Skip to content

Commit

Permalink
Merge pull request #433 from kinow/use-workflow-id
Browse files Browse the repository at this point in the history
Use workflow ID instead of workflow name in queries
  • Loading branch information
hjoliver authored Mar 30, 2020
2 parents d8f52a8 + 99c46ab commit d26d0e9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/lang/en-GB/App.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Cylc UI",
"dashboard": "Dashboard",
"graph": "Graph",
"graph": "Graph {name}",
"workflow": "Workflow {name}",
"workflows": "Workflows",
"notFound": "Not Found",
Expand Down
8 changes: 7 additions & 1 deletion src/views/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Graph from '@/components/cylc/graph/Graph'
import { mixin } from '@/mixins'
import { WORKFLOW_GRAPH_QUERY } from '@/graphql/queries'
import { mapState } from 'vuex'
const QUERIES = {
root: WORKFLOW_GRAPH_QUERY
Expand Down Expand Up @@ -37,6 +38,10 @@ export default {
isLoading: true
}),
computed: {
...mapState('user', ['user'])
},
created () {
this.viewID = `Graph(${this.workflowName}): ${Math.random()}`
this.$workflowService.register(
Expand All @@ -54,9 +59,10 @@ export default {
methods: {
subscribe (queryName) {
const workflowId = `${this.user.username}|${this.workflowName}`
const id = this.$workflowService.subscribe(
this,
QUERIES[queryName].replace('WORKFLOW_ID', this.workflowName)
QUERIES[queryName].replace('WORKFLOW_ID', workflowId)
)
if (!(queryName in this.subscriptions)) {
this.subscriptions[queryName] = {
Expand Down
30 changes: 16 additions & 14 deletions src/views/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<script>
import { mixin } from '@/mixins/index'
import { mapGetters } from 'vuex'
import { mapGetters, mapState } from 'vuex'
import Tree from '@/components/cylc/tree/Tree'
import { WORKFLOW_TREE_QUERY } from '@/graphql/queries'
Expand Down Expand Up @@ -52,7 +52,8 @@ export default {
}),
computed: {
...mapGetters('workflows', ['workflowTree'])
...mapGetters('workflows', ['workflowTree']),
...mapState('user', ['user'])
},
created () {
Expand All @@ -71,36 +72,37 @@ export default {
},
methods: {
/**
* Subscribe this view to a new GraphQL query.
* @param {string} queryName - Must be in QUERIES.
*/
subscribe (queryName) {
/**
* Subscribe this view to a new GraphQL query.
* @param {string} queryName - Must be in QUERIES.
*/
if (!(queryName in this.subscriptions)) {
const workflowId = `${this.user.username}|${this.workflowName}`
this.subscriptions[queryName] =
this.$workflowService.subscribe(
this,
QUERIES[queryName].replace('WORKFLOW_ID', this.workflowName)
QUERIES[queryName].replace('WORKFLOW_ID', workflowId)
)
}
},
/**
* Unsubscribe this view to a new GraphQL query.
* @param {string} queryName - Must be in QUERIES.
*/
unsubscribe (queryName) {
/**
* Unsubscribe this view to a new GraphQL query.
* @param {string} queryName - Must be in QUERIES.
*/
if (queryName in this.subscriptions) {
this.$workflowService.unsubscribe(
this.subscriptions[queryName]
)
}
},
/** Toggle the isLoading state.
* @param {bool} isActive - Are this views subs active.
*/
setActive (isActive) {
/** Toggle the isLoading state.
* @param {bool} isActive - Are this views subs active.
*/
this.isLoading = !isActive
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/views/Workflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
}),
computed: {
...mapState('workflows', ['workflows']),
...mapState('user', ['user']),
...mapGetters('workflows', ['workflowTree'])
},
created () {
Expand Down Expand Up @@ -112,9 +113,10 @@ export default {
activeCallback: this.setActive
}
)
const workflowId = `${this.user.username}|${this.workflowName}`
const subscriptionId = this.$workflowService.subscribe(
view,
QUERIES[queryName].replace('WORKFLOW_ID', this.workflowName)
QUERIES[queryName].replace('WORKFLOW_ID', workflowId)
)
view.subscriptionId = subscriptionId
if (!(queryName in this.subscriptions)) {
Expand Down

0 comments on commit d26d0e9

Please sign in to comment.