-
Notifications
You must be signed in to change notification settings - Fork 5
[FEATURE]: add clone icon button to the dashboard variable #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (v.kind === 'TextVariable') { | ||
| draft.push({ | ||
| ...v, | ||
| spec: { ...v.spec, value: v.spec.value, name: `${v.spec.name}_copy` }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| spec: { ...v.spec, value: v.spec.value, name: `${v.spec.name}_copy` }, | |
| spec: { ...v.spec, name: `${v.spec.name}_copy` }, |
I think this is redundant, as ...v.spec already copies all properties of v.spec, including value. Then we don't need the if. Or am i missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same idea, but TS throws an exception :(
Property 'value' is missing in type '{ defaultValue?: VariableValue; allowMultiple: boolean; allowAllValue: boolean; customAllValue?: string; capturingRegexp?: string; sort?: string; plugin: Definition<...>; name: VariableName; display?: VariableDisplay; }' but required in type 'WritableDraft'.ts(2345)
variables.d.ts(17, 5): 'value' is declared here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange, ok.
Another potential issue: The current code does a shallow clone, for example v.spec.display on the clone will reference to the display property of the original variable.
I'm not sure if this is an issue when using immer. Could you test to clone a variable, and click hide on the original variable (which sets spec.display.hidden) and make sure the cloned variable is not hidden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we could remove the if condition, but TS is not happy, except if we force with as 😒 Maybe we should enforce with as in this case and remove a if.
| > | ||
| <ArrowDown /> | ||
| </IconButton> | ||
| <IconButton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this new button after the Edit one (next one), as people are more likely to edit variables rather than duplicating them.
As a side note: there may be a broader UX topic to address here but out of scope of this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com>
4b9fc4f to
199b23f
Compare

Closes perses/perses#3771
Description 🖊️
This feature lets users clone dashboard variables. I am not sure if it makes sense to have it for the external variables, so this is only for the internal ones.
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: