Commit e3272f4a authored by Tom Quirk's avatar Tom Quirk

Remove slot from copyable_field.vue

Instead, handle UI text creation within the component.
parent 81cfd79e
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
/** /**
...@@ -35,12 +35,23 @@ export default { ...@@ -35,12 +35,23 @@ export default {
tooltipBoundary: 'viewport', tooltipBoundary: 'viewport',
tooltipPlacement: 'left', tooltipPlacement: 'left',
text: this.value, text: this.value,
title: sprintf(__('Copy %{name}'), { name: this.name }), title: sprintf(this.$options.i18n.clipboardTooltip, { name: this.name }),
}; };
}, },
loadingIconLabel() { loadingIconLabel() {
return sprintf(__('Loading %{name}'), { name: this.name }); return sprintf(this.$options.i18n.loadingIconLabel, { name: this.name });
}, },
templateText() {
return sprintf(this.$options.i18n.templateText, {
name: this.name,
value: this.value,
});
},
},
i18n: {
loadingIconLabel: __('Loading %{name}'),
clipboardTooltip: __('Copy %{name}'),
templateText: s__('Sidebar|%{name}: %{value}'),
}, },
}; };
</script> </script>
...@@ -56,14 +67,12 @@ export default { ...@@ -56,14 +67,12 @@ export default {
<div <div
class="gl-display-flex gl-align-items-center gl-justify-content-space-between hide-collapsed" class="gl-display-flex gl-align-items-center gl-justify-content-space-between hide-collapsed"
> >
<gl-loading-icon v-if="isLoading" inline :label="loadingIconLabel" /> <span class="gl-overflow-hidden gl-text-overflow-ellipsis gl-white-space-nowrap">
<template v-else> {{ templateText }}
<span class="gl-overflow-hidden gl-text-overflow-ellipsis gl-white-space-nowrap"> </span>
<slot></slot>
</span>
<clipboard-button size="small" v-bind="clipboardProps" /> <gl-loading-icon v-if="isLoading" inline :label="loadingIconLabel" />
</template> <clipboard-button v-else size="small" v-bind="clipboardProps" />
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { GlSprintf } from '@gitlab/ui';
import { labelsFilterParam } from 'ee/integrations/jira/issues_show/constants'; import { labelsFilterParam } from 'ee/integrations/jira/issues_show/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
import CopyableField from '~/vue_shared/components/sidebar/copyable_field.vue'; import CopyableField from '~/vue_shared/components/sidebar/copyable_field.vue';
...@@ -11,7 +10,6 @@ import IssueField from './issue_field.vue'; ...@@ -11,7 +10,6 @@ import IssueField from './issue_field.vue';
export default { export default {
name: 'JiraIssuesSidebar', name: 'JiraIssuesSidebar',
components: { components: {
GlSprintf,
Assignee, Assignee,
IssueDueDate, IssueDueDate,
IssueField, IssueField,
...@@ -46,7 +44,6 @@ export default { ...@@ -46,7 +44,6 @@ export default {
i18n: { i18n: {
statusTitle: __('Status'), statusTitle: __('Status'),
referenceName: __('Reference'), referenceName: __('Reference'),
referenceText: __('Reference: %{reference}'),
}, },
}; };
</script> </script>
...@@ -70,14 +67,6 @@ export default { ...@@ -70,14 +67,6 @@ export default {
class="block" class="block"
:name="$options.i18n.referenceName" :name="$options.i18n.referenceName"
:value="reference" :value="reference"
> />
<span class="cross-project-reference">
<gl-sprintf :message="$options.i18n.referenceText">
<template #reference>
<cite>{{ reference }}</cite>
</template>
</gl-sprintf>
</span>
</copyable-field>
</div> </div>
</template> </template>
...@@ -8497,6 +8497,9 @@ msgstr "" ...@@ -8497,6 +8497,9 @@ msgstr ""
msgid "Copy %{http_label} clone URL" msgid "Copy %{http_label} clone URL"
msgstr "" msgstr ""
msgid "Copy %{name}"
msgstr ""
msgid "Copy %{protocol} clone URL" msgid "Copy %{protocol} clone URL"
msgstr "" msgstr ""
...@@ -18428,6 +18431,9 @@ msgstr "" ...@@ -18428,6 +18431,9 @@ msgstr ""
msgid "Loading" msgid "Loading"
msgstr "" msgstr ""
msgid "Loading %{name}"
msgstr ""
msgid "Loading contribution stats for group members" msgid "Loading contribution stats for group members"
msgstr "" msgstr ""
...@@ -25189,9 +25195,6 @@ msgstr "" ...@@ -25189,9 +25195,6 @@ msgstr ""
msgid "Reference" msgid "Reference"
msgstr "" msgstr ""
msgid "Reference:"
msgstr ""
msgid "References" msgid "References"
msgstr "" msgstr ""
...@@ -28091,6 +28094,9 @@ msgstr "" ...@@ -28091,6 +28094,9 @@ msgstr ""
msgid "Side-by-side" msgid "Side-by-side"
msgstr "" msgstr ""
msgid "Sidebar|%{name}: %{value}"
msgstr ""
msgid "Sidebar|Assign health status" msgid "Sidebar|Assign health status"
msgstr "" msgstr ""
......
...@@ -14,9 +14,6 @@ describe('SidebarCopyableField', () => { ...@@ -14,9 +14,6 @@ describe('SidebarCopyableField', () => {
const createComponent = (propsData = defaultProps) => { const createComponent = (propsData = defaultProps) => {
wrapper = shallowMount(CopyableField, { wrapper = shallowMount(CopyableField, {
propsData, propsData,
slots: {
default: 'Reference: Gl-1',
},
}); });
}; };
...@@ -51,12 +48,18 @@ describe('SidebarCopyableField', () => { ...@@ -51,12 +48,18 @@ describe('SidebarCopyableField', () => {
}); });
describe('when `isLoading` prop is `true`', () => { describe('when `isLoading` prop is `true`', () => {
it('renders loading icon', () => { beforeEach(() => {
createComponent({ ...defaultProps, isLoading: true }); createComponent({ ...defaultProps, isLoading: true });
});
it('renders loading icon', () => {
expect(findLoadingIcon().exists()).toBe(true); expect(findLoadingIcon().exists()).toBe(true);
expect(findLoadingIcon().props('label')).toBe('Loading Reference'); expect(findLoadingIcon().props('label')).toBe('Loading Reference');
}); });
it('does not render clipboard button', () => {
expect(findClipboardButton().exists()).toBe(false);
});
}); });
}); });
}); });
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