Skip to content
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

[ui, helios] Toast Component #16099

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion ui/app/components/job-page/parts/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import classic from 'ember-classic-decorator';
@tagName('')
export default class Title extends Component {
@service router;
@service flashMessages;

job = null;
title = null;
Expand Down Expand Up @@ -37,7 +38,7 @@ export default class Title extends Component {
this.flashMessages.add({
title: 'Job Purged',
message: `You have purged ${this.job.name}`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/policy-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class PolicyEditorComponent extends Component {

this.flashMessages.add({
title: 'Policy Saved',
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -55,7 +55,7 @@ export default class PolicyEditorComponent extends Component {
this.flashMessages.add({
title: `Error creating Policy ${this.policy.name}`,
message: error,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/variable-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default class VariableFormComponent extends Component {
this.flashMessages.add({
title: 'Variable saved',
message: `${this.path} successfully saved`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -245,7 +245,7 @@ export default class VariableFormComponent extends Component {
this.flashMessages.add({
title: `Error saving ${this.path}`,
message: error,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/controllers/clients/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export default class ClientController extends Controller.extend(
this.flashMessages.add({
title: 'Metadata added',
message: `${key} successfully saved`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 3000,
});
Expand All @@ -329,7 +329,7 @@ export default class ClientController extends Controller.extend(
this.flashMessages.add({
title: `Error saving Metadata`,
message: error,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/controllers/jobs/run/templates/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ export default class JobsRunTemplatesManageController extends Controller {
this.flashMessages.add({
title: 'Job template deleted',
message: `${model.path} successfully deleted`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
} catch (err) {
this.flashMessages.add({
title: `Job template could not be deleted.`,
message: err,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/controllers/jobs/run/templates/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class JobsRunTemplatesNewController extends Controller {
this.flashMessages.add({
title: 'Job template saved',
message: `${this.templateName} successfully saved`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -73,7 +73,7 @@ export default class JobsRunTemplatesNewController extends Controller {
this.flashMessages.add({
title: 'Job template cannot be saved.',
message: e,
type: 'error',
color: 'critical',
destroyOnClick: false,
timeout: 5000,
});
Expand Down
8 changes: 4 additions & 4 deletions ui/app/controllers/jobs/run/templates/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class JobsRunTemplatesController extends Controller {
this.flashMessages.add({
title: 'Job template saved',
message: `${this.model.path} successfully editted`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -47,7 +47,7 @@ export default class JobsRunTemplatesController extends Controller {
this.flashMessages.add({
title: 'Job template cannot be editted.',
message: e,
type: 'error',
color: 'critical',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -61,7 +61,7 @@ export default class JobsRunTemplatesController extends Controller {
this.flashMessages.add({
title: 'Job template deleted',
message: `${this.model.path} successfully deleted`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -70,7 +70,7 @@ export default class JobsRunTemplatesController extends Controller {
this.flashMessages.add({
title: `Job template could not be deleted.`,
message: err,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
8 changes: 4 additions & 4 deletions ui/app/controllers/policies/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class PoliciesPolicyController extends Controller {
yield this.policy.save();
this.flashMessages.add({
title: 'Policy Deleted',
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand All @@ -48,7 +48,7 @@ export default class PoliciesPolicyController extends Controller {
this.flashMessages.add({
title: `Error deleting Policy ${this.policy.name}`,
message: err,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class PoliciesPolicyController extends Controller {
this.flashMessages.add({
title: 'Example Token Created',
message: `${newToken.secret}`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 30000,
customAction: {
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class PoliciesPolicyController extends Controller {
yield this.refreshTokens();
this.flashMessages.add({
title: 'Token successfully deleted',
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/controllers/variables/variable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export default class VariablesVariableIndexController extends Controller {
this.flashMessages.add({
title: 'Variable deleted',
message: `${this.model.path} successfully deleted`,
type: 'success',
color: 'success',
destroyOnClick: false,
timeout: 5000,
});
} catch (err) {
this.flashMessages.add({
title: `Error deleting ${this.model.path}`,
message: err,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
2 changes: 1 addition & 1 deletion ui/app/routes/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class AllocationRoute extends Route.extend(WithWatchers) {
this.flashMessages.add({
title: `Error: Not Found`,
message: `Allocation of id: ${allocId} was not found.`,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
2 changes: 1 addition & 1 deletion ui/app/routes/jobs/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class JobsRunIndexRoute extends Route {
this.flashMessages.add({
title: `Error loading job template`,
message: error404.detail,
type: 'error',
color: 'critical',
destroyOnClick: false,
sticky: true,
});
Expand Down
2 changes: 1 addition & 1 deletion ui/app/services/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class TokenService extends Service {
message: `Your token access expires ${moment(
this.selfToken.expirationTime
).fromNow()}`,
type: 'error',
color: 'warning',
destroyOnClick: false,
sticky: true,
customCloseAction: () => {
Expand Down
64 changes: 6 additions & 58 deletions ui/app/styles/core/notifications.scss
Original file line number Diff line number Diff line change
@@ -1,66 +1,14 @@
$bonusRightPadding: 20px;

section.notifications {
position: fixed;
bottom: 10px;
right: 10px;
bottom: 20px;
right: 20px;
z-index: 100;
justify-items: right;
display: grid;

.flash-message {
width: 300px;
transition: all 700ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
padding: 1rem;
margin-bottom: 1rem;
box-shadow: 1px 1px 4px 0px rgb(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
padding-right: $bonusRightPadding;

&.alert-success {
background-color: lighten($nomad-green, 50%);
}
&.alert-error {
background-color: lighten($danger, 45%);
}

h3 {
font-weight: bold;
}

span.close-button {
position: absolute;
top: 0;
right: 0;
padding: 10px;
line-height: 100%;
font-size: 1.5rem;
cursor: pointer;
}

.alert-progress {
width: 100%;
border-radius: 3px;
position: absolute;
bottom: 0;
left: 0;
.alert-progressBar {
background-color: $nomad-green;
height: 2px;
width: 0%;
}
}

&.active {
.alert-progress {
.alert-progressBar {
width: 100%;
}
}
}

.custom-action-button {
width: calc(100% + $bonusRightPadding - 1rem);
margin: 1.5rem 0 0;
&:not(:last-child) {
margin-bottom: 1rem;
}
}
}
39 changes: 19 additions & 20 deletions ui/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@
<section class="notifications">
{{#each this.flashMessages.queue as |flash|}}
<FlashMessage @flash={{flash}} as |component flash close|>
<span class="close-button" role="button" {{on "click"
(queue
(action close)
(action (optional flash.customCloseAction))
)
}}>&times;</span>
{{#if flash.title}}
<h3>{{flash.title}}</h3>
{{/if}}
{{#if flash.message}}
<p>{{flash.message}}</p>
{{/if}}
{{#if flash.customAction}}
<button type="button" class="button custom-action-button" {{on "click" (action flash.customAction.action)}}>{{flash.customAction.label}}</button>
{{/if}}
{{#if component.showProgressBar}}
<div class="alert-progress">
<div class="alert-progressBar" style={{component.progressDuration}}></div>
</div>
{{/if}}
<Hds::Toast
@color={{or flash.color "neutral"}}
@onDismiss={{
queue
(action close)
(action (optional flash.customCloseAction))

}}
as |T|>
{{#if flash.title}}
<T.Title>{{flash.title}}</T.Title>
{{/if}}
{{#if flash.message}}
<T.Description>{{flash.message}}</T.Description>
{{/if}}
{{#if flash.customAction}}
<T.Button @text={{flash.customAction.label}} @color="secondary" {{on "click" (action flash.customAction.action)}} />
{{/if}}
</Hds::Toast>
</FlashMessage>
{{/each}}
</section>
Expand Down