Skip to content

Commit 4f58e66

Browse files
Merge pull request #2078 from MetRonnie/log-wrap
Save log view word wrap default
2 parents 8984ad7 + 0da1825 commit 4f58e66

File tree

11 files changed

+64
-26
lines changed

11 files changed

+64
-26
lines changed

changes.d/2078.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Log view word wrap setting is now saved.

changes.d/2078.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed log view word wrap not working in all cases.

src/components/cylc/ViewToolbar.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3131
:data-cy="`control-${iControl.key}`"
3232
>
3333
<v-btn
34+
@click="iControl.callback"
3435
v-bind="btnProps"
3536
:disabled="iControl.disabled"
36-
:color="iControl.color"
37-
@click="iControl.callback"
37+
:aria-checked="iControl.value"
38+
:color="iControl.value ? 'blue' : undefined"
39+
role="switch"
3840
>
3941
<v-icon>{{ iControl.icon }}</v-icon>
4042
<v-tooltip>{{ iControl.title }}</v-tooltip>
@@ -107,7 +109,6 @@ export default {
107109
const ret = []
108110
let iGroup
109111
let iControl
110-
let color // control color
111112
let callback // callback to fire when control is activated
112113
let disabled // true if control should not be enabled
113114
const values = this.getValues()
@@ -117,17 +118,13 @@ export default {
117118
iControls: []
118119
}
119120
for (const control of group.controls) {
120-
color = null
121121
callback = null
122122
disabled = false
123123
124-
// set callback and color
124+
// set callback
125125
switch (control.action) {
126126
case 'toggle':
127127
callback = (e) => this.toggle(control, e)
128-
if (control.value) {
129-
color = 'blue'
130-
}
131128
break
132129
case 'callback':
133130
callback = (e) => this.call(control, e)
@@ -150,7 +147,6 @@ export default {
150147
151148
iControl = {
152149
...control,
153-
color,
154150
callback,
155151
disabled
156152
}

src/components/cylc/log/Log.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
ref="scrollWrapper"
2121
class="h-100 overflow-auto px-4 pb-2"
2222
>
23-
<pre ref="logText" data-cy="log-text"><span
23+
<pre
24+
ref="logText"
25+
:class="wordWrap ? 'text-pre-wrap text-break' : 'text-pre'"
26+
data-cy="log-text"
27+
><span
2428
v-for="(log, index) in computedLogs"
2529
:key="index"
26-
:class="wordWrap ? 'text-pre-wrap' : 'text-pre'"
2730
>{{ log }}</span></pre>
2831
<v-btn
2932
v-if="logs.length"

src/composables/localStorage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ export const useJobTheme = () => useLocalStorage('jobTheme', 'default')
3232
export const useReducedAnimation = () => useLocalStorage('reducedAnimation', false)
3333

3434
export const useWorkflowWarnings = () => useLocalStorage('useWorkflowWarnings', true)
35+
36+
export const useLogWordWrapDefault = () => useLocalStorage('logWordWrap', false)

src/services/mock/json/logData.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const workflowLogLines = [
3434
'2023-05-25T10:48:01+01:00 INFO - + cycle point time zone = Z\n',
3535
'2023-08-17T14:10:51+01:00 INFO - The quick brown 🦊 jumps over the lazy 🐶\n',
3636
'2024-02-07T13:38:25+01:00 INFO - Ce programme est distribué dans l\'espoir qu\'il sera utile, mais SANS TOUTE GARANTIE ; sans même la garantie implicite de QUALITÉ MARCHANDE ou d\'ADAPTATION À UN USAGE PARTICULIER. Consultez la GNU General Public License pour plus de détails.\n',
37+
'2025-08-21T02:53:22+01:00 ERROR - cycl not found in /home/users/sheev.palpatine/.local/bin:/home/users/sheev.palpatine/bin:/opt/caribou-client-wrapper/bin:/opt/conda/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/bish/bash/bosh/bin:/data/apps/apes/2025/bin\n',
3738
'2038-01-19T04:14:07+01:00 CRITICAL - It\'s the Epochalypse!\n',
3839
]
3940

src/views/Log.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
170170
</template>
171171

172172
<script>
173-
import { ref, computed } from 'vue'
173+
import { ref, computed, watch } from 'vue'
174174
import { refWithControl, usePrevious, whenever } from '@vueuse/core'
175175
import { useStore } from 'vuex'
176176
import {
@@ -200,6 +200,7 @@ import { debounce } from 'lodash-es'
200200
import CopyBtn from '@/components/core/CopyBtn.vue'
201201
import { Alert } from '@/model/Alert.model'
202202
import { getJobLogFileFromState } from '@/model/JobState.model'
203+
import { useLogWordWrapDefault } from '@/composables/localStorage'
203204
204205
/**
205206
* Query used to retrieve data for the Log view.
@@ -362,8 +363,12 @@ export default {
362363
/** Toggle timestamps in log files */
363364
const timestamps = useInitialOptions('timestamps', { props, emit }, true)
364365
365-
/** Wrap lines? */
366-
const wordWrap = useInitialOptions('wordWrap', { props, emit }, false)
366+
/* Wrap lines? */
367+
const wordWrapDefault = useLogWordWrapDefault()
368+
const wordWrap = useInitialOptions('wordWrap', { props, emit }, wordWrapDefault.value)
369+
watch(wordWrap, (value) => {
370+
wordWrapDefault.value = value
371+
})
367372
368373
/** The log subscription results */
369374
const results = ref(new Results())

tests/component/specs/viewToolbar.cy.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ describe('View Toolbar Component', () => {
7777
// the toggle should be blue because it's active (default true)
7878
.get('[data-cy=control-toggle] .v-btn')
7979
.should('have.class', 'text-blue')
80+
.should('have.attr', 'aria-checked', 'true')
8081
// clicking the toggle should emit a "setOption" event with the
8182
// controls key (toggle) and new value (false)
8283
.click({ force: true })
@@ -87,7 +88,8 @@ describe('View Toolbar Component', () => {
8788
})
8889
// it should not be grey because it's inactive (false)
8990
.get('[data-cy=control-toggle] .v-btn')
90-
.not('.text-blue')
91+
.should('not.have.class', 'text-blue')
92+
.should('have.attr', 'aria-checked', 'false')
9193
// click it again and it should become active again
9294
.click({ force: true })
9395
.get('@wrapper').then(({ wrapper }) => {
@@ -97,6 +99,7 @@ describe('View Toolbar Component', () => {
9799
})
98100
.get('[data-cy=control-toggle] .v-btn')
99101
.should('have.class', 'text-blue')
102+
.should('have.attr', 'aria-checked', 'true')
100103

101104
// test action=callback
102105
expect(callbacks).to.have.length(0)

tests/e2e/specs/graph.cy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function checkRememberToolbarSettings (selector, stateBefore, stateAfter) {
4848
cy
4949
.get(selector)
5050
.find('.v-btn')
51-
.should(stateBefore, 'text-blue')
51+
.should('have.attr', 'aria-checked', String(stateBefore))
5252
.click()
5353
// Navigate away
5454
cy.visit('/#/')
@@ -59,7 +59,7 @@ function checkRememberToolbarSettings (selector, stateBefore, stateAfter) {
5959
cy
6060
.get(selector)
6161
.find('.v-btn')
62-
.should(stateAfter, 'text-blue')
62+
.should('have.attr', 'aria-checked', String(stateAfter))
6363
}
6464

6565
describe('Graph View', () => {
@@ -133,21 +133,21 @@ describe('Graph View', () => {
133133
cy.visit('/#/workspace/one')
134134
addView('Graph')
135135
waitForGraphLayout()
136-
checkRememberToolbarSettings('[data-cy=control-autoRefresh]', 'have.class', 'not.have.class')
136+
checkRememberToolbarSettings('[data-cy=control-autoRefresh]', true, false)
137137
})
138138

139139
it('remembers transpose setting when switching between workflows', () => {
140140
cy.visit('/#/workspace/one')
141141
addView('Graph')
142142
waitForGraphLayout()
143-
checkRememberToolbarSettings('[data-cy=control-transpose]', 'not.have.class', 'have.class')
143+
checkRememberToolbarSettings('[data-cy=control-transpose]', false, true)
144144
})
145145

146146
it('remembers cycle point grouping setting when switching between workflows', () => {
147147
cy.visit('/#/workspace/one')
148148
addView('Graph')
149149
waitForGraphLayout()
150-
checkRememberToolbarSettings('[data-cy="control-groupCycle"]', 'not.have.class', 'have.class')
150+
checkRememberToolbarSettings('[data-cy="control-groupCycle"]', false, true)
151151
})
152152

153153
describe('Flow nums', () => {

tests/e2e/specs/log.cy.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,19 @@ describe('Log command in menu', () => {
242242
})
243243

244244
describe('Log view in workspace', () => {
245+
function openWorkflowLog () {
246+
cy.get('#workflow-mutate-button')
247+
.click()
248+
.get('.c-mutation').contains('Log')
249+
.click()
250+
}
251+
245252
it('remembers job ID and file when switching between workflows', () => {
246253
const jobFile = /^job$/
247254
const jobID = '20000102T0000Z/succeeded'
248255
cy.visit('/#/workspace/one')
249-
.get('#workflow-mutate-button')
250-
.click()
251-
.get('.c-mutation').contains('Log')
252-
.click()
253-
.get('[data-cy=job-toggle]')
256+
openWorkflowLog()
257+
cy.get('[data-cy=job-toggle]')
254258
.click()
255259
.get('.c-log [data-cy=job-id-input] input').as('jobIDInput')
256260
.type(jobID)
@@ -276,6 +280,28 @@ describe('Log view in workspace', () => {
276280
.contains(jobFile)
277281
})
278282

283+
it('remembers word wrap setting and sets default word wrap', () => {
284+
cy.visit('/#/workspace/one')
285+
.get('.lm-TabBar-tabCloseIcon').click()
286+
openWorkflowLog()
287+
cy.get('.c-log [data-cy=control-wordWrap] button')
288+
.should('have.attr', 'aria-checked', 'false')
289+
// Open a new log view
290+
openWorkflowLog()
291+
cy.get('.c-log:last [data-cy=control-wordWrap] button')
292+
.click()
293+
.should('have.attr', 'aria-checked', 'true')
294+
// Should not affect the first log view
295+
cy.get('.lm-TabBar-tab:first').click()
296+
.get('.c-log:first [data-cy=control-wordWrap] button')
297+
.should('have.attr', 'aria-checked', 'false')
298+
// Should set the default word wrap for new log views
299+
cy.visit('/#/workspace/multi/level/run1')
300+
openWorkflowLog()
301+
cy.get('.c-log [data-cy=control-wordWrap] button')
302+
.should('have.attr', 'aria-checked', 'true')
303+
})
304+
279305
it('navigates to correct workflow when choosing log option in mutation menu', () => {
280306
const one = 'one'
281307
const multi = 'multi/level/run1'

0 commit comments

Comments
 (0)