* chore: 🤖 Add initial page layout for code editor + sidebar (#3180) * chore: 🤖 Add initial page layout for code editor + sidebar * test: 💍 add missing a11y ignores for exisitng color issue ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18460 * Replace `Rose::CodeEditor` with `Hds::CodeEditor` (#2679) * chore: 🤖 replace Rose::CodeEditor with Hds::CodeEditor - Remove CodeEditor 5 dependency * chore: 🤖 Replace CodeMirror5 dep remove CodeMirror5 and replace existing editors with HDS::CodeEditor * chore: 🤖 deleting old codeeditor styles * feat: 🎸 changing code editor changing code editor ✅ Closes: 0 * removed unused export * pr cleanup * updating tests for new code editor * responding to PR feedback * added whitespace * fixing linting violations * chore: 🤖 self-review PR self-review PR in the course of switching to new HDS code editor * fix: 🐛 fix linting bug * fix: 🐛 unneeded dependency remove jslint dependency as this is handled in the new code editor from HDS * fix: 🐛 Fixing import bug Fix import bug caused by importing scss modules that no longer exist * Fix and refactor code editor acceptance test * Fix and refactor code editor acceptance test * chore: 🤖 remove codemirror dependency * refactor: 💡 fix merge conflict issues * test: 💍 update e2e test selectors * test: 💍 fix target spec click event * refactor: 💡 clean up test selectors for code editor * refactor: 💡 clean up storage bucket test selectors * chore: 🤖 remove code mirror modifiers --------- Co-authored-by: calcaide <ccorvo@hashicorp.com> Co-authored-by: cameronperera <cameron.perera@hashicorp.com> * feat: 🎸 Create string formats component (#3191) * feat: 🎸 Create string formats component * Add missing copyright headers * fix: 🐛 change to readonly ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18458 * feat: 🎸 add grant schema to mirage (#3196) * feat: 🎸 add grant schema to mirage * refactor: 💡 update grant schema mirage data * refactor: 💡 fix route name in mirage * feat: 🎸 add export options flyout (#3198) * feat: 🎸 add export options flyout * fix: 🐛 update id to be ids * test: 💍 add a11y ignores * test: 💍 fix tests for grant string format ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18524 * feat: 🎸 Add autocompletion to code editor (#3207) * feat: 🎸 Add CSP nonce to code editors (#3230) Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * feat: 🎸 Add linting to code editor (#3211) * feat: 🎸 Add linting to code editor * refactor: 💡 add missing case for wildcard type & ids field * refactor: 💡 simplify condition + add more tests * refactor: 💡 cleanup ids validation logic and add more lint erro * refactor: 💡 simplify logic and add actions linting cases * feat: 🎸 Add autocompletion to code editor (#3207) * refactor: 💡 apply PR feedback * refactor: 💡 PR feedback * refactor: 💡 add noop action * fix: 🐛 noop should not be suggested with resource type format ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18462 --------- Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * Icu 18506 load resource IDs for autocomplete (#3247) * feat: 🎸 Add id auto completion * style: 💄 Fix code editor styling for dark mode * feat: 🎸 Add optimization for caching sqlite data ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18506 * refactor: 💡 Update string formats to use select + add options (#3256) * refactor: 💡 Update string formats to use select + add options * refactor: 💡 PR feedback * test: 💍 fix tests ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18983 * refactor: 💡 role grants tab to use code block (#3261) * refactor: 💡 grants tab to use code block * refactor: 💡 update getter comment * test: 💍 fix tests * refactor: 💡 remove language arg for codeblock ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18757 * Grant actions card (#3246) * chore: 🤖 Add initial page layout for code editor + sidebar (#3180) * chore: 🤖 Add initial page layout for code editor + sidebar * test: 💍 add missing a11y ignores for exisitng color issue ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18460 * Replace `Rose::CodeEditor` with `Hds::CodeEditor` (#2679) * chore: 🤖 replace Rose::CodeEditor with Hds::CodeEditor - Remove CodeEditor 5 dependency * chore: 🤖 Replace CodeMirror5 dep remove CodeMirror5 and replace existing editors with HDS::CodeEditor * chore: 🤖 deleting old codeeditor styles * feat: 🎸 changing code editor changing code editor ✅ Closes: 0 * removed unused export * pr cleanup * updating tests for new code editor * responding to PR feedback * added whitespace * fixing linting violations * chore: 🤖 self-review PR self-review PR in the course of switching to new HDS code editor * fix: 🐛 fix linting bug * fix: 🐛 unneeded dependency remove jslint dependency as this is handled in the new code editor from HDS * fix: 🐛 Fixing import bug Fix import bug caused by importing scss modules that no longer exist * Fix and refactor code editor acceptance test * Fix and refactor code editor acceptance test * chore: 🤖 remove codemirror dependency * refactor: 💡 fix merge conflict issues * test: 💍 update e2e test selectors * test: 💍 fix target spec click event * refactor: 💡 clean up test selectors for code editor * refactor: 💡 clean up storage bucket test selectors * chore: 🤖 remove code mirror modifiers --------- Co-authored-by: calcaide <ccorvo@hashicorp.com> Co-authored-by: cameronperera <cameron.perera@hashicorp.com> * feat: 🎸 Create string formats component (#3191) * feat: 🎸 Create string formats component * Add missing copyright headers * fix: 🐛 change to readonly ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18458 * feat: 🎸 add grant schema to mirage (#3196) * feat: 🎸 add grant schema to mirage * refactor: 💡 update grant schema mirage data * refactor: 💡 fix route name in mirage * feat: 🎸 add export options flyout (#3198) * feat: 🎸 add export options flyout * fix: 🐛 update id to be ids * test: 💍 add a11y ignores * test: 💍 fix tests for grant string format ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18524 * feat: 🎸 Add autocompletion to code editor (#3207) * feat: 🎸 create grant actions component * feat: 🎸 add description to actions * feat: 🎸 update default logic to not show all actions * feat: 🎸 show invalid id and type message * test: 💍 create const for test selectors * feat: 🎸 trigger action suggestion when cursor moves * refactor: 💡 add createGrantLineHelpers func * refactor: 💡 small refactors * feat: 🎸 Add CSP nonce to code editors (#3230) Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * refactor: 💡 small refactor * test: 💍 add more tests * refactor: 💡 fix merge conflicts issues * refactor: 💡 updates from PR feedback * refactor: 💡 updates for completions and linting * test: 💍 fix test issue with translations * test: 💍 fix test issue that was already fixed once * refactor: 💡 address PR feedback --------- Co-authored-by: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Co-authored-by: Zack Moore <zack.moore@hashicorp.com> Co-authored-by: calcaide <ccorvo@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Bharath Gajjala <120367134+bgajjala8@users.noreply.github.com> * refactor: 💡 update pinned IDs logic for actions table * refactor: 💡 use if/else in place of complex ternary * refactor: 💡 user intl.formatList --------- Co-authored-by: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Co-authored-by: Zack Moore <zack.moore@hashicorp.com> Co-authored-by: calcaide <ccorvo@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Bharath Gajjala <120367134+bgajjala8@users.noreply.github.com>
77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { cached } from '@glimmer/tracking';
|
|
import { service } from '@ember/service';
|
|
|
|
import { analyzeGrantString } from 'admin/utils/grant-completions';
|
|
|
|
export default class GrantActionsIndex extends Component {
|
|
@service intl;
|
|
|
|
@cached
|
|
get grantAnalysis() {
|
|
return analyzeGrantString(
|
|
this.args.grantsSchema ?? {},
|
|
this.args.grantString,
|
|
);
|
|
}
|
|
|
|
get actionRows() {
|
|
return this.grantAnalysis.actions.map((action) => ({
|
|
name: action,
|
|
description: this.getActionDescription(action),
|
|
}));
|
|
}
|
|
|
|
get showNoResourceTypeDetected() {
|
|
const { actions, detectedResourceType } = this.grantAnalysis;
|
|
return (
|
|
!this.showInvalidIdAndType && !actions.length && !detectedResourceType
|
|
);
|
|
}
|
|
|
|
get showInvalidIdAndType() {
|
|
const {
|
|
actions,
|
|
hasInvalidType,
|
|
hasInvalidIds,
|
|
hasInvalidPinnedIdTypeCombination,
|
|
} = this.grantAnalysis;
|
|
return (
|
|
!actions.length &&
|
|
(hasInvalidType || hasInvalidIds || hasInvalidPinnedIdTypeCombination)
|
|
);
|
|
}
|
|
|
|
getActionDescription(action) {
|
|
const { detectedResourceType } = this.grantAnalysis;
|
|
const specificKey = `resources.role.edit-grants.actions.${action}`;
|
|
const genericKey = `resources.role.edit-grants.actions.generic.${action}`;
|
|
|
|
if (detectedResourceType && this.intl.exists(specificKey)) {
|
|
const resourceType = Array.isArray(detectedResourceType)
|
|
? this.intl.formatList(detectedResourceType, { type: 'disjunction' })
|
|
: detectedResourceType;
|
|
// Determine the appropriate article ("a" or "an") to use based on the
|
|
// detected resource type. "user" is a special case that uses "a" instead
|
|
// of "an" because it's pronounced "you" so I don't include it below.
|
|
const article = /^[aeio]/i.test(resourceType) ? 'an' : 'a';
|
|
return this.intl.t(specificKey, { resourceType, article });
|
|
}
|
|
|
|
if (this.intl.exists(genericKey)) {
|
|
return this.intl.t(genericKey);
|
|
}
|
|
|
|
if (this.intl.exists(specificKey)) {
|
|
return this.intl.t(specificKey);
|
|
}
|
|
|
|
return action;
|
|
}
|
|
}
|