fix: 🐛 actions not displaying for templates in grants editor (#3296)
* fix: 🐛 actions not displaying for templates in grants editor * fix: 🐛 invalid ids check * fix: 🐛 update check for ids type * test: 💍 fix broken strings * test: 💍 fix test case * test: 💍 remove log
This commit is contained in:
1 parent
4a206c82dc
commit
ecefa39b98
5 files changed
+76
-75
No files matched your search
@@ -28,7 +28,7 @@ export default class GrantStringFormatsIndex extends Component {
|
||||
|
||||
stringFormats = {
|
||||
[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')}>`,
|
||||
text: `type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-type')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
|
||||
link: 'role.grant-string-format.resource-type',
|
||||
},
|
||||
[this.stringFormatTypes.resource]: {
|
||||
@@ -36,7 +36,7 @@ export default class GrantStringFormatsIndex extends Component {
|
||||
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')}>`,
|
||||
text: `ids=<${this.intl.t('resources.role.edit-grants.string-formats.insert-ids')}>;type=<${this.intl.t('resources.role.edit-grants.string-formats.insert-resource-type')}>;actions=<${this.intl.t('resources.role.edit-grants.string-formats.insert-actions')}>`,
|
||||
link: 'role.grant-string-format.pinned-id',
|
||||
},
|
||||
[this.stringFormatTypes.outputFields]: {
|
||||
|
||||
@@ -101,18 +101,12 @@ export const analyzeGrantString = (grantsSchema, grantString = '') => {
|
||||
const hasSpecificIds = Boolean(idsValue) && !idsValue.includes('*');
|
||||
const hasExplicitType = Boolean(typeValue) && typeValue !== '*';
|
||||
|
||||
const hasTemplateIds =
|
||||
hasSpecificIds &&
|
||||
parseIds(idsValue).some((id) => id.startsWith('{{') && id.endsWith('}}'));
|
||||
|
||||
const hasLiteralIds = hasSpecificIds && !hasTemplateIds;
|
||||
|
||||
const compatibleIdsResourceType = hasLiteralIds
|
||||
const compatibleIdsResourceType = hasSpecificIds
|
||||
? getCompatibleResourceTypeForIds(schema, idsValue)
|
||||
: null;
|
||||
|
||||
const hasInvalidType = hasExplicitType && !schema.resourcesByType[typeValue];
|
||||
const hasInvalidIds = hasLiteralIds && !compatibleIdsResourceType;
|
||||
const hasInvalidIds = hasSpecificIds && !compatibleIdsResourceType;
|
||||
|
||||
const hasInvalidPinnedIdTypeCombination =
|
||||
hasSpecificIds &&
|
||||
|
||||
Reference in new issue
Block a user