Skip to content

Commit fce01ac

Browse files
authored
Merge pull request #77 from Jont828/severity-undefined
Fix bug in condition chips when status is and severity is undefined
2 parents 41c4f2e + ba25617 commit fce01ac

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

web/src/components/CustomResourceDefinition.vue

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<v-tooltip
7474
:top="scrollY <= 20"
7575
:bottom="scrollY > 20"
76-
:disabled="condition.status"
76+
:disabled="condition.status === 'True'"
7777
>
7878
<template v-slot:activator="{ on, attrs }">
7979
<v-chip
@@ -89,18 +89,20 @@
8989
v-bind="attrs"
9090
v-on="on"
9191
>
92-
<!-- :color="($vuetify.theme.dark) ? getType(condition) : 'white'"
93-
:text-color="($vuetify.theme.dark) ? 'black' : getType(condition)" -->
9492
<StatusIcon
95-
:type="(condition.status) ? 'success' : condition.severity.toLowerCase()"
93+
:type="condition.status === 'True' ? 'success' : (condition.Status === 'Unknown' ? 'unknown' : (condition.severity ? condition.severity.toLowerCase() : 'unknown' ))"
9694
:spinnerWidth="2"
9795
left
9896
>
97+
<!-- TODO: verify that StatusIcon works when passing in undefined as type, i.e. if condition.severity is undefined -->
9998
</StatusIcon>
10099
{{ condition.type }}
101100
</v-chip>
102101
</template>
103-
<span>{{ condition.severity }}: {{ condition.reason }}</span>
102+
<span v-if="condition.severity && condition.reason">{{ condition.severity }}: {{ condition.reason }}</span>
103+
<span v-else-if="condition.severity">{{ condition.severity }}</span>
104+
<span v-else-if="condition.reason">{{ condition.reason }}</span>
105+
<span v-else>Unknown</span>
104106
</v-tooltip>
105107
</div>
106108
</div>
@@ -201,11 +203,9 @@ export default {
201203
},
202204
methods: {
203205
getType(condition) {
204-
return condition.status
205-
? "success"
206-
: condition.isError
207-
? "error"
208-
: "warning";
206+
if (condition.status === "True") return "success";
207+
else if (condition.isError || !condition.severity || condition.status === "Unknown") return "error"; // if severity is undefined, we assume it's an error
208+
else return "warning";
209209
},
210210
onScroll(e) {
211211
this.scrollY = window.scrollY;
@@ -230,7 +230,7 @@ export default {
230230
conditions.forEach((e, i) => {
231231
this.conditions.push({
232232
type: e.type,
233-
status: e.status === "True",
233+
status: e.status,
234234
isError: e.severity === "Error",
235235
severity: e.severity,
236236
reason: e.reason,
@@ -258,6 +258,7 @@ export default {
258258
watch: {
259259
jsonItems: {
260260
handler(val, old) {
261+
console.log("Val is", val);
261262
this.setConditions(val?.status?.conditions);
262263
},
263264
},

web/src/components/StatusIcon.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
:color="$vuetify.theme.dark ? 'black' : 'white'"
4141
:size="size-2"
4242
> mdi-information-variant</v-icon>
43+
<v-icon
44+
v-else-if="type==='unknown' || !type"
45+
class="readyIcon"
46+
:color="$vuetify.theme.dark ? 'black' : 'white'"
47+
:size="size-2"
48+
> mdi-help</v-icon>
4349
</v-avatar>
4450
<v-avatar
4551
:size="size"
@@ -84,6 +90,12 @@
8490
:color="getColor(type)"
8591
:size="size"
8692
> mdi-information</v-icon>
93+
<v-icon
94+
v-else-if="type==='unknown' || !type"
95+
class="readyIcon"
96+
:color="getColor(type)"
97+
:size="size"
98+
> mdi-help-circle</v-icon>
8799
</v-avatar>
88100
</template>
89101

@@ -100,7 +112,9 @@ export default {
100112
default: 1.5,
101113
type: Number,
102114
},
103-
circle: Boolean,
115+
circle: Boolean,
116+
// If circle is true, the icon will be displayed in a circle with the color in the background. This is meant for the top right corner of a CRD.
117+
// If circle is false, the icon will be displayed in a square with the color as the border. This is meant for the condition chips in the CRD views.
104118
spinner: Boolean,
105119
left: Boolean,
106120
},
@@ -113,6 +127,8 @@ export default {
113127
getColor(type) {
114128
if (!this.circle) return "";
115129
130+
if (type === "unknown") return "error";
131+
116132
if (this.spinner && (type === "warning" || type === "info"))
117133
return "warning";
118134

0 commit comments

Comments
 (0)