feat: 🎸 enable delete confirm for all delete actions

This commit is contained in:
Randall Morey committed 2020-09-30 18:41:55 -04:00
1 parent 51e6fe2db0
commit fa34a292ca
13 files changed
+42 -24

No files matched your search

@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../utilities/confirm';
export default class ScopesScopeAuthMethodsRoute extends Route {
// =services
@@ -71,10 +72,11 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
*/
@action
@loading
@confirm('questions.delete-confirm')
async delete(authMethod) {
try {
await authMethod.destroyRecord();
await this.transitionTo('scopes.scope.auth-methods');
await this.replaceWith('scopes.scope.auth-methods');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
} catch (error) {
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../utilities/confirm';
export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route {
// =services
@@ -71,10 +72,11 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route
*/
@action
@loading
async delete(account) {
@confirm('questions.delete-confirm')
async deleteAccount(account) {
try {
await account.destroyRecord();
await this.transitionTo('scopes.scope.auth-methods.auth-method.accounts');
await this.replaceWith('scopes.scope.auth-methods.auth-method.accounts');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
} catch (error) {
+3 -1
View File
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../utilities/confirm';
export default class ScopesScopeGroupsRoute extends Route {
// =services
@@ -68,12 +69,13 @@ export default class ScopesScopeGroupsRoute extends Route {
*/
@action
@loading
@confirm('questions.delete-confirm')
async delete(group) {
try {
await group.destroyRecord();
await this.replaceWith('scopes.scope.groups');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
await this.transitionTo('scopes.scope.groups');
} catch (error) {
//TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../utilities/confirm';
export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route {
// =services
@@ -61,16 +62,17 @@ export default class ScopesScopeProjectsProjectHostCatalogsRoute extends Route {
/**
* Deletes the host catalog and redirects to index.
* @param {ProjectModel} project
* @param {HostCatalogModel} hostCatalog
*/
@action
@loading
async delete(project) {
@confirm('questions.delete-confirm')
async delete(hostCatalog) {
try {
await project.destroyRecord();
await hostCatalog.destroyRecord();
await this.replaceWith('scopes.scope.projects.project.host-catalogs');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo('scopes.scope.projects.project.host-catalogs');
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../../../utilities/confirm';
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRoute extends Route {
// =services
@@ -70,13 +71,14 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsRo
*/
@action
@loading
async delete(hostSet) {
@confirm('questions.delete-confirm')
async deleteHostSet(hostSet) {
try {
await hostSet.destroyRecord();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo(
await this.replaceWith(
'scopes.scope.projects.project.host-catalogs.host-catalog.host-sets'
);
this.notify.success(this.intl.t('notifications.delete-success'));
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../../../utilities/confirm';
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostsRoute extends Route {
// =services
@@ -70,14 +71,15 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostsRoute
*/
@action
@loading
async delete(host) {
@confirm('questions.delete-confirm')
async deleteHost(host) {
try {
await host.destroyRecord();
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo(
await this.replaceWith(
'scopes.scope.projects.project.host-catalogs.host-catalog.hosts'
);
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../utilities/confirm';
export default class ScopesScopeProjectsProjectTargetsRoute extends Route {
// =services
@@ -62,12 +63,13 @@ export default class ScopesScopeProjectsProjectTargetsRoute extends Route {
*/
@action
@loading
@confirm('questions.delete-confirm')
async delete(target) {
try {
await target.destroyRecord();
await this.replaceWith('scopes.scope.projects.project.targets');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo('scopes.scope.projects.project.targets');
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
+3 -1
View File
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../utilities/confirm';
export default class ScopesScopeRolesRoute extends Route {
// =services
@@ -68,12 +69,13 @@ export default class ScopesScopeRolesRoute extends Route {
*/
@action
@loading
@confirm('questions.delete-confirm')
async delete(role) {
try {
await role.destroyRecord();
await this.replaceWith('scopes.scope.roles');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo('scopes.scope.roles');
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
+3 -1
View File
@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../utilities/confirm';
export default class ScopesScopeUsersRoute extends Route {
// =services
@@ -69,12 +70,13 @@ export default class ScopesScopeUsersRoute extends Route {
*/
@action
@loading
@confirm('questions.delete-confirm')
async delete(user) {
try {
await user.destroyRecord();
await this.replaceWith('scopes.scope.users');
this.refresh();
this.notify.success(this.intl.t('notifications.delete-success'));
this.transitionTo('scopes.scope.users');
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
@@ -2,7 +2,7 @@
<dropdown.button
@style="danger"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
{{on "click" (route-action "deleteAccount" @model)}}
>
{{t 'actions.delete'}}
</dropdown.button>
@@ -19,4 +19,4 @@
>
{{t 'resources.host-catalog.actions.delete'}}
</dropdown.button>
</Rose::Dropdown>
</Rose::Dropdown>
@@ -5,8 +5,8 @@
<dropdown.button
@style="danger"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
{{on "click" (route-action "deleteHostSet" @model)}}
>
{{t 'resources.host-set.actions.delete'}}
</dropdown.button>
</Rose::Dropdown>
</Rose::Dropdown>
@@ -2,8 +2,8 @@
<dropdown.button
@style="danger"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
{{on "click" (route-action "deleteHost" @model)}}
>
{{t 'resources.host.actions.delete'}}
</dropdown.button>
</Rose::Dropdown>
</Rose::Dropdown>