mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
add warning modal if last ws message is a warning
This commit is contained in:
parent
65f21c659a
commit
47d71a6022
4 changed files with 72 additions and 6 deletions
|
@ -145,11 +145,15 @@ export default {
|
||||||
'END_REQUEST' ({ commit }, { request, success, wait }) {
|
'END_REQUEST' ({ commit }, { request, success, wait }) {
|
||||||
let status = success ? 'success' : 'error'
|
let status = success ? 'success' : 'error'
|
||||||
if (success && (request.warnings || request.errors)) {
|
if (success && (request.warnings || request.errors)) {
|
||||||
|
const messages = request.messages
|
||||||
|
if (messages.length && messages[messages.length - 1].color === 'warning') {
|
||||||
|
request.showWarningMessage = true
|
||||||
|
}
|
||||||
status = 'warning'
|
status = 'warning'
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('UPDATE_REQUEST', { request, key: 'status', value: status })
|
commit('UPDATE_REQUEST', { request, key: 'status', value: status })
|
||||||
if (wait) {
|
if (wait && !request.showWarningMessage) {
|
||||||
// Remove the overlay after a short delay to allow an error to display withtout flickering.
|
// Remove the overlay after a short delay to allow an error to display withtout flickering.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
commit('SET_WAITING', false)
|
commit('SET_WAITING', false)
|
||||||
|
@ -214,6 +218,11 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commit('SET_ERROR', null)
|
commit('SET_ERROR', null)
|
||||||
|
},
|
||||||
|
|
||||||
|
'DISMISS_WARNING' ({ commit, state }, request) {
|
||||||
|
commit('SET_WAITING', false)
|
||||||
|
delete request.showWarningMessage
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
<query-header :request="error || currentRequest" status-size="lg" />
|
<query-header :request="error || currentRequest" status-size="lg" />
|
||||||
</b-card-header>
|
</b-card-header>
|
||||||
|
|
||||||
<component v-if="error" :is="'ErrorDisplay'" :request="error" />
|
<component :is="component.name" :request="component.request" />
|
||||||
<component v-else :is="'WaitingDisplay'" :request="currentRequest" />
|
|
||||||
</b-card>
|
</b-card>
|
||||||
</template>
|
</template>
|
||||||
</b-overlay>
|
</b-overlay>
|
||||||
|
@ -21,7 +20,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { ErrorDisplay, WaitingDisplay } from '@/views/_partials'
|
import { ErrorDisplay, WarningDisplay, WaitingDisplay } from '@/views/_partials'
|
||||||
import QueryHeader from '@/components/QueryHeader'
|
import QueryHeader from '@/components/QueryHeader'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -29,16 +28,30 @@ export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ErrorDisplay,
|
ErrorDisplay,
|
||||||
|
WarningDisplay,
|
||||||
WaitingDisplay,
|
WaitingDisplay,
|
||||||
QueryHeader
|
QueryHeader
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: mapGetters(['waiting', 'error', 'currentRequest'])
|
computed: {
|
||||||
|
...mapGetters(['waiting', 'error', 'currentRequest']),
|
||||||
|
|
||||||
|
component () {
|
||||||
|
const { error, currentRequest: request } = this
|
||||||
|
if (error) {
|
||||||
|
return { name: 'ErrorDisplay', request: error }
|
||||||
|
} else if (request.showWarningMessage) {
|
||||||
|
return { name: 'WarningDisplay', request }
|
||||||
|
} else {
|
||||||
|
return { name: 'WaitingDisplay', request }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// Style for `ErrorDisplay` and `WaitingDisplay`'s cards
|
// Style for `*Display`'s cards
|
||||||
.card-overlay {
|
.card-overlay {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 10vh;
|
top: 10vh;
|
||||||
|
|
43
app/src/views/_partials/WarningDisplay.vue
Normal file
43
app/src/views/_partials/WarningDisplay.vue
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<template>
|
||||||
|
<!-- This card receives style from `ViewLockOverlay` if used inside it -->
|
||||||
|
<div>
|
||||||
|
<b-card-body body-class="alert alert-warning" v-html="warning.text" />
|
||||||
|
|
||||||
|
<b-card-footer footer-bg-variant="warning">
|
||||||
|
<b-button
|
||||||
|
variant="light" size="sm"
|
||||||
|
v-t="'ok'" @click="dismiss"
|
||||||
|
/>
|
||||||
|
</b-card-footer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'WarningDisplay',
|
||||||
|
|
||||||
|
props: {
|
||||||
|
request: { type: Object, required: true }
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
warning () {
|
||||||
|
const messages = this.request.messages
|
||||||
|
return messages[messages.length - 1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
dismiss () {
|
||||||
|
this.$store.dispatch('DISMISS_WARNING', this.request)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.card-body {
|
||||||
|
padding-bottom: 1.5rem !important;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,4 +1,5 @@
|
||||||
export { default as ErrorDisplay } from './ErrorDisplay'
|
export { default as ErrorDisplay } from './ErrorDisplay'
|
||||||
|
export { default as WarningDisplay } from './WarningDisplay'
|
||||||
export { default as WaitingDisplay } from './WaitingDisplay'
|
export { default as WaitingDisplay } from './WaitingDisplay'
|
||||||
|
|
||||||
export { default as HistoryConsole } from './HistoryConsole'
|
export { default as HistoryConsole } from './HistoryConsole'
|
||||||
|
|
Loading…
Add table
Reference in a new issue