-
Notifications
You must be signed in to change notification settings - Fork 27
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
Attempt 2 collapsing gscan #1175
Conversation
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.
Thanks @AaronDCole.
I'm not terribly keen on the HTML line break removals which are also making it hard to work out exactly what this PR has changed. It would be easier to consider code style changes in a separate issue/PR (see also #1172), we may also consider using prettier (or similar) with Vue support for HTML/SCSS formatting.
The auto-collapsing works well for the examples 👍, although for some strange reason, when I tried it with a workflow named generic/run1
it didn't work and the workflow icon broke?
I also spotted an issue with the workflow names when these nodes are expanded (more in later comment):
The "Tree Component" src/components/cylc/tree/Tree
is used by both the "GScan Component" and the "Tree View" (src/views/Tree
) which has the unfortunate side effect that this auto-collapsing also impacts the tree view which is undesirable. For now we can use a simple toggle switch to turn this off (more in later comment).
src/components/cylc/gscan/GScan.vue
Outdated
ref="tree" | ||
> | ||
<div v-if="!isLoading" class="c-gscan-workflows flex-grow-1"> | ||
<tree :filterable="false" :expand-collapse-toggle="false" :workflows="workflows" :stopOn="['workflow']" :autoExpandTypes="['workflow-part', 'workflow']" class="c-gscan-workflow ma-0 pa-0" ref="tree"> |
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 don't collapse code down to one long line like this, it's bad for reading/editing and makes it hard to understand the diff. I don't think anything here has actually changed?
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.
Sorry you're totally right, I didn't actually intend to include that and I will fix/revert that in the next commit.
watch: { | ||
node: { | ||
deep: true, | ||
handler: function () { | ||
this.$nextTick(() => { | ||
// apply auto-expand rules when a tree-item is updated, take into account singleChildDescendants preference | ||
// this needs to happen until the user manually overrides the automatic opening and closing | ||
if (!this.firstInteraction) { | ||
this.isExpanded = this.hasBranchingLineage && this.autoExpandTypes.includes(this.node.type) | ||
// this.isExpanded = this.autoExpandTypes.includes(this.node.type) | ||
this.emitExpandCollapseEvent(this.isExpanded) | ||
} | ||
}) | ||
} | ||
} | ||
}, |
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.
This will be invoked every time anything in node
(or any of its children) changes which will be very compute intensive.
I think this can be handled with a computed
property:
// untested
computed: {
autoExpand () {
// only called when one of its dependencies changes
if (!this.firstInteraction) {
return null
}
return this.hasBranchingLineage && this.autoExpandTypes.includes(this.node.type)
}
},
watch: {
autoExpand (expand) {
// only called when autoExpand changes
if (expand !== null) {
this.emitExpandCollapseEvent(expand)
}
}
}
Note that we don't (initially) want this behaviour in the "Tree view" (src/Tree
) which also shares this recursive tree component. Although one day we may want to auto-collapse tasks with only one job in a similar manner.
For now it's probably good enough to target this behaviour at the workflow-part
type, the recursive tree component needs straightening out so we can refactor this branch away later. E.G:
// untested
computed: {
autoExpand () {
// only called when one of its dependencies changes
if (!this.firstInteraction) {
return null
}
if (node.type === 'workflow-part') {
return this.hasBranchingLineage && this.autoExpandTypes.includes(this.node.type)
}
return this.autoExpandTypes.includes(this.node.type)
}
},
src/components/cylc/gscan/GScan.vue
Outdated
:to="workflowLink(scope.node)" | ||
> | ||
|
||
<workflow-icon class="mr-2" v-if="scope.node.type === 'workflow' || !checkForBranchingLineage(scope.node)" :status="getLastDescendent(scope.node).node.status || 'waiting'" v-cylc-object="getLastDescendent(scope.node)" /> |
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.
checkForBranchingLineage
and getLastDescendent
seem to be used multiple times which means there will be duplicate computation. It would be worth using computed properties to cache these values to avoid unnecessary computation.
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.
'The auto-collapsing works well for the examples 👍, although for some strange reason, when I tried it with a workflow named generic/run1 it didn't work and the workflow icon broke?'
I actually worked out why this was happening after I left the office last night, I will fix it today
src/components/cylc/gscan/GScan.vue
Outdated
<span>{{ scope.node.name || scope.node.id }}</span> | ||
|
||
<v-flex v-if="scope.node.type === 'workflow-part'" class="c-gscan-workflow-name"> | ||
<span>{{ checkForBranchingLineage(scope.node) ? scope.node.name || scope.node.id : createDescendentLabel(scope.node) }}</span> |
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 think this test might need to use this.isExpanded
so that the name collapsing is only performed when the node is collapsed.
<span>{{ (this.isExpanded && checkForBranchingLineage(scope.node)) ? scope.node.name || scope.node.id : createDescendentLabel(scope.node) }}</span>
E.G. the collapsed state should look like this:
b/b1/b11
The expanded state should look as it did before:
b/
b1/
b11/
Rather than:
b/b1/b1
b1/b11
b11/
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.
Good point!
This feature can be tested in a component test but at the moment the code structure doesn't allow this (because we would have to mock all the GraphQL/VueX data stuff). I've split the GraphQL/VueX stuff out of the GScan component into a GScan view to allow the component to be tested standalone. Feel free to cherry-pick this commit, it contains a blank component test with the https://github.com/cylc/cylc-ui/compare/master...oliver-sanders:cylc-ui:gscan-component?expand=1 There are a couple of simple component tests to look at but we haven't started using them widely yet. You should be able to |
Thanks Oliver, I am refactoring a lot of the commit (to, for example, be able to pass through computed properties from the TreeItem component to use where the slot overrides are defined in the gScan component), so I will look into this when that is finished. |
b4b4e4b
to
65b4a3f
Compare
There is an issue where when you switch to the tree view, it seems to change the format of the node object which breaks a lot of stuff within the gscan component. I will investigate tomorrow. |
4e3d0f5
to
7419694
Compare
…tus's to non expanded branching trees
7419694
to
3bef538
Compare
Taking a look today ... |
@AaronDCole - the placement of job icons looks good now as I collapse and expand the tree, but I've noticed a couple of problems. I tested it side-by side with master, by moving the $ cylc gui --CylcUIServer.ui_build_dir="/home/oliverh/cylc/cylc-ui/dist-gscan"
$ cylc gui --new --CylcUIServer.ui_build_dir="/home/oliverh/cylc/cylc-ui/dist-master" Then I started 4 copies of this workflow: [scheduling]
cycling mode = integer
runahead limit = P2
[[graph]]
P1 = "a => b1 & b2 & b3 "
[runtime]
[[a, b1, b2, b3]]
script = sleep $((10 + RANDOM % 5)) ... at different levels of run-dir nesting, like this: $ cylc vip # bgg/run1
$ cylc vip # bgg/run2
$ cylc vip --workflow-name=top/mid/one # top/mid/one/run1
$ cylc vip --workflow-name=top/mid/two # top/mid/two/run1 The two problems are:
To get the state totals right you could put some really long sleep values in some tasks, so that the totals stay stable for a long time. And use (And of course, at the higher levels - as you collapse tree nodes - the state totals should be a sum of the individual workflows below). |
…assed state totals through for totals calculation instead of relying on latest task states
Tests pass 🎉 I'm going to build and test later this afternoon... |
This is looking good. I'll try to find time to leave some review comments this afternoon, and to prompt others on the team to review it. (Bearing in mind the Vue3 changes in master now). |
superseded by #1406 |
Attempt number 3 at the auto collapse workflows, this may not work flawlessly yet but would be good to get some review on based on the feedback from Oliver on the previous pull request (#1037).
This is a ground up rewrite of the original feature request, based on the latest changes on developer (including the most recent changes from Oliver), with (hopefully) a lot of code quality improvements and general readability updates (since I found the structure of the g-scan element incredible hard to follow / change in a recursive fashion (as suggested in Olivers comments on the previous MR, listed above).
Tests will be broken, but an initial review would be helpful (even if just a sighting pass), then Ill make final adjustments and then fix the tests.
Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.