mutation editor: add open in new tab button#2394
Conversation
| // For now, Info view cannot be opened for a workflow, but this will be resolved by | ||
| // https://github.com/cylc/cylc-ui/issues/1898 | ||
| ['Info', { component: InfoView, icon: mdiInformationOutline }], | ||
| ['Command', { component: MutationView, icon: mdiInformationOutline }], |
There was a problem hiding this comment.
Note, "Command" is the user-facing term, "Mutation" comes from the GraphQL implementation. We should probably rename the "Mutation" component etc one day...
| }, | ||
| cylcObject: { | ||
| // data store node | ||
| initialOptions: { |
There was a problem hiding this comment.
Moved props into initialOptions to allow this component to be used as a view.
With this state will be restored as normal when the user navigates to another workflow then back.
| // Navigate to the corresponding workflow then open the log view | ||
| // (no nav occurs if already on the correct workflow page) | ||
| this.$router.push({ | ||
| name: 'Workspace', | ||
| params: { | ||
| workflowName: this.cylcObject.tokens.workflow | ||
| } | ||
| }).then(() => { |
There was a problem hiding this comment.
The same thing we do in Menu.vue for the benefit of the standalone views (otherwise the open in new tab button would do nothing in these contexts).
|
One test was failing in CI in 2/3 browsers (but not locally for me?) due to the mutation editor form remaining open (but not visible) after being closed. 2d7141c changes the logic to destroy the dialog when not in use which fixes this test. |
| // set the tab title to something informative | ||
| eventBus.emit( | ||
| `lumino:update-tab:${props.widgetID}`, | ||
| { title: `Command: ${props.initialOptions.mutation._title}` }, |
There was a problem hiding this comment.
Long term, we may be able to use the Jupyter Lab API for this (LabIcon) though it's react, so we may end up going our own way.
Short term, the only solution I can come up with is a unicode icon which would probably require a special icon font.
| content-class="c-mutation-dialog mx-0" | ||
| > | ||
| <Mutation | ||
| :mutation="dialogMutation" |
There was a problem hiding this comment.
This would be possible, but it would make the menus wider and more complicated.
wxtim
left a comment
There was a problem hiding this comment.
No blockers. Some UX suggestions.
MetRonnie
left a comment
There was a problem hiding this comment.
Seems to work well, however I have noticed and am looking into how this is now storing 300+ kB in cache storage as part of the initialOptions. This is mainly due to storing introspection query data.
Also, getting a warning when the form is mounted as a tab:
[Vue warn]: Extraneous non-props attributes (workflow-name, class) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.
at <VDefaultsProvider defaults= {global: {…}, VAutocomplete: {…}, VCombobox: {…}, VSelect: {…}, VTextarea: {…}, …} workflow-name="one" class="h-100" >
at <Mutation workflow-name="one" initial-options= {mutation: Proxy(Object), cylcObject: Proxy(Object), data: {…}, types: Proxy(Array), initialData: {…}, …} onUpdate:initialOptions=fn<onUpdate:initialOptions> ... >
at <AsyncComponentWrapper workflow-name="one" initial-options= {mutation: Proxy(Object), cylcObject: Proxy(Object), data: {…}, types: Proxy(Array), initialData: {…}, …} onUpdate:initialOptions=fn<onUpdate:initialOptions> ... >
at <Widget key="widget70" id="widget70" >
at <Lumino key="one" onEmptied=fn<bound onEmptied> workflow-name="one" ... >
at <Workspace workflowName="one" onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy(Object) {setAlert: ƒ, onEmptied: ƒ, …} > >
at <RouterView>
at <VMain>
at <Default showSidebar=true >
at <VApp class="job_theme--default" >
at <VDefaultsProvider defaults= {global: {…}} >
at <App>
|
|
||
| // and close this menu | ||
| this.close() | ||
| this.$emit('success') |
There was a problem hiding this comment.
We are closing both the menu and the overlay which are handled in two different ways.
Addressed in 4c19030, tldr, don't use |
TBH, I'm not too concerned by this personally:
If worried, we could:
|
* The `vDefaultsProvider` component has multiple "root" nodes which makes it unsuitable for use as a component's "root" node in some situations.
|
Unfortunately I have found that opening a command editor in a tab and then navigating away to a different workflow results in |
This seems to be a harmless error (layout restoration including form state still works fine) which is confusing. It seems that |
| data: { | ||
| type: Object, | ||
| required: false, | ||
| default: () => { return {} }, // for ease of testing | ||
| } |
There was a problem hiding this comment.
FYI: This is passing data as a prop, however, this object is modified from either end.
If you were to do this with an Boolean, Array or whatever, Vue would complain. However, when you pass an Object, it doesn't complain and seems to work fine.
But I'm not sure the absence of a warning means it's ok? The Object is constant and reactivity seems fine, however, the more Vue'ey way to work is using a model.
These components already implement a model (for form validity). It is possible for a component to implement multiple models (or just encapsulate validity into the data?), but I wasn't able to work out how to do this in time.
There was a problem hiding this comment.
When objects and arrays are passed as props, while the child component cannot mutate the prop binding, it will be able to mutate the object or array's nested properties. This is because in JavaScript objects and arrays are passed by reference, and it is unreasonably expensive for Vue to prevent such mutations.
The main drawback of such mutations is that it allows the child component to affect parent state in a way that isn't obvious to the parent component, potentially making it more difficult to reason about the data flow in the future. As a best practice, you should avoid such mutations unless the parent and child are tightly coupled by design. In most cases, the child should emit an event to let the parent perform the mutation.
https://vuejs.org/guide/components/props.html#mutating-object-array-props
It is probably ok for now in this PR
|
I haven't been able to replicate the problem from at 4c19030 either in dev mode or with a full build. I have now also tried with the latest version. |
I replicated the issue with a dev build:
FYI, the layout is saved when the editor is opened in a tab, I think it tries again on navigate, but there's some sort of lifecycle issue with how |
|
This is what I did - including the F12! I eventually got something similar: Which goes away with your fix. 😃 |
MetRonnie
left a comment
There was a problem hiding this comment.
Got a few suggestions at oliver-sanders#125
Mutation editor



Check List
CONTRIBUTING.mdand added my name as a Code Contributor.setup.cfg(andconda-environment.ymlif present).?.?.xbranch.