Skip to content

Commit 1aa4c34

Browse files
committed
Add setting for log view word wrap default
1 parent d8541aa commit 1aa4c34

File tree

8 files changed

+49
-18
lines changed

8 files changed

+49
-18
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+
Added setting for log view word wrap default.

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/composables/localStorage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ export const useCyclePointsOrderDesc = () => useLocalStorage('cyclePointsOrderDe
3030
export const useJobTheme = () => useLocalStorage('jobTheme', 'default')
3131

3232
export const useReducedAnimation = () => useLocalStorage('reducedAnimation', false)
33+
34+
export const useLogWordWrapDefault = () => useLocalStorage('logWordWrap', false)

src/views/Log.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ import ViewToolbar from '@/components/cylc/ViewToolbar.vue'
205205
import DeltasCallback from '@/services/callbacks'
206206
import { debounce } from 'lodash-es'
207207
import CopyBtn from '@/components/core/CopyBtn.vue'
208+
import { useLogWordWrapDefault } from '@/composables/localStorage'
208209
209210
/**
210211
* Query used to retrieve data for the Log view.
@@ -356,7 +357,7 @@ export default {
356357
const timestamps = useInitialOptions('timestamps', { props, emit }, true)
357358
358359
/** Wrap lines? */
359-
const wordWrap = useInitialOptions('wordWrap', { props, emit }, false)
360+
const wordWrap = useInitialOptions('wordWrap', { props, emit }, useLogWordWrapDefault().value)
360361
361362
/** The log subscription results */
362363
const results = ref(new Results())

src/views/UserProfile.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
210210
</template>
211211
</v-select>
212212
</v-row>
213+
214+
<v-row no-gutters class="align-center wrap">
215+
<v-col cols="3">
216+
<span>Log view word wrap</span>
217+
</v-col>
218+
<v-checkbox
219+
v-model="logWordWrap"
220+
data-cy="log-wrap"
221+
/>
222+
</v-row>
213223
</v-container>
214224
</v-defaults-provider>
215225
</v-form>
@@ -221,7 +231,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
221231
<script>
222232
import { mapState } from 'vuex'
223233
import { mdiCog, mdiFormatFontSizeDecrease, mdiFormatFontSizeIncrease } from '@mdi/js'
224-
import { useCyclePointsOrderDesc, useJobTheme, useReducedAnimation } from '@/composables/localStorage'
234+
import { useCyclePointsOrderDesc, useJobTheme, useLogWordWrapDefault, useReducedAnimation } from '@/composables/localStorage'
225235
import { decreaseFontSize, getCurrentFontSize, increaseFontSize, resetFontSize } from '@/utils/font-size'
226236
import { allViews, useDefaultView } from '@/views/views.js'
227237
import Job from '@/components/cylc/Job.vue'
@@ -243,6 +253,7 @@ export default {
243253
cyclePointsOrderDesc: useCyclePointsOrderDesc(),
244254
jobTheme: useJobTheme(),
245255
reducedAnimation: useReducedAnimation(),
256+
logWordWrap: useLogWordWrapDefault(),
246257
upperFirst,
247258
}
248259
},

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/userprofile.cy.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ describe('User Profile', () => {
3030
const defaultFontSize = 16 // px
3131
beforeEach(() => {
3232
cy.visit('/#/user-profile')
33-
cy.title().should('eq', 'Cylc UI | User Profile')
3433
})
3534

3635
it('Visits the user profile', () => {
36+
cy.title().should('eq', 'Cylc UI | User Profile')
3737
cy.get('input#profile-username')
3838
.should('be.visible')
3939
.should('be.disabled')
@@ -158,4 +158,21 @@ describe('User Profile', () => {
158158
.click()
159159
checkCyclePointOrder(['1', '2'])
160160
})
161+
162+
it('Sets log view word wrap default setting', () => {
163+
const checkLogWrap = (expected) => {
164+
cy.visit('/#/log/one')
165+
.get('[data-cy=control-wordWrap] button')
166+
.should('have.attr', 'aria-checked', String(expected))
167+
}
168+
169+
cy.get('[data-cy=log-wrap] input').as('checkbox')
170+
.should('not.be.checked')
171+
checkLogWrap(false)
172+
cy.visit('/#/user-profile')
173+
.get('@checkbox')
174+
.click()
175+
.should('be.checked')
176+
checkLogWrap(true)
177+
})
161178
})

0 commit comments

Comments
 (0)