diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml
index aee5967ec..92493a6b8 100644
--- a/addons/core/translations/resources/en-us.yaml
+++ b/addons/core/translations/resources/en-us.yaml
@@ -720,22 +720,33 @@ role:
title: Grant Editor
description: Add each new grant string on a different line
string-formats:
- title: String format
title_plural: String formats
+ syntax: Syntax
+ syntax-format: Syntax format
+ more-info: More info
resource-type:
label: Singular resource type
- help: Applies actions to a specific resource type
+ help: Applies collection actions to a specific resource type in a single grant.
resource:
label: Specific resource(s)
- help: Applies actions to one or more individual resources
+ help: Applies ID actions to one or more individual resources in a single grant.
pinned-id:
label: Pinned ID
- help: '"Pins" actions to a non-top-level type within a specific resource ID. Only available for certain resource types. '
- link: More info
+ help: '"Pins" actions to a non-top-level type within a specific ID in a single grant.'
+ output-fields:
+ label: Output fields
+ help: Defines which fields from a request are returned to the user.
+ account-template:
+ label: Account template
+ help: Substitutes the account ID from the token used to perform the request.
+ user-template:
+ label: User template
+ help: Substitutes the user ID from the token used to perform the request.
insert-actions: insert actions
insert-resource-types: insert resource types
insert-id: insert id
insert-resource-ids: insert resource ids
+ insert-output-fields: insert output fields
export:
format: Format
formatted-export-aria-label: Formatted export
diff --git a/ui/admin/app/components/grant-string-formats/index.hbs b/ui/admin/app/components/grant-string-formats/index.hbs
index fb1c8b1ff..28b94f47d 100644
--- a/ui/admin/app/components/grant-string-formats/index.hbs
+++ b/ui/admin/app/components/grant-string-formats/index.hbs
@@ -3,61 +3,45 @@
SPDX-License-Identifier: BUSL-1.1
}}
-
-
- {{t
- 'resources.role.edit-grants.string-formats.resource-type.label'
- }}
- {{t
- 'resources.role.edit-grants.string-formats.resource-type.help'
- }}
-
-
- {{t
- 'resources.role.edit-grants.string-formats.resource.label'
- }}
- {{t
- 'resources.role.edit-grants.string-formats.resource.help'
- }}
-
-
- {{t
- 'resources.role.edit-grants.string-formats.pinned-id.label'
- }}
-
- {{t 'resources.role.edit-grants.string-formats.pinned-id.help'}}
-
- {{t 'resources.role.edit-grants.string-formats.pinned-id.link'}}
-
-
-
-
+ {{t
+ 'resources.role.edit-grants.string-formats.syntax-format'
+ }}
+
+ {{#let F.options as |formatType|}}
+ {{t
+ (concat
+ 'resources.role.edit-grants.string-formats.' formatType '.label'
+ )
+ }}
+ {{t
+ (concat
+ 'resources.role.edit-grants.string-formats.' formatType '.help'
+ )
+ }}
+ {{/let}}
+
+
- {{t 'resources.role.edit-grants.string-formats.title'}}
-
\ No newline at end of file
+ {{t 'resources.role.edit-grants.string-formats.syntax'}}
+
+
+
\ No newline at end of file
diff --git a/ui/admin/app/components/grant-string-formats/index.js b/ui/admin/app/components/grant-string-formats/index.js
index fc6fc5df4..64c2b41b3 100644
--- a/ui/admin/app/components/grant-string-formats/index.js
+++ b/ui/admin/app/components/grant-string-formats/index.js
@@ -6,6 +6,7 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';
+import { action } from '@ember/object';
export default class GrantStringFormatsIndex extends Component {
// =services
@@ -18,15 +19,38 @@ export default class GrantStringFormatsIndex extends Component {
resourceType: 'resource-type',
resource: 'resource',
pinnedId: 'pinned-id',
+ outputFields: 'output-fields',
+ accountTemplate: 'account-template',
+ userTemplate: 'user-template',
};
+ stringFormatTypesList = Object.values(this.stringFormatTypes);
+
stringFormats = {
- [this.stringFormatTypes.resourceType]:
- `type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-types')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
- [this.stringFormatTypes.resource]:
- `ids=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-ids')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
- [this.stringFormatTypes.pinnedId]:
- `ids=<${this.intl.t('resources.role.edit-grants.string-formats.insert-id')}>;type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-types')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
+ [this.stringFormatTypes.resourceType]: {
+ text: `type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-types')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
+ link: 'role.grant-string-format.resource-type',
+ },
+ [this.stringFormatTypes.resource]: {
+ text: `ids=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-ids')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
+ link: 'role.grant-string-format.resource',
+ },
+ [this.stringFormatTypes.pinnedId]: {
+ text: `ids=<${this.intl.t('resources.role.edit-grants.string-formats.insert-id')}>;type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-types')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
+ link: 'role.grant-string-format.pinned-id',
+ },
+ [this.stringFormatTypes.outputFields]: {
+ text: `output_fields=<${this.intl.t('resources.role.edit-grants.string-formats.insert-output-fields')}>`,
+ link: 'role.grant-string-format.output-fields',
+ },
+ [this.stringFormatTypes.accountTemplate]: {
+ text: 'ids={{.Account.Id}}',
+ link: 'role.grant-string-format.account-template',
+ },
+ [this.stringFormatTypes.userTemplate]: {
+ text: 'ids={{.User.Id}}',
+ link: 'role.grant-string-format.user-template',
+ },
};
@tracked selectedFormatType = this.stringFormatTypes.resourceType;
@@ -38,4 +62,11 @@ export default class GrantStringFormatsIndex extends Component {
get stringFormat() {
return this.stringFormats[this.selectedFormatType];
}
+
+ // =actions
+
+ @action
+ changeSelectedFormatType(type) {
+ this.selectedFormatType = type;
+ }
}
diff --git a/ui/admin/config/environment.js b/ui/admin/config/environment.js
index 80691ea63..640aeb024 100644
--- a/ui/admin/config/environment.js
+++ b/ui/admin/config/environment.js
@@ -97,8 +97,18 @@ module.exports = function (environment) {
'role.add-principals':
'/tutorials/oss-administration/oss-manage-roles#create-a-role',
'role.add-grant-scopes': '/docs/commands/roles/add-grant-scopes',
+ 'role.grant-string-format.resource-type':
+ '/docs/rbac/permission-grant-formats#type-only',
+ 'role.grant-string-format.resource':
+ '/docs/rbac/permission-grant-formats#id-only',
'role.grant-string-format.pinned-id':
'/docs/rbac/permission-grant-formats#pinned-id',
+ 'role.grant-string-format.output-fields':
+ '/docs/rbac/assignable-permissions#output-fields',
+ 'role.grant-string-format.account-template':
+ '/docs/rbac/permission-grant-formats#account-id',
+ 'role.grant-string-format.user-template':
+ '/docs/rbac/permission-grant-formats#user-id',
session: '/docs/concepts/domain-model/sessions',
target: '/docs/concepts/domain-model/targets',
'target.new': '/docs/common-workflows/manage-targets',
diff --git a/ui/admin/tests/integration/components/grant-string-formats/index-test.js b/ui/admin/tests/integration/components/grant-string-formats/index-test.js
index 0c2f31ec1..9561196aa 100644
--- a/ui/admin/tests/integration/components/grant-string-formats/index-test.js
+++ b/ui/admin/tests/integration/components/grant-string-formats/index-test.js
@@ -15,48 +15,85 @@ module(
setupRenderingTest(hooks);
setupIntl(hooks, 'en-us');
- const RESOURCE_TYPE_OPTION = '[value="resource-type"]';
- const RESOURCE_OPTION = '[value="resource"]';
- const PINNED_ID_OPTION = '[value="pinned-id"]';
+ const STRING_FORMATS_SELECT = '[name="string-formats"]';
+ const RESOURCE_TYPE_OPTION = '[data-option-index="0"]';
+ const RESOURCE_OPTION = '[data-option-index="1"]';
+ const PINNED_ID_OPTION = '[data-option-index="2"]';
+ const OUTPUT_FIELDS_OPTION = '[data-option-index="3"]';
+ const ACCOUNT_TEMPLATE_OPTION = '[data-option-index="4"]';
+ const USER_TEMPLATE_OPTION = '[data-option-index="5"]';
const STRING_FORMAT_FIELD = '[name="string-format"]';
+ const MORE_INFO_LINK = '.hds-link-standalone';
- test('it renders string format with resource type by default', async function (assert) {
- await render(hbs``);
+ const options = {
+ resourceType: RESOURCE_TYPE_OPTION,
+ resource: RESOURCE_OPTION,
+ pinnedId: PINNED_ID_OPTION,
+ outputFields: OUTPUT_FIELDS_OPTION,
+ accountTemplate: ACCOUNT_TEMPLATE_OPTION,
+ userTemplate: USER_TEMPLATE_OPTION,
+ };
- assert.dom(RESOURCE_TYPE_OPTION).isChecked();
- assert.dom(RESOURCE_OPTION).isNotChecked();
- assert.dom(PINNED_ID_OPTION).isNotChecked();
- assert
- .dom(STRING_FORMAT_FIELD)
- .hasValue('type=;actions=');
- });
+ test.each(
+ 'it renders the expected string format for each option',
+ [
+ {
+ selectedOption: 'resourceType',
+ expectedValue:
+ 'type=;actions=',
+ },
+ {
+ optionToClick: RESOURCE_OPTION,
+ selectedOption: 'resource',
+ expectedValue: 'ids=;actions=',
+ },
+ {
+ optionToClick: PINNED_ID_OPTION,
+ selectedOption: 'pinnedId',
+ expectedValue:
+ 'ids=;type=;actions=',
+ },
+ {
+ optionToClick: OUTPUT_FIELDS_OPTION,
+ selectedOption: 'outputFields',
+ expectedValue: 'output_fields=',
+ },
+ {
+ optionToClick: ACCOUNT_TEMPLATE_OPTION,
+ selectedOption: 'accountTemplate',
+ expectedValue: 'ids={{.Account.Id}}',
+ },
+ {
+ optionToClick: USER_TEMPLATE_OPTION,
+ selectedOption: 'userTemplate',
+ expectedValue: 'ids={{.User.Id}}',
+ },
+ ],
+ async function (
+ assert,
+ { optionToClick, selectedOption, expectedValue },
+ ) {
+ await render(hbs``);
- test('it renders string format when type is changed to specific resource', async function (assert) {
- await render(hbs``);
+ await click(STRING_FORMATS_SELECT);
- await click(RESOURCE_OPTION);
+ if (optionToClick) {
+ await click(optionToClick);
+ await click(STRING_FORMATS_SELECT);
+ }
- assert.dom(RESOURCE_OPTION).isChecked();
- assert.dom(RESOURCE_TYPE_OPTION).isNotChecked();
- assert.dom(PINNED_ID_OPTION).isNotChecked();
- assert
- .dom(STRING_FORMAT_FIELD)
- .hasValue('ids=;actions=');
- });
+ for (const [optionName, selector] of Object.entries(options)) {
+ assert
+ .dom(selector)
+ .hasAria(
+ 'selected',
+ optionName === selectedOption ? 'true' : 'false',
+ );
+ }
- test('it renders string format when type is changed to pinned id', async function (assert) {
- await render(hbs``);
-
- await click(PINNED_ID_OPTION);
-
- assert.dom(PINNED_ID_OPTION).isChecked();
- assert.dom(RESOURCE_TYPE_OPTION).isNotChecked();
- assert.dom(RESOURCE_OPTION).isNotChecked();
- assert
- .dom(STRING_FORMAT_FIELD)
- .hasValue(
- 'ids=;type=;actions=',
- );
- });
+ assert.dom(STRING_FORMAT_FIELD).hasValue(expectedValue);
+ assert.dom(MORE_INFO_LINK).isVisible();
+ },
+ );
},
);