-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable hints for machine image vendors #1066
Conversation
# Conflicts: # frontend/src/store/index.js # frontend/tests/unit/store.index.spec.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
{{- range .vendorNames }} | ||
- {{ . }} | ||
{{- end }} | ||
hintMessage: {{ .hintMessage }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be it makes to change it to {{ quote .hintMessage }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I already did this and added the support for markdown on the UI side as well
@@ -121,6 +121,17 @@ export default { | |||
} | |||
return join(hintText, ' / ') | |||
}, | |||
hintColor () { | |||
if (this.machineImage.expirationDate || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we create a class for this classification, version, hint, ... stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, would be a good idea. But not as part of this PR
Co-authored-by: Holger Koser <holger.koser@sap.com>
@@ -36,6 +36,9 @@ SPDX-License-Identifier: Apache-2.0 | |||
{{item.name}} [{{item.version}}] | |||
</span> | |||
</template> | |||
<template v-slot:message="{ message }"> | |||
<div v-html="message"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like this would be better
<template v-slot:message="{ message }">
<multi-message :message="message"/>
</template>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeSandbox example:
https://codesandbox.io/s/focused-cdn-qn1wl?file=/src/components/MultiMessage.vue
<template>
<div class="wrapper">
<template v-for="({ type, hint }, index) in hints">
<div v-if="type === 'html'" v-html="hint" :key="index" />
<div v-else v-text="hint" :key="index" />
</template>
</div>
</template>
<script>
export default {
props: {
message: {
type: String,
},
},
computed: {
hints() {
try {
const obj = JSON.parse(this.message);
return Array.isArray(obj) ? obj : [obj];
} catch (err) {
return [
{
type: "text",
hint: this.message,
},
];
}
},
},
};
</script>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -119,7 +122,18 @@ export default { | |||
if (this.machineImage.isPreview) { | |||
hintText.push('Preview versions have not yet undergone thorough testing. There is a higher probability of undiscovered issues and are therefore not recommended for production usage') | |||
} | |||
return join(hintText, ' / ') | |||
return join(hintText, '<br />') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid hand-craftet html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed as suggested
if (this.machineImage.needsLicense) { | ||
hintText.push('The OS image selected requires a license and a contract for full enterprise support. By continuing you are confirming that you have a valid license and you have signed an enterprise support contract.') | ||
if (this.machineImage.vendorHint) { | ||
hintText.push(transformHtml(this.machineImage.vendorHint.hintMessage)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hints.push({
type: 'html',
hint: transformHtml(this.machineImage.vendorHint.hintMessage)
})
or
hints.push({
type: 'text',
hint: `Image version expires on: ${this.machineImage.expirationDateString}. Image update will be enforced after that date.`
})
and
return JSON.stringify(hints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
frontend/src/store/index.js
Outdated
@@ -465,7 +464,7 @@ const getters = { | |||
expirationDate, | |||
vendorName, | |||
icon: vendorName, | |||
needsLicense | |||
vendorHint: findVendorHint(state.cfg.vendorHints, vendorName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vendorHint
only depends on the vendor name and should not be determined outside of the iteratee.
const vendorName = vendorNameFromImageName(machineImage.name)
const vendorHint = findVendorHint(state.cfg.vendorHints, vendorName)
return map(versions, ({ version, expirationDate, cri, classification }) => {
return decorateClassificationObject({
key: name + '/' + version,
name,
version,
cri,
classification,
expirationDate,
vendorName,
icon: vendorName,
vendorHint
})
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
{{- range .Values.frontendConfig.vendorHints }} | ||
- vendorNames: | ||
{{- range .vendorNames }} | ||
- {{ . }} | ||
{{- end }} | ||
hintMessage: {{ quote .hintMessage }} | ||
{{- if .hintType }} | ||
hintType: {{ .hintType }} | ||
{{- end }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property is already called vendorHints
. It would not repeat vendor and hint in child properties. Type from my point of view should be named severity. But this is only my personal opinion.
{{- range .Values.frontendConfig.vendorHints }} | |
- vendorNames: | |
{{- range .vendorNames }} | |
- {{ . }} | |
{{- end }} | |
hintMessage: {{ quote .hintMessage }} | |
{{- if .hintType }} | |
hintType: {{ .hintType }} | |
{{- end }} | |
{{- end }} | |
{{- range .Values.frontendConfig.vendorHints }} | |
- matchNames: {{ toJson .matchNames }} | |
message: {{ quote .message }} | |
{{- if .severity }} | |
severity: {{ .severity }} | |
{{- end }} | |
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed as suggested
Co-authored-by: Holger Koser <holger.koser@sap.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What this PR does / why we need it:
Some vendors require additional hints, e.g. to inform the user that an enterprise license is required for usage.
With this PR it is possible to define those hints via the dashboard configuration.
Example:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: