Skip to content

Commit 164d36c

Browse files
authored
Feature/notification bar (#86)
* moved widgets to components folder. Added onNotification event to trigger notification bar from any subview. * added notification event for terminating a workflow. Removed old error handling logic. * fixing lint * adding success banner after terminating workflow * eslint fixes * adding in error notification to replace old error handling logic in workflow history screen. * adding retry logic into history page. * allowing getErrorMessage to recieve default to be overridden * 3.9.0
1 parent ed0e26d commit 164d36c

21 files changed

+255
-36
lines changed

client/App.vue

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
<script>
22
import { version } from '../package.json';
33
import logo from './assets/logo.svg';
4+
import NotificationBar from './components/notification-bar.vue';
5+
import { NOTIFICATION_TIMEOUT, NOTIFICATION_TYPE_SUCCESS } from './constants';
46
57
export default {
8+
components: {
9+
NotificationBar,
10+
},
611
data() {
712
return {
813
logo,
14+
notification: {
15+
message: '',
16+
show: false,
17+
type: '',
18+
timeout: undefined,
19+
},
920
};
1021
},
22+
beforeDestroy() {
23+
clearTimeout(this.notification.timeout);
24+
},
1125
methods: {
1226
globalClick(e) {
1327
if (this.editing && !this.$refs.domain.contains(e.target)) {
@@ -29,6 +43,26 @@ export default {
2943
}
3044
}
3145
},
46+
onNotification({ message, type = NOTIFICATION_TYPE_SUCCESS }) {
47+
this.notification.message = message;
48+
this.notification.type = type;
49+
this.notification.show = true;
50+
},
51+
onNotificationClose() {
52+
this.notification.show = false;
53+
},
54+
},
55+
watch: {
56+
'notification.show'(value) {
57+
clearTimeout(this.notification.timeout);
58+
59+
if (value) {
60+
this.notification.timeout = setTimeout(
61+
this.onNotificationClose,
62+
NOTIFICATION_TIMEOUT
63+
);
64+
}
65+
},
3266
},
3367
computed: {
3468
version() {
@@ -40,6 +74,12 @@ export default {
4074

4175
<template>
4276
<main @click="globalClick">
77+
<NotificationBar
78+
:message="notification.message"
79+
:onClose="onNotificationClose"
80+
:show="notification.show"
81+
:type="notification.type"
82+
/>
4383
<header class="top-bar">
4484
<a href="/" class="logo">
4585
<div v-html="logo"></div>
@@ -74,7 +114,7 @@ export default {
74114
<span>{{ $route.params.taskList }}</span>
75115
</div>
76116
</header>
77-
<router-view></router-view>
117+
<router-view @onNotification="onNotification"></router-view>
78118
<modals-container />
79119
<v-dialog />
80120
</main>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<template>
2+
<transition name="fade">
3+
<div class="notification-bar" :class="type" v-if="show">
4+
<div class="message">
5+
{{ message }}
6+
</div>
7+
<span class="close icon icon_delete" @click="onClose" />
8+
</div>
9+
</transition>
10+
</template>
11+
12+
<script>
13+
export default {
14+
name: 'notification-bar',
15+
props: [
16+
'message',
17+
'onClose',
18+
'show',
19+
'type', // 'error', 'success', 'warning'
20+
],
21+
};
22+
</script>
23+
24+
<style scoped lang="stylus">
25+
UberGreen = #3AA76D;
26+
UberRed = #D44333;
27+
UberOrange = #ED6E33;
28+
DefaultColor = UberGreen;
29+
30+
.close {
31+
cursor: pointer;
32+
line-height: 60px;
33+
padding: 0 13px;
34+
position: absolute;
35+
right: 6px;
36+
top: 0;
37+
}
38+
39+
.notification-bar {
40+
background-color: DefaultColor;
41+
color: #fff;
42+
font-size: 18px;
43+
height: 60px;
44+
left: 0;
45+
line-height: 60px;
46+
overflow: hidden;
47+
padding: 0 50px 0 24px;
48+
position: absolute;
49+
right: 0;
50+
top: 0;
51+
z-index: 1;
52+
}
53+
54+
.error {
55+
background-color: UberRed;
56+
}
57+
58+
.fade-enter-active, .fade-leave-active {
59+
transition: opacity 0.25s;
60+
}
61+
62+
.fade-enter, .fade-leave-to {
63+
opacity: 0;
64+
}
65+
66+
.message {
67+
white-space: nowrap;
68+
overflow: hidden;
69+
text-overflow: ellipsis;
70+
}
71+
72+
.success {
73+
background-color: UberGreen;
74+
}
75+
76+
.warning {
77+
background-color: UberOrange;
78+
}
79+
</style>

client/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ export const preKeys = jsonKeys.concat(['stackTrace', 'details.stackTrace']);
44
export const MAXIMUM_JSON_CHARACTER_LIMIT = 5000;
55
export const MAXIMUM_JSON_MESSAGE =
66
'\n ... to see more open full screen mode from top right arrow.';
7+
8+
export const NOTIFICATION_TYPE_ERROR = 'error';
9+
export const NOTIFICATION_TYPE_ERROR_MESSAGE_DEFAULT =
10+
'An unexpected error has occurred. Please try again. If problems persist contact cadence-support.';
11+
export const NOTIFICATION_TYPE_SUCCESS = 'success';
12+
export const NOTIFICATION_TYPE_WARNING = 'warning';
13+
export const NOTIFICATION_TIMEOUT = 5000;

0 commit comments

Comments
 (0)