Grant actions card#3246
Conversation
* 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
* 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 * Add missing copyright headers * fix: 🐛 change to readonly ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18458
* feat: 🎸 add grant schema to mirage * refactor: 💡 update grant schema mirage data * refactor: 💡 fix route name in mirage
* 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
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
237f03c to
b5e39b1
Compare
ZedLi
left a comment
There was a problem hiding this comment.
Looks cool! Did an initial pass of some of the code
| if (update.selectionSet) { | ||
| const line = update.state.doc.lineAt(update.state.selection.main.head); | ||
| this.currentLineText = line.text; |
There was a problem hiding this comment.
Should we just have all updating happen here and remove the onInput?
| ); | ||
|
|
||
| @tracked grantStringsText = (this.args.model?.grant_strings ?? []).join('\n'); | ||
| @tracked currentLineText = this.args.model?.grant_strings?.[0] ?? ''; |
There was a problem hiding this comment.
Shouldn't we just default it to the first line when loading before there's any focus? Any reason we want to show nothing on first load?
There was a problem hiding this comment.
Should we be showing all actions on wildcard? We might want diverge from autocomplete to limit it to a different set in this case (maybe just default CRUDL like in figma?).
Also we should not make the card expand forever down and add scrolling if needed.
| return getActionOptions(schema, typeValue, idsValue); | ||
| }; | ||
|
|
||
| export const getDetectedResourceTypeForGrantLine = ( |
| const hasEnteredActions = enteredActions.length > 0; | ||
| const options = filterByPrefix( | ||
| getActionOptions(schema, typeValue, idsValue), | ||
| getSuggestedActionsForGrantLine(schema, line.text), |
There was a problem hiding this comment.
Why was this change necessary? We already parsed the grant line earlier and now it looks like we just re-parse the line again and then call getActionOptions again?
| return (context) => grantCompletions(context, schema, translatedStrings); | ||
| }; | ||
|
|
||
| export const createGrantLineHelpers = (grantsSchema) => { |
There was a problem hiding this comment.
Is this needed here? It seems like it's a thin wrapper around the other exported functions. It also looks like you have a normalized schema in your component but still normalize the schema here.
| }; | ||
| }; | ||
|
|
||
| const isNormalizedGrantsSchema = (grantsSchema) => |
There was a problem hiding this comment.
Why would we need this check?
| parseGrantLine, | ||
| } from 'admin/utils/grant-completions'; | ||
|
|
||
| const ACTIONS_WITH_RESOURCE_TYPE = new Set([ |
There was a problem hiding this comment.
What is the purpose of this? Why do we just reflect back the resource type?
| #grantLineHelpers = createGrantLineHelpers(this.args.grantsSchema ?? {}); | ||
|
|
||
| get parsedGrantLine() { | ||
| return parseGrantLine(this.args.grantString); |
There was a problem hiding this comment.
This will parse the grant line every time this getter is called which seems inefficient. It looks like this can get called a lot of times the way we've structured these getters (over 10 times by my count). I don't think it's a realistic performance issue since parsing should be relatively quick but if it ever changes we'll get caught by this. It might be worth adding the cached decorator here.
Though I'm curious if this indicates a more structural issue. We have a lot of getters (which I find a bit hard to read). I wonder if most of this logic should have actually been exported in an object out of a util function (whether it's autocomplete or linting) which at least lets a reader to see the different variables and logic at once instead of jumping all over.
Description
🎟️ Jira ticket
Screenshots (if appropriate)
Screen.Recording.2026-04-27.at.3.09.06.PM.mov
How to Test
Visit the edit grants route. You should now see suggested actions on the right of the code editor. The suggestions should work as before and the suggested actions should match the actions in the completion window. Only difference is the actions card will not remove actions as they are used like the completion list.
Checklist
a11y-testslabel to run a11y audit tests if neededPCI review checklist
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.