Skip to content

Commit

Permalink
Allow notification subscriptions to be enabled/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
EricTendian committed Sep 26, 2024
1 parent eb4e3e6 commit 879c1ac
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/components/notification-subscription-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default class NotificationSubscriptionFormComponent extends Component {
}
let data = {
name: formdata.get('name'),
enabled: formdata.get('enabled') == 'on',
keywords: formdata.get('keywords').split('\n'),
ignore_keywords: formdata.get('ignore_keywords').split('\n'),
topic: formdata.getAll('topic').join('|'),
Expand Down
1 change: 1 addition & 0 deletions app/models/transcript-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Model, { attr } from '@ember-data/model';

export default class TranscriptSubscriptionModel extends Model {
@attr name;
@attr enabled;
@attr keywords;
@attr ignore_keywords;
@attr location;
Expand Down
17 changes: 14 additions & 3 deletions app/templates/components/notification-subscription-form.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<h2 id="subscription-form-heading" class="fs-4">{{if @subscription "Edit" "Add a new"}} subscription</h2>
<form id="subscription-form" aria-label="New subscription form" {{on "submit" this.submit}} {{did-insert this.initData}}>
<div class="mb-3">
<label for="nameInput" class="form-label">Subscription name</label>
<input type="text" class="form-control" id="nameInput" name="name" value="{{@subscription.name}}" required />
<div class="row mb-3">
<div class="col">
<label for="nameInput" class="form-label">Subscription name</label>
<input type="text" class="form-control" id="nameInput" name="name" value="{{@subscription.name}}" required />
</div>
<div class="col-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="enabledInput" name="enabled"
checked={{if @subscription @subscription.enabled true}}>
<label class="form-check-label" for="enabledInput">
Enabled?
</label>
</div>
</div>
</div>
<div class="mb-3">
<label for="keywordList" class="form-label">Keywords to match, one per line (will be interpreted as exact matches, case insensitive)</label>
Expand Down
10 changes: 9 additions & 1 deletion app/templates/components/notification-subscription-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
<div class="card-header">
<div class="row">
<div class="col">
<h5 class="mt-1 mb-0">{{subscription.name}}</h5>
<h5 class="mt-1 mb-0">
{{#unless subscription.enabled}}
<span class="badge bg-secondary me-2">Disabled</span>
{{/unless}}
{{subscription.name}}
</h5>
</div>
<div class="col-3 d-flex justify-content-end">
<button type="button" class="btn btn-secondary btn-sm me-2" aria-label="Edit" {{on "click" (fn @onEdit subscription)}}><FaIcon @icon="pencil-alt" /></button>
Expand Down Expand Up @@ -58,6 +63,9 @@
<div class="mb-3">
<p class="fw-bold">Will notify via:</p>
<NotificationChannelList @channels={{subscription.notification_channels}} />
{{#unless subscription.enabled}}
<p class="mt-2 fst-italic">Note: Notifications are currently disabled. Please edit and re-enable the subscription to receive them.</p>
{{/unless}}
</div>
</div>
</div>
Expand Down

0 comments on commit 879c1ac

Please sign in to comment.