Skip to content

Commit 2e3f2bf

Browse files
committed
Clicking "Log" in mutation menu works for GScan sidebar
1 parent 937fc58 commit 2e3f2bf

File tree

4 files changed

+68
-42
lines changed

4 files changed

+68
-42
lines changed

changes.d/1758.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clicking "Log" in the command menu now works correctly for workflows in the sidebar.

src/components/cylc/cylcObject/Menu.vue

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
7777
<v-btn
7878
icon
7979
variant="text"
80-
:disabled="isEditable(authorised, mutation)"
80+
:disabled="!isEditable(mutation, authorised)"
8181
@click.stop="openDialog(mutation)"
8282
data-cy="mutation-edit"
8383
class="ml-2"
@@ -167,7 +167,6 @@ export default {
167167
dialogKey: false,
168168
expanded: false,
169169
node: null,
170-
workflowStatus: null,
171170
mutations: [],
172171
isLoadingMutations: true,
173172
showMenu: false,
@@ -246,45 +245,23 @@ export default {
246245
},
247246
248247
methods: {
249-
isEditable (authorised, mutation) {
250-
if (mutation.name === 'log' || this.isDisabled(mutation, authorised)) {
251-
return true
252-
} else {
253-
return false
254-
}
248+
isEditable (mutation, authorised) {
249+
return mutation.name !== 'log' && !this.isDisabled(mutation, authorised)
255250
},
256251
isDisabled (mutation, authorised) {
257-
if (this.node.type !== 'workflow') {
258-
const nodeReturned = this.getNodes(
259-
'workflow', [this.node.tokens.workflowID])
260-
if (nodeReturned.length) {
261-
this.workflowStatus = nodeReturned[0].node.status
262-
} else { this.workflowStatus = WorkflowState.RUNNING.name }
263-
} else {
264-
this.workflowStatus = this.node.node.status
265-
}
266-
if (
267-
(!mutation._validStates.includes(this.workflowStatus)) ||
268-
!authorised) {
252+
if (!authorised) {
269253
return true
270254
}
271-
return false
255+
let status = this.node.node?.status
256+
if (this.node.type !== 'workflow') {
257+
const nodeReturned = this.getNodes('workflow', [this.node.tokens.workflowID])
258+
status = nodeReturned.length
259+
? nodeReturned[0].node.status
260+
: WorkflowState.RUNNING.name
261+
}
262+
return !mutation._validStates.includes(status)
272263
},
273264
openDialog (mutation) {
274-
if (mutation.name === 'log') {
275-
this.$eventBus.emit(
276-
'add-view',
277-
{
278-
name: 'Log',
279-
initialOptions: {
280-
relativeID: this.node.tokens.relativeID || null
281-
}
282-
}
283-
)
284-
this.showMenu = false
285-
return
286-
}
287-
288265
this.dialog = true
289266
this.dialogMutation = mutation
290267
// Tell Vue to re-render the dialog component:
@@ -344,14 +321,36 @@ export default {
344321
345322
/* Call a mutation using only the tokens for args. */
346323
callMutationFromContext (mutation) {
324+
this.showMenu = false
347325
// eslint-disable-next-line no-console
348326
console.debug(`mutation: ${mutation._title} ${this.node.id}`)
349-
mutate(
350-
mutation,
351-
getMutationArgsFromTokens(mutation, this.node.tokens),
352-
this.$workflowService.apolloClient
353-
)
354-
this.showMenu = false
327+
328+
if (mutation.name === 'log') {
329+
// Navigate to the corresponding workflow then open the log view
330+
// (no nav occurs if already on the correct workflow page)
331+
this.$router.push({
332+
name: 'workspace',
333+
params: {
334+
workflowName: this.node.tokens.workflow
335+
}
336+
}).then(() => {
337+
this.$eventBus.emit(
338+
'add-view',
339+
{
340+
name: 'Log',
341+
initialOptions: {
342+
relativeID: this.node.tokens.relativeID || null
343+
}
344+
}
345+
)
346+
})
347+
} else {
348+
mutate(
349+
mutation,
350+
getMutationArgsFromTokens(mutation, this.node.tokens),
351+
this.$workflowService.apolloClient
352+
)
353+
}
355354
},
356355
357356
showMutationsMenu ({ node, event }) {

src/utils/aotf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export const dummyMutations = [
305305
description: 'View the logs.',
306306
args: [],
307307
_appliesTo: [cylcObjects.Workflow, cylcObjects.Namespace, cylcObjects.Job],
308-
_requiresInfo: true
308+
_requiresInfo: false
309309
},
310310
]
311311

tests/e2e/specs/log.cy.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,30 @@ describe('Log view in workspace', () => {
206206
.invoke('val')
207207
.should('eq', jobFile)
208208
})
209+
210+
it('navigates to correct workflow when choosing log option in mutation menu', () => {
211+
const one = 'one'
212+
const multi = 'multi/level/run1'
213+
cy.visit('/#')
214+
.get('.c-gscan .node').contains(one)
215+
.parents('.node').find('[data-c-interactive]')
216+
.click()
217+
.get('.c-mutation').contains('Log')
218+
.click()
219+
cy.url()
220+
.should('contain', `/workspace/${encodeURIComponent(one)}`)
221+
.get('.c-log [data-cy=workflow-id-input] input').as('idInput')
222+
.invoke('val')
223+
.should('eq', `~user/${one}`)
224+
cy.get('.c-gscan .node').contains(multi)
225+
.parents('.node').find('[data-c-interactive]')
226+
.click()
227+
.get('.c-mutation').contains('Log')
228+
.click()
229+
cy.url()
230+
.should('contain', `/workspace/${encodeURIComponent(multi)}`)
231+
.get('@idInput')
232+
.invoke('val')
233+
.should('eq', `~user/${multi}`)
234+
})
209235
})

0 commit comments

Comments
 (0)