Skip to content

Commit 03ab518

Browse files
committed
replace alert box with a snackbar
changed test for non-existance for on of non-visibility remove toggleFunction, plumber setAlert(null) if alert closed
1 parent c5480f0 commit 03ab518

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

src/components/core/Alert.vue

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
-->
1717

1818
<template>
19-
<div v-if="alert">
20-
<v-alert
21-
:value="true"
22-
:type="alert.color"
23-
:icon="alert.icon"
24-
:class="getColor(alert.color)"
25-
dismissible
26-
tile
27-
light
28-
colored-border
29-
>
30-
<template v-slot:close="props">
31-
<v-icon @click="closeAlert(props.toggle)">{{ svgPaths.close }}</v-icon>
32-
</template>
33-
{{ alert.text }}
34-
</v-alert>
35-
</div>
19+
<v-snackbar
20+
v-if="alert"
21+
v-model="snackbar"
22+
:color="getColor(alert.color)"
23+
:top="true"
24+
timeout="-1"
25+
:icon="alert.icon"
26+
>
27+
28+
<template v-slot:action="{ attrs }">
29+
<v-btn
30+
color="black"
31+
text
32+
v-bind="attrs"
33+
@click="closeAlert"
34+
>
35+
<v-icon>{{ svgPaths.close }}</v-icon>
36+
</v-btn>
37+
</template>
38+
{{ alert.text }}
39+
</v-snackbar>
3640
</template>
3741

3842
<script>
@@ -52,7 +56,8 @@ export default {
5256
]),
5357
svgPaths: {
5458
close: mdiClose
55-
}
59+
},
60+
snackbar: alert
5661
}
5762
},
5863
@@ -71,9 +76,9 @@ export default {
7176
* @param {Function} toggleFunction - the original Vuetify toggle function
7277
* @see https://vuetifyjs.com/en/api/v-alert/
7378
*/
74-
closeAlert (toggleFunction) {
79+
closeAlert () {
80+
this.snackbar = false
7581
this.setAlert(null)
76-
toggleFunction()
7782
}
7883
}
7984
}

tests/e2e/specs/alert.cy.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ describe('Alert component', () => {
3131
store.dispatch('setAlert', new Alert(errorMessage, null, 'error'))
3232
})
3333
cy
34-
.get('.v-alert')
34+
.get('.v-snack')
3535
.should('contain', errorMessage)
3636
})
3737
it('Uses the right color for success', () => {
3838
cy.visit('/#/')
3939
cy.get('.c-header').should('exist')
4040
getStore().then(store => {
4141
cy.wrap(store).invoke('commit', 'SET_ALERT', new Alert('An alert', null, 'success'))
42-
cy.get('.v-alert').then($alertElements => {
42+
cy.get('.v-snack').then($alertElements => {
4343
const backgroundColor = window.getComputedStyle($alertElements[0])['background-color']
4444
expect(backgroundColor).to.not.equal(COLOR_BLACK)
4545
expect(backgroundColor).to.not.equal(COLOR_WHITE)
@@ -52,7 +52,7 @@ describe('Alert component', () => {
5252
cy.get('.c-header').should('exist')
5353
getStore().then(store => {
5454
cy.wrap(store).invoke('commit', 'SET_ALERT', new Alert('An alert', null, 'warning'))
55-
cy.get('.v-alert').then($alertElements => {
55+
cy.get('.v-snack').then($alertElements => {
5656
const backgroundColor = window.getComputedStyle($alertElements[0])['background-color']
5757
expect(backgroundColor).to.not.equal(COLOR_BLACK)
5858
expect(backgroundColor).to.not.equal(COLOR_WHITE)
@@ -65,7 +65,7 @@ describe('Alert component', () => {
6565
cy.get('.c-header').should('exist')
6666
getStore().then(store => {
6767
cy.wrap(store).invoke('commit', 'SET_ALERT', new Alert('An alert', null, 'error'))
68-
cy.get('.v-alert').then($alertElements => {
68+
cy.get('.v-snack').then($alertElements => {
6969
const backgroundColor = window.getComputedStyle($alertElements[0])['background-color']
7070
expect(backgroundColor).to.not.equal(COLOR_BLACK)
7171
expect(backgroundColor).to.not.equal(COLOR_WHITE)
@@ -81,14 +81,14 @@ describe('Alert component', () => {
8181
store.dispatch('setAlert', new Alert(errorMessage, null, 'error'))
8282
})
8383
cy
84-
.get('.v-alert')
84+
.get('.v-snack')
8585
.should('contain', errorMessage)
8686
cy
87-
.get('.v-alert')
87+
.get('.v-snack')
8888
.get('button')
8989
.click({ force: true, multiple: true })
9090
cy
91-
.get('.v-alert')
91+
.get('.v-snack--active')
9292
.should('not.exist')
9393
getStore().then(store => {
9494
expect(store.state.alert).to.equal(null)

tests/e2e/specs/layout.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe('Default layout', () => {
2020
// visit any page first, so that we create the window.app reference
2121
cy.visit('/#/workspace/one')
2222
cy
23-
.get('.v-alert')
24-
.should('not.exist')
23+
.get('.v-snack__wrapper')
24+
.should('not.visible')
2525
cy.window().its('app.$workflowService').then(service => {
2626
// mock service so that it returns an error
2727
cy.stub(service, 'subscribe', () => {
@@ -33,7 +33,7 @@ describe('Default layout', () => {
3333
.contains('Dashboard')
3434
.click({ force: true })
3535
cy
36-
.get('.v-alert')
36+
.get('.v-snack__wrapper')
3737
.should('be.visible')
3838
})
3939
})

0 commit comments

Comments
 (0)