Commit 9ed303a6 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '241895-Replace-v-html' into 'master'

Replace v-html with inline text in weight.vue

See merge request gitlab-org/gitlab!41325
parents a5a5a047 a452b4e2
<script> <script>
/* eslint-disable vue/no-v-html */
import $ from 'jquery'; import $ from 'jquery';
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import { MAX_DISPLAY_WEIGHT } from '../../constants';
export default { export default {
components: { components: {
...@@ -66,31 +66,15 @@ export default { ...@@ -66,31 +66,15 @@ export default {
return this.checkIfNoValue(this.weight); return this.checkIfNoValue(this.weight);
}, },
collapsedWeightLabel() { collapsedWeightLabel() {
let label = this.weight; return this.checkIfNoValue(this.weight)
if (this.checkIfNoValue(this.weight)) { ? this.noValueLabel
label = this.noValueLabel; : this.weight.toString().substr(0, 5);
}
// Truncate with ellipsis after five digits
if (this.weight > 99999) {
label = `${this.weight.toString().substr(0, 5)}&hellip;`;
}
return label;
}, },
noValueLabel() { noValueLabel() {
return s__('Sidebar|None'); return s__('Sidebar|None');
}, },
changeWeightLabel() {
return s__('Sidebar|Change weight');
},
dropdownToggleLabel() { dropdownToggleLabel() {
let label = this.weight; return this.checkIfNoValue(this.weight) ? s__('Sidebar|Weight') : this.weight;
if (this.checkIfNoValue(this.weight)) {
label = s__('Sidebar|Weight');
}
return label;
}, },
shouldShowWeight() { shouldShowWeight() {
return !this.fetching && !this.shouldShowEditField; return !this.fetching && !this.shouldShowEditField;
...@@ -150,6 +134,7 @@ export default { ...@@ -150,6 +134,7 @@ export default {
eventHub.$emit('updateWeight', '', this.id); eventHub.$emit('updateWeight', '', this.id);
}, },
}, },
maxDisplayWeight: MAX_DISPLAY_WEIGHT,
}; };
</script> </script>
...@@ -166,7 +151,12 @@ export default { ...@@ -166,7 +151,12 @@ export default {
> >
<gl-icon :size="16" name="weight" /> <gl-icon :size="16" name="weight" />
<gl-loading-icon v-if="fetching" class="js-weight-collapsed-loading-icon" /> <gl-loading-icon v-if="fetching" class="js-weight-collapsed-loading-icon" />
<span v-else class="js-weight-collapsed-weight-label" v-html="collapsedWeightLabel"></span> <span v-else class="js-weight-collapsed-weight-label">
{{ collapsedWeightLabel
}}<template v-if="weight > $options.maxDisplayWeight"
>&hellip;</template
>
</span>
</div> </div>
<div class="title hide-collapsed"> <div class="title hide-collapsed">
{{ s__('Sidebar|Weight') }} {{ s__('Sidebar|Weight') }}
......
...@@ -25,3 +25,5 @@ export const healthStatusForRestApi = { ...@@ -25,3 +25,5 @@ export const healthStatusForRestApi = {
[healthStatus.NEEDS_ATTENTION]: 'needs_attention', [healthStatus.NEEDS_ATTENTION]: 'needs_attention',
[healthStatus.AT_RISK]: 'at_risk', [healthStatus.AT_RISK]: 'at_risk',
}; };
export const MAX_DISPLAY_WEIGHT = 99999;
---
title: Replace v-html with inline text in weight.vue
merge_request: 41325
author: Kev @KevSlashNull
type: other
...@@ -23214,9 +23214,6 @@ msgstr "" ...@@ -23214,9 +23214,6 @@ msgstr ""
msgid "Sidebar|Assign health status" msgid "Sidebar|Assign health status"
msgstr "" msgstr ""
msgid "Sidebar|Change weight"
msgstr ""
msgid "Sidebar|Health status" msgid "Sidebar|Health status"
msgstr "" msgstr ""
......
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