Merge pull request #251 from hashicorp/feature-apply-confirm

feat: 🎸 enable delete confirm for all delete actions
This commit is contained in:
Susmitha Girumala authored and GitHub committed 2020-10-01 19:31:12 -04:00
commit 1db724aade
17 files changed
+51 -25

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 });
@@ -3,6 +3,7 @@ import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { hash, all } from 'rsvp';
import loading from 'ember-loading/decorator';
import { confirm } from '../../../../../utilities/confirm';
export default class ScopesScopeGroupsGroupMembersRoute extends Route {
// =services
@@ -38,10 +39,11 @@ export default class ScopesScopeGroupsGroupMembersRoute extends Route {
*/
@action
@loading
@confirm('questions.remove-confirm')
async removeMember(group, member) {
try {
await group.removeMember(member.id);
await this.refresh();
this.refresh();
this.notify.success(this.intl.t('notifications.remove-success'));
} catch (error) {
// TODO: replace with translated strings
@@ -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 });
@@ -3,6 +3,7 @@ import { hash, all } from 'rsvp';
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 ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHostSetHostsRoute extends Route {
// =services
@@ -37,6 +38,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
*/
@action
@loading
@confirm('questions.remove-confirm')
async removeHost(hostSet, host) {
try {
const scopeID = this.modelFor('scopes.scope.projects.project').id;
@@ -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,6 +3,7 @@ import { all, hash } from 'rsvp';
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 ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extends Route {
// =services
@@ -55,6 +56,7 @@ export default class ScopesScopeProjectsProjectTargetsTargetHostSetsRoute extend
*/
@action
@loading
@confirm('questions.remove-confirm')
async removeHostSet(target, hostSet) {
try {
await target.removeHostSet(hostSet.id);
+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,6 +3,7 @@ import { all, hash } from 'rsvp';
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 ScopesScopeRolesRolePrincipalsRoute extends Route {
// =services
@@ -65,6 +66,7 @@ export default class ScopesScopeRolesRolePrincipalsRoute extends Route {
*/
@action
@loading
@confirm('questions.remove-confirm')
async removePrincipal(principal) {
try {
const role = this.modelFor('scopes.scope.roles.role');
+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>