Commit 9cffbbf9 authored by Thomas Randolph's avatar Thomas Randolph

Switch MR Widgets to use a structured data output for summaries

parent b990dc7a
...@@ -94,6 +94,20 @@ export default { ...@@ -94,6 +94,20 @@ export default {
tertiaryActionsButtons() { tertiaryActionsButtons() {
return this.tertiaryButtons ? this.tertiaryButtons() : undefined; return this.tertiaryButtons ? this.tertiaryButtons() : undefined;
}, },
hydratedSummary() {
const structuredOutput = this.summary(this.collapsedData);
const summary = {
subject: generateText(
typeof structuredOutput === 'string' ? structuredOutput : structuredOutput.subject,
),
};
if (structuredOutput.meta) {
summary.meta = generateText(structuredOutput.meta);
}
return summary;
},
}, },
watch: { watch: {
isCollapsed(newVal) { isCollapsed(newVal) {
...@@ -182,7 +196,13 @@ export default { ...@@ -182,7 +196,13 @@ export default {
<div class="gl-flex-grow-1"> <div class="gl-flex-grow-1">
<template v-if="isLoadingSummary">{{ widgetLoadingText }}</template> <template v-if="isLoadingSummary">{{ widgetLoadingText }}</template>
<template v-else-if="hasFetchError">{{ widgetErrorText }}</template> <template v-else-if="hasFetchError">{{ widgetErrorText }}</template>
<div v-else v-safe-html="generateText(summary(collapsedData))"></div> <div v-else>
<span v-safe-html="hydratedSummary.subject"></span>
<template v-if="hydratedSummary.meta">
<br />
<span v-safe-html="hydratedSummary.meta" class="gl-font-sm"></span>
</template>
</div>
</div> </div>
<actions <actions
:widget="$options.label || $options.name" :widget="$options.label || $options.name"
......
...@@ -38,10 +38,10 @@ export default { ...@@ -38,10 +38,10 @@ export default {
}, },
); );
return `${text} return {
<br> subject: text,
${reportNumbersText} meta: reportNumbersText,
`; };
}, },
statusIcon() { statusIcon() {
if (this.collapsedData.degraded.length || this.collapsedData.same.length) { if (this.collapsedData.degraded.length || this.collapsedData.same.length) {
......
...@@ -35,10 +35,10 @@ export default { ...@@ -35,10 +35,10 @@ export default {
}, },
); );
return `${text} return {
<br> subject: text,
${reportNumbersText} meta: reportNumbersText,
`; };
}, },
statusIcon() { statusIcon() {
if (this.collapsedData.degraded.length || this.collapsedData.same.length) { if (this.collapsedData.degraded.length || this.collapsedData.same.length) {
......
...@@ -46,13 +46,10 @@ export default { ...@@ -46,13 +46,10 @@ export default {
); );
} }
return ` return {
${s__('StatusCheck|Status checks')} subject: s__('StatusCheck|Status checks'),
<br> meta: reports.join(__(', and ')),
<span class="gl-font-sm"> };
${reports.join(__(', and '))}
</span>
`;
}, },
statusIcon({ pending = [], failed = [] }) { statusIcon({ pending = [], failed = [] }) {
if (failed.length > 0) { if (failed.length > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment