Merge branch 'develop' into chore-logomark
This commit is contained in:
28 files changed
+285
-28
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) {
|
||||
|
||||
@@ -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 ScopesScopeProjectsRoute extends Route {
|
||||
// =services
|
||||
@@ -9,6 +10,7 @@ export default class ScopesScopeProjectsRoute extends Route {
|
||||
@service intl;
|
||||
@service notify;
|
||||
@service session;
|
||||
@service confirm;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -84,12 +86,13 @@ export default class ScopesScopeProjectsRoute extends Route {
|
||||
*/
|
||||
@action
|
||||
@loading
|
||||
@confirm('questions.delete-confirm')
|
||||
async delete(project) {
|
||||
try {
|
||||
await project.destroyRecord();
|
||||
await this.replaceWith('scopes.scope.projects');
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t('notifications.delete-success'));
|
||||
this.transitionTo('scopes.scope.projects');
|
||||
} 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 });
|
||||
|
||||
+5
-3
@@ -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
@@ -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;
|
||||
|
||||
+6
-4
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import Service from '@ember/service';
|
||||
import { getOwner } from '@ember/application';
|
||||
import { bind } from '@ember/runloop';
|
||||
import { Promise, resolve } from 'rsvp';
|
||||
import config from '../config/environment';
|
||||
|
||||
export default class ConfirmService extends Service {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* When the confirm service is disabled, it always returns resolving promises.
|
||||
* @type {boolean}
|
||||
*/
|
||||
enabled = config.enableConfirmService;
|
||||
|
||||
/**
|
||||
* The window's confirm function, bound to the window scope.
|
||||
* @type {Function}
|
||||
*/
|
||||
get confirmFn() {
|
||||
// The Ember way of accessing globals...
|
||||
const document =
|
||||
getOwner(this).lookup('service:-document').documentElement;
|
||||
// defaultView === window, but without using globals directly
|
||||
const windowRef = document.parentNode.defaultView;
|
||||
const { confirm } = windowRef;
|
||||
return bind(windowRef, confirm);
|
||||
}
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* When the service is enabled, returns a promise that resolves if the user
|
||||
* accepts the confirmation, otherwise rejects. If the service is disabled,
|
||||
* this method always returns a resolving promise.
|
||||
* @param {string} text
|
||||
* @return {Promise}
|
||||
*/
|
||||
confirm(text) {
|
||||
if (this.enabled) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.confirmFn(text)) {
|
||||
return resolve();
|
||||
} else {
|
||||
return reject();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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>
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@
|
||||
>
|
||||
{{t 'resources.host-catalog.actions.delete'}}
|
||||
</dropdown.button>
|
||||
</Rose::Dropdown>
|
||||
</Rose::Dropdown>
|
||||
+2
-2
@@ -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
-2
@@ -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>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
/**
|
||||
* Decorates a method whereby calls to the method will first request
|
||||
* confirmation via the confirmation service. If the user accepts, the
|
||||
* original method is executed. If the user denies, it is not.
|
||||
*/
|
||||
export function confirm(confirmationTextKey) {
|
||||
return function (_target, _propertyKey, desc) {
|
||||
const method = desc.value;
|
||||
desc.value = function () {
|
||||
const owner = getOwner(this);
|
||||
const confirmService = owner.lookup('service:confirm');
|
||||
const intl = owner.lookup('service:intl');
|
||||
const text = intl.t(confirmationTextKey);
|
||||
return confirmService.confirm(text)
|
||||
// If user confirmed, execute the decorated method
|
||||
.then(() => method.apply(this, arguments))
|
||||
// If the user denied, gracefully handle promise rejection with no-op
|
||||
.catch(() => {});
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user