Skip to content

me.index: Hide "Email Notifications" until the feature is fully developed #2622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/controllers/me/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { alias, sort, filterBy, notEmpty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Ember from 'ember';

import ajax from '../../utils/ajax';

Expand All @@ -22,6 +24,10 @@ export default Controller.extend({
emailNotificationsError: false,
emailNotificationsSuccess: false,

hasEmailNotificationFeature: computed(function () {
return Ember.testing;
}),

setAllEmailNotifications(value) {
this.get('ownedCrates').forEach(c => {
c.set('email_notifications', value);
Expand Down
62 changes: 35 additions & 27 deletions app/templates/me/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,46 @@
<form local-class="me-email-notifications" {{ action 'saveEmailNotifications' on='submit' }} >
<h2>Email Notification Preferences</h2>

<p>
To aid detection of unauthorized crate changes, we email you each time a new version of a crate you own is pushed.
By receiving and reading these emails, you help protect the Rust ecosystem. You may also choose to turn these
emails off for any of your crates listed below.
</p>
{{#if this.hasEmailNotificationFeature}}
<p>
To aid detection of unauthorized crate changes, we email you each time a new version of a crate you own is pushed.
By receiving and reading these emails, you help protect the Rust ecosystem. You may also choose to turn these
emails off for any of your crates listed below.
</p>

<div local-class="notifications-row">
<button type='button' local-class="select-all-button" {{action 'emailNotificationsSelectAll'}}>Select All</button>
<button type='button' local-class="deselect-all-button" {{action 'emailNotificationsSelectNone'}}>Deselect All</button>
</div>
<div local-class="notifications-row">
<button type='button' local-class="select-all-button" {{action 'emailNotificationsSelectAll'}}>Select All</button>
<button type='button' local-class="deselect-all-button" {{action 'emailNotificationsSelectNone'}}>Deselect All</button>
</div>

<ul local-class="notifications-list">
{{#each this.ownedCrates as |ownedCrate|}}
<OwnedCrateRow @ownedCrate={{ownedCrate}} />
{{/each}}
</ul>
<ul local-class="notifications-list">
{{#each this.ownedCrates as |ownedCrate|}}
<OwnedCrateRow @ownedCrate={{ownedCrate}} />
{{/each}}
</ul>

<div local-class="notifications-row">
{{#if this.emailNotificationsError}}
<div local-class="notifications-error">
An error occurred while saving your email preferences.
<div local-class="notifications-row">
{{#if this.emailNotificationsError}}
<div local-class="notifications-error">
An error occurred while saving your email preferences.
</div>
{{/if}}
{{#if this.emailNotificationsSuccess}}
<div local-class="notifications-success">
Your email notification preferences have been updated!
</div>
{{/if}}
<div local-class="right">
<button type='submit' local-class="update-notifications-button">Update</button>
</div>
{{/if}}
{{#if this.emailNotificationsSuccess}}
<div local-class="notifications-success">
Your email notification preferences have been updated!
</div>
{{/if}}
<div local-class="right">
<button type='submit' local-class="update-notifications-button">Update</button>
</div>
</div>
{{else}}
<p>
To aid detection of unauthorized crate changes, we plan to email you each time a new version of a crate you own is
pushed. This feature is still work-in-progress, if you want to help out have a look at
<a href="https://github.com/rust-lang/crates.io/issues/1895">#1895</a>.
</p>
{{/if}}
</form>

<div local-class="me-subheading">
Expand Down