Skip to content

Commit

Permalink
feat: update notification to use hds toast component (#16519)
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriia-ruban committed Mar 6, 2023
1 parent 7ea2bd6 commit 63204b5
Show file tree
Hide file tree
Showing 59 changed files with 428 additions and 847 deletions.
3 changes: 3 additions & 0 deletions .changelog/16519.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Update to use Hds::Toast component to show notifications
```
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
{{#if (eq @type 'remove')}}
{{#if @error}}
<Notice
class="notification-delete"
@type="error"
<Hds::Toast
@color='critical'
...attributes
as |notice|>
<notice.Header>
<strong>Error!</strong>
</notice.Header>
<notice.Body>
<p>
There was an error invalidating the Lock Session.
{{#if (and @error.status @error.detail)}}
as |T|>
<T.Title>Error!</T.Title>
<T.Description>
There was an error invalidating the Lock Session.
{{#if (and @error.status @error.detail)}}
<br />{{@error.status}}: {{@error.detail}}
{{/if}}
</p>
</notice.Body>
</Notice>
{{/if}}
</T.Description>
</Hds::Toast>
{{else}}
<Notice
class="notification-delete"
@type="success"
<Hds::Toast
@color='success'
...attributes
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your Lock Session has been invalidated.
</p>
</notice.Body>
</Notice>
as |T|>
<T.Title>Success!</T.Title>
<T.Description>
Your Lock Session has been invalidated.
</T.Description>
</Hds::Toast>
{{/if}}
{{else if (eq @type 'kv')}}
<Hds::Alert @type='inline' @color='warning' class='mb-3' data-test-session-warning as |A|>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{{#if (eq @type 'remove')}}
<Notice
class="notification-delete"
@type="success"
...attributes
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your Namespace has been marked for deletion.
</p>
</notice.Body>
</Notice>
<Hds::Toast @color='success'
...attributes
as |T|>
<T.Title>Success!</T.Title>
<T.Description>Your Namespace has been marked for deletion.</T.Description>
</Hds::Toast>
{{/if}}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{{#if (eq @type 'remove')}}
<Notice
class="notification-delete"
@type="success"
<Hds::Toast
@color='success'
...attributes
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your Partition has been marked for deletion.
</p>
</notice.Body>
</Notice>
as |T|>
<T.Title>Success!</T.Title>
<T.Description>
Your Partition has been marked for deletion.
</T.Description>
</Hds::Toast>
{{/if}}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{{#if (eq @type 'remove')}}
<Notice
class="notification-delete"
@type="success"
<Hds::Toast
@color='success'
...attributes
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your Peer has been marked for deletion.
</p>
</notice.Body>
</Notice>
as |T|>
<T.Title>Success!</T.Title>
<T.Description>
Your Peer has been marked for deletion.
</T.Description>
</Hds::Toast>
{{/if}}
11 changes: 3 additions & 8 deletions ui/packages/consul-ui/app/components/app/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
@extend %app-notifications;
}
%app-notifications {
display: flex;
flex-direction: column;
align-items: center;

position: fixed;
z-index: 50;
top: -45px;
left: 0;
z-index: 100;
bottom: 2rem;
left: 1.5rem;

pointer-events: none;
}
Expand Down Expand Up @@ -125,7 +121,6 @@ main {
%main-nav-horizontal-toggle:checked + header > div > nav:first-of-type {
left: calc(var(--chrome-width, 280px) * -1);
}
%main-nav-horizontal-toggle ~ main .notifications,
%main-nav-horizontal-toggle ~ main {
margin-left: var(--chrome-width, 280px);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div
class="app-notification"
class='app-notification'
...attributes
{{style
(array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,32 @@ as |api|>

<BlockSlot @name="error" as |after|>
{{#if (string-starts-with api.error.detail 'duplicate intention found:')}}
<Notice
{{notification
after=(action after)
}}
class="notification-update"
@type="error"
as |notice|>
<notice.Header>
<strong>Intention exists!</strong>
</notice.Header>
<notice.Body>
<p>
An intention already exists for this Source-Destination pair. Please enter a different combination of Services, or search the intentions to edit an existing intention.
</p>
</notice.Body>
</Notice>
<Hds::Toast
@color='critical'
{{notification
after=(action after)
}}
as |T|>
<T.Title>Intention exists!</T.Title>
<T.Description>
An intention already exists for this Source-Destination pair. Please enter a different combination of Services, or search the intentions to edit an existing intention.
</T.Description>
</Hds::Toast>
{{else}}
<Notice
{{notification
after=(action after)
}}
class="notification-update"
@type="error"
as |notice|>
<notice.Header>
<strong>Error!</strong>
</notice.Header>
<notice.Body>
<p>
There was an error saving your intention.
{{#if (and api.error.status api.error.detail)}}
<br />{{api.error.status}}: {{api.error.detail}}
{{/if}}
</p>
</notice.Body>
</Notice>
<Hds::Toast
@color='critical'
{{notification
after=(action after)
}}
as |T|>
<T.Title>Error!</T.Title>
<T.Description>
There was an error saving your intention.
{{#if (and api.error.status api.error.detail)}}
<br />{{api.error.status}}: {{api.error.detail}}
{{/if}}
</T.Description>
</Hds::Toast>
{{/if}}
</BlockSlot>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,4 @@
td.intent- strong {
@extend %pill-l7;
}
.notice.allow {
@extend %notice-success;
}
.notice.deny {
@extend %notice-error;
}
.notice.permissions {
@extend %notice-info;
}
}
19 changes: 5 additions & 14 deletions ui/packages/consul-ui/app/components/data-loader/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,13 @@
{{#yield-slot name="disconnected" params=(block-params (action dispatch "RESET"))}}
{{yield api}}
{{else}}
<Notice
<Hds::Toast @color='warning'
{{notification
sticky=true
}}
class="notification-update"
@type="warning"
as |notice|>
<notice.Header>
<strong>Warning!</strong>
</notice.Header>
<notice.Body>
<p>
An error was returned whilst loading this data, refresh to try again.
</p>
</notice.Body>
</Notice>
}} as |T|>
<T.Title>Warning!</T.Title>
<T.Description>An error was returned whilst loading this data, refresh to try again.</T.Description>
</Hds::Toast>
{{/yield-slot}}
{{/if}}
</State>
Expand Down
71 changes: 24 additions & 47 deletions ui/packages/consul-ui/app/components/data-writer/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,14 @@ as |after|}}
{{#yield-slot name="removed" params=(block-params after)}}
{{yield api}}
{{else}}
<Notice
{{notification
after=(action after)
}}
class="notification-delete"
@type="success"
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your {{or label type}} has been deleted.
</p>
</notice.Body>
</Notice>
<Hds::Toast
@color='success'
{{notification
after=(action after)
}} as |T|>
<T.Title>Success!</T.Title>
<T.Description>Your {{or label type}} has been deleted.</T.Description>
</Hds::Toast>
{{/yield-slot}}
{{/let}}
</State>
Expand All @@ -66,22 +58,14 @@ as |after|}}
{{#yield-slot name="persisted" params=(block-params after)}}
{{yield api}}
{{else}}
<Notice
<Hds::Toast
@color='success'
{{notification
after=(action after)
}}
class="notification-update"
@type="success"
as |notice|>
<notice.Header>
<strong>Success!</strong>
</notice.Header>
<notice.Body>
<p>
Your {{or label type}} has been saved.
</p>
</notice.Body>
</Notice>
}} as |T|>
<T.Title>Success!</T.Title>
<T.Description>Your {{or label type}} has been saved.</T.Description>
</Hds::Toast>
{{/yield-slot}}
{{/let}}
</State>
Expand All @@ -93,27 +77,20 @@ as |after|}}
{{#yield-slot name="error" params=(block-params after api.error)}}
{{yield api}}
{{else}}
<Notice
<Hds::Toast
@color='critical'
{{notification
after=(action after)
}}
class="notification-update"
@type="error"
as |notice|>
<notice.Header>
<strong>Error!</strong>
</notice.Header>
<notice.Body>
<p>
There was an error saving your {{or label type}}.
{{#if (and api.error.status api.error.detail)}}
}} as |T|>
<T.Title>Error!</T.Title>
<T.Description>There was an error saving your {{or label type}}.
{{#if (and api.error.status api.error.detail)}}
<br />{{api.error.status}}: {{api.error.detail}}
{{else if api.error.message}}
{{else if api.error.message}}
<br />{{api.error.message}}
{{/if}}
</p>
</notice.Body>
</Notice>
{{/if}}
</T.Description>
</Hds::Toast>
{{/yield-slot}}
{{/let}}
</State>
Expand Down
Loading

0 comments on commit 63204b5

Please sign in to comment.