Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions frontend/__tests__/components/GStatusTag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ describe('components', () => {
const wrapper = mountStatusTag({
shortName: 'foo',
name: 'foo-bar',
status: 'True',
status: 'Healthy',
})
authnStore.user.isAdmin = true
const vm = wrapper.vm
expect(vm.chipText).toBe('foo')
expect(vm.chipStatus).toBe('Healthy')
expect(vm.chipTooltip.title).toBe('foo-bar')
expect(vm.chipIcon).toBe('')
expect(vm.isError || vm.isUnknown || vm.isProgressing).toBe(false)
expect(vm.isError || vm.isUnknown || vm.isProgressing || vm.isDegraded).toBe(false)
expect(vm.color).toBe('primary')
expect(vm.visible).toBe(true)
})
Expand All @@ -64,22 +64,22 @@ describe('components', () => {
const wrapper = mountStatusTag({
shortName: 'foo',
name: 'foo-bar',
status: 'True',
status: 'Healthy',
codes: [
'ERR_CONFIGURATION_PROBLEM',
],
})
const vm = wrapper.vm
expect(vm.chipText).toBe('foo')
expect(vm.chipStatus).toBe('Error')
expect(vm.chipStatus).toBe('Healthy')
expect(vm.isError).toBe(true)
expect(vm.isUserError).toBe(true)
expect(vm.chipIcon).toBe('mdi-account-alert-outline')
expect(vm.color).toBe('error')
expect(vm.visible).toBe(true)
})

it('should render condition for a user without admin role', () => {
it('should render progressing condition', () => {
const wrapper = mountStatusTag({
shortName: 'foo',
name: 'foo-bar',
Expand All @@ -91,22 +91,37 @@ describe('components', () => {
expect(vm.isProgressing).toBe(true)
expect(vm.color).toBe('primary')
expect(vm.chipStatus).toBe('Progressing')
expect(vm.chipIcon).toBe('mdi-progress-clock')
})

it('should render condition for a user without admin role', () => {
const wrapper = mountStatusTag({
shortName: 'foo',
name: 'foo-bar',
status: 'Degraded',
showAdminOnly: true,
})
const vm = wrapper.vm
expect(vm.visible).toBe(false)
expect(vm.isDegraded).toBe(true)
expect(vm.color).toBe('primary')
expect(vm.chipStatus).toBe('Degraded')
expect(vm.chipIcon).toBe('')
})

it('should render condition for a user with admin role', () => {
const wrapper = mountStatusTag({
shortName: 'foo',
name: 'foo-bar',
status: 'Progressing',
status: 'Degraded',
showAdminOnly: true,
})
authnStore.user.isAdmin = true
const vm = wrapper.vm
expect(vm.visible).toBe(true)
expect(vm.isProgressing).toBe(true)
expect(vm.isDegraded).toBe(true)
expect(vm.color).toBe('info')
expect(vm.chipStatus).toBe('Progressing')
expect(vm.chipStatus).toBe('Degraded')
expect(vm.chipIcon).toBe('mdi-progress-alert')
})
})
Expand Down
9 changes: 9 additions & 0 deletions frontend/__tests__/components/GStatusTags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('components', () => {
return {
type,
lastTransitionTime,
status: 'True',
}
}),
},
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('components', () => {
shortName: 'SC',
name: 'Sample Condition',
sortOrder: '000000SC',
status: 'True',
})
})

Expand All @@ -98,6 +100,7 @@ describe('components', () => {
shortName: 'ELSTC',
name: 'Extra Long Sample TEST Condition',
sortOrder: '000ELSTC',
status: 'True',
})
})

Expand All @@ -111,6 +114,7 @@ describe('components', () => {
shortName: 'S',
name: 'Singlecondition',
sortOrder: '0000000S',
status: 'True',
})
})

Expand All @@ -124,6 +128,9 @@ describe('components', () => {
shortName: 'API',
name: 'API Server',
sortOrder: '00000000',
statusMappings: expect.any(Object),
statusTextMappings: expect.any(Object),
status: 'True',
description: expect.stringContaining('kube-apiserver'),
})
})
Expand All @@ -138,6 +145,7 @@ describe('components', () => {
shortName: 'CC',
name: 'Config Condition',
sortOrder: '00000000',
status: 'True',
description: 'Config Condition Description',
})
})
Expand All @@ -152,6 +160,7 @@ describe('components', () => {
shortName: 'CPO',
name: 'Control Plane Overwritten',
sortOrder: '00000011',
status: 'True',
description: 'Overwritten Description',
})
})
Expand Down
44 changes: 17 additions & 27 deletions frontend/src/components/GStatusTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SPDX-License-Identifier: Apache-2.0
</v-chip>
</template>
<g-shoot-message-details
:status-title="chipStatus"
:status-title="chipStatusText"
:last-message="nonErrorMessage"
:error-descriptions="errorDescriptions"
:last-transition-time="condition.lastTransitionTime"
Expand Down Expand Up @@ -143,22 +143,15 @@ export default {
return this.condition.shortName || ''
},
chipStatus () {
if (this.isError) {
return 'Error'
}
if (this.isUnknown) {
return 'Unknown'
}
if (this.isProgressing) {
return 'Progressing'
}

return 'Healthy'
return get(this.condition.statusMappings, this.condition.status, this.condition.status)
},
chipStatusText () {
return get(this.condition.statusTextMappings, this.chipStatus, this.chipStatus)
},
chipTooltip () {
return {
title: this.condition.name,
status: this.chipStatus,
status: this.chipStatusText,
description: this.condition.description,
userErrorCodeObjects: filter(objectsFromErrorCodes(this.condition.codes), { userError: true }),
}
Expand All @@ -173,29 +166,26 @@ export default {
if (this.isUnknown) {
return 'mdi-help-circle-outline'
}
if (this.isProgressing && this.isAdmin) {
if (this.isDegraded && this.isAdmin) {
return 'mdi-progress-alert'
}
if (this.isProgressing) {
return 'mdi-progress-clock'
}

return ''
},
isError () {
if (this.condition.status === 'False' || !isEmpty(this.condition.codes)) {
return true
}
return false
return this.chipStatus === 'False' || !isEmpty(this.condition.codes)
},
isUnknown () {
if (this.condition.status === 'Unknown') {
return true
}
return false
return this.chipStatus === 'Unknown'
},
isDegraded () {
return this.chipStatus === 'Degraded'
},
isProgressing () {
if (this.condition.status === 'Progressing') {
return true
}
return false
return this.chipStatus === 'Progressing'
},
isUserError () {
return isUserError(this.condition.codes)
Expand Down Expand Up @@ -227,7 +217,7 @@ export default {
if (this.isError) {
return 'error'
}
if (this.isProgressing && this.isAdmin) {
if (this.isDegraded && this.isAdmin) {
return 'info'
}
return 'primary'
Expand Down
50 changes: 38 additions & 12 deletions frontend/src/components/GStatusTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,50 @@ const {
shootCloudProviderBinding,
shootMetadata,
shootUid,
shootReadiness,
shootConditions,
shootConstraints,
} = useShootItem()

const configStore = useConfigStore()
const shootStore = useShootStore()

/**
* Merge an item (condition or constraint) with its default config,
* apply status-mapping and padded sortOrder.
*/
function mergeItem (item) {
const defaults = configStore.conditionForType(item.type) ?? {}

return {
...item,
...defaults,
sortOrder: padStart(defaults.sortOrder ?? '', 8, '0'),
}
}

const conditions = computed(() => {
const conditions = shootReadiness.value
.filter(condition => !!condition.lastTransitionTime)
.map(condition => {
const conditionDefaults = configStore.conditionForType(condition.type)
return {
...conditionDefaults,
...condition,
sortOrder: padStart(conditionDefaults.sortOrder, 8, '0'),
}
})
return sortBy(conditions, 'sortOrder')
const merged = []

// helper to avoid repeating the same checks
const pushIfValid = (item, mustNotBeTrue) => {
item = mergeItem(item)
if (!item.lastTransitionTime) {
return
}
if (mustNotBeTrue && item.status === 'True') {
return
}
merged.push(item)
}

for (const c of shootConditions.value) {
pushIfValid(c, false)
}
for (const c of shootConstraints.value) {
pushIfValid(c, true)
}

return sortBy(merged, 'sortOrder')
})

const errorCodeObjects = computed(() => {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/composables/useShootItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export function createShootItemComposable (shootItem, options = {}) {
shootConditions,
shootConstraints,
shootCredentialsRotation,
shootReadiness,
shootObservedGeneration,
shootTechnicalId,
lastMaintenance,
Expand Down Expand Up @@ -241,7 +240,6 @@ export function createShootItemComposable (shootItem, options = {}) {
shootConditions,
shootConstraints,
shootCredentialsRotation,
shootReadiness,
shootObservedGeneration,
shootTechnicalId,
lastMaintenance,
Expand Down
12 changes: 0 additions & 12 deletions frontend/src/composables/useShootStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {

import get from 'lodash/get'
import find from 'lodash/find'
import filter from 'lodash/filter'

export const useShootStatus = shootItem => {
const shootStatus = computed(() => {
Expand Down Expand Up @@ -62,16 +61,6 @@ export const useShootStatus = shootItem => {
return get(shootItem.value, ['status', 'credentials', 'rotation'], {})
})

const shootReadiness = computed(() => {
const shootConstraintsNotInCondition = filter(shootConstraints.value, condition => {
return condition.status !== 'True'
})
return [
...shootConditions.value,
...shootConstraintsNotInCondition,
]
})

const shootObservedGeneration = computed(() => {
return get(shootItem.value, ['status', 'observedGeneration'])
})
Expand Down Expand Up @@ -140,7 +129,6 @@ export const useShootStatus = shootItem => {
shootConditions,
shootConstraints,
shootCredentialsRotation,
shootReadiness,
shootObservedGeneration,
shootTechnicalId,
lastMaintenance,
Expand Down
Loading
Loading