From 9e0467cbf08822a23973c4cd27aad0276d011ba3 Mon Sep 17 00:00:00 2001 From: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:37:09 -0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20add=20global=20setti?= =?UTF-8?q?ngs=20link=20(#2093)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 💡 add global settings link (#2093) --- addons/api/mirage/factories/scope.js | 23 ++++--- addons/core/translations/resources/en-us.yaml | 6 ++ ui/admin/app/components/form/scope/index.hbs | 2 +- .../scopes/scope/add-storage-policy/index.js | 13 +--- ui/admin/app/templates/scopes/scope.hbs | 10 +++ ui/admin/app/templates/scopes/scope/edit.hbs | 19 +++++- ui/admin/tests/acceptance/scopes/read-test.js | 62 ++++++++++++++++++- 7 files changed, 112 insertions(+), 23 deletions(-) diff --git a/addons/api/mirage/factories/scope.js b/addons/api/mirage/factories/scope.js index 79dcbd872..6bedf3406 100644 --- a/addons/api/mirage/factories/scope.js +++ b/addons/api/mirage/factories/scope.js @@ -11,15 +11,20 @@ import generateId from '../helpers/id'; export default factory.extend({ type: 'global', - authorized_actions: () => - permissions.authorizedActionsFor('scope') || [ - 'no-op', - 'read', - 'update', - 'delete', - 'attach-storage-policy', - 'detach-storage-policy', - ], + authorized_actions() { + const authorizedActions = ['no-op', 'read', 'update']; + + // Storage policies can only be attatched to global and org scopes. + if (this.type === 'global' || this.type === 'org') { + authorizedActions.push('attach-storage-policy', 'detach-storage-policy'); + } + + if (this.type === 'org' || this.type === 'project') { + authorizedActions.push('delete'); + } + + return permissions.authorizedActionsFor('scope') || authorizedActions; + }, authorized_collection_actions() { const collectionActions = { diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 17dd1b9f1..7e9325c6f 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -326,6 +326,12 @@ session: address-port: Address & port ssh: SSH shell: Shell +global: + title: Global + description: The global scope is the outermost scope. There is always a single global scope and it cannot be deleted. + messages: + settings: + title: Global Settings org: title: Org title_plural: Orgs diff --git a/ui/admin/app/components/form/scope/index.hbs b/ui/admin/app/components/form/scope/index.hbs index 1f12c8f0f..3aa48c5c9 100644 --- a/ui/admin/app/components/form/scope/index.hbs +++ b/ui/admin/app/components/form/scope/index.hbs @@ -51,7 +51,7 @@ {{/if}} - {{#if (can 'save model' @model)}} + {{#if (and (can 'save model' @model) (not @model.isGlobal))}}
{{t 'resources.global.description'}}
+ {{/if}} {{#if @model.isOrg}}