Skip to content
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

Use workflow ID instead of workflow name in queries #433

Merged
merged 3 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -43,6 +43,7 @@ export default {
}),
computed: {
...mapState('workflows', ['workflows']),
...mapState('user', ['user']),
...mapGetters('workflows', ['workflowTree'])
},
created () {
Expand Down Expand Up @@ -104,9 +105,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