debian-mirror-gitlab/app/assets/javascripts/related_issues/components/issue_token.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

120 lines
3.4 KiB
Vue
Raw Normal View History

2020-11-24 15:15:51 +05:30
<script>
2021-01-29 00:20:46 +05:30
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2020-11-24 15:15:51 +05:30
import { __, sprintf } from '~/locale';
2022-01-26 12:08:38 +05:30
import relatedIssuableMixin from '~/issuable/mixins/related_issuable_mixin';
2020-11-24 15:15:51 +05:30
export default {
name: 'IssueToken',
components: {
GlIcon,
},
2021-01-29 00:20:46 +05:30
directives: {
GlTooltip: GlTooltipDirective,
},
2020-11-24 15:15:51 +05:30
mixins: [relatedIssuableMixin],
props: {
isCondensed: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
removeButtonLabel() {
const { displayReference } = this;
/*
* Giving false as third argument to prevent unescaping of ampersand in
* epic reference. Eg. &42 will remain &42 instead of &amp;42
*
* https://docs.gitlab.com/ee/development/i18n/externalization.html#interpolation
*/
return sprintf(__('Remove %{displayReference}'), { displayReference }, false);
},
stateTitle() {
if (this.isCondensed) return '';
return this.isOpen ? __('Open') : __('Closed');
},
innerComponentType() {
return this.isCondensed ? 'span' : 'div';
},
issueTitle() {
return this.isCondensed ? this.title : '';
},
},
};
</script>
<template>
<div
:class="{
2021-11-18 22:05:49 +05:30
'issue-token gl-display-inline-flex gl-align-items-stretch gl-max-w-full gl-line-height-24 gl-white-space-nowrap': isCondensed,
2020-11-24 15:15:51 +05:30
'flex-row issuable-info-container': !isCondensed,
}"
>
<component
:is="computedLinkElementType"
ref="link"
2021-01-29 00:20:46 +05:30
v-gl-tooltip
2020-11-24 15:15:51 +05:30
:class="{
2021-11-18 22:05:49 +05:30
'issue-token-link gl-display-inline-flex gl-min-w-0 gl-text-gray-500': isCondensed,
2020-11-24 15:15:51 +05:30
'issuable-main-info': !isCondensed,
}"
:href="computedPath"
:title="issueTitle"
data-placement="top"
>
<component
:is="innerComponentType"
v-if="hasTitle"
ref="title"
:class="{
2021-11-18 22:05:49 +05:30
'issue-token-title issue-token-end gl-overflow-hidden gl-display-flex gl-align-items-baseline gl-text-gray-500 gl-pl-3': isCondensed,
2020-11-24 15:15:51 +05:30
'issue-title block-truncated': !isCondensed,
2021-11-18 22:05:49 +05:30
'gl-rounded-top-right-small gl-rounded-bottom-right-small gl-pr-3': !canRemove,
2020-11-24 15:15:51 +05:30
}"
class="js-issue-token-title"
>
2021-11-18 22:05:49 +05:30
<span class="gl-text-truncate">{{ title }}</span>
2020-11-24 15:15:51 +05:30
</component>
<component
:is="innerComponentType"
ref="reference"
:class="{
2021-11-18 22:05:49 +05:30
'issue-token-reference gl-display-flex gl-align-items-center gl-rounded-top-left-small gl-rounded-bottom-left-small gl-px-3': isCondensed,
2020-11-24 15:15:51 +05:30
'issuable-info': !isCondensed,
}"
>
<gl-icon
v-if="hasState"
2021-01-29 00:20:46 +05:30
v-gl-tooltip
2020-11-24 15:15:51 +05:30
:class="iconClass"
:name="iconName"
:size="12"
:title="stateTitle"
:aria-label="state"
2021-01-03 14:25:43 +05:30
data-testid="referenceIcon"
2020-11-24 15:15:51 +05:30
/>
{{ displayReference }}
</component>
</component>
<button
v-if="canRemove"
ref="removeButton"
2021-01-29 00:20:46 +05:30
v-gl-tooltip
2020-11-24 15:15:51 +05:30
:class="{
2021-11-18 22:05:49 +05:30
'issue-token-remove-button gl-display-flex gl-align-items-center gl-px-3 gl-border-0 gl-rounded-top-right-small gl-rounded-bottom-right-small gl-text-gray-500': isCondensed,
2020-11-24 15:15:51 +05:30
'btn btn-default': !isCondensed,
}"
:title="removeButtonLabel"
:aria-label="removeButtonLabel"
:disabled="removeDisabled"
2021-01-03 14:25:43 +05:30
data-testid="removeBtn"
2020-11-24 15:15:51 +05:30
type="button"
@click="onRemoveRequest"
>
2021-02-22 17:27:13 +05:30
<gl-icon name="close" />
2020-11-24 15:15:51 +05:30
</button>
</div>
</template>