Skip to content
Snippets Groups Projects

Update Work Item Drawer header

Merged Jack Chapman requested to merge jc/465823-work-item-drawer-header into master
All threads resolved!
1 file
+ 7
3
Compare changes
  • Side-by-side
  • Inline
<script>
<script>
import { GlLink, GlDrawer } from '@gitlab/ui';
import { GlLink, GlDrawer, GlButton, GlTooltipDirective } from '@gitlab/ui';
import { escapeRegExp } from 'lodash';
import { escapeRegExp } from 'lodash';
 
import { __ } from '~/locale';
import deleteWorkItemMutation from '~/work_items/graphql/delete_work_item.mutation.graphql';
import deleteWorkItemMutation from '~/work_items/graphql/delete_work_item.mutation.graphql';
import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants';
import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants';
import * as Sentry from '~/sentry/sentry_browser_wrapper';
import * as Sentry from '~/sentry/sentry_browser_wrapper';
@@ -8,9 +9,13 @@ import { visitUrl } from '~/lib/utils/url_utility';
@@ -8,9 +9,13 @@ import { visitUrl } from '~/lib/utils/url_utility';
export default {
export default {
name: 'WorkItemDrawer',
name: 'WorkItemDrawer',
 
directives: {
 
GlTooltip: GlTooltipDirective,
 
},
components: {
components: {
GlLink,
GlLink,
GlDrawer,
GlDrawer,
 
GlButton,
WorkItemDetail: () => import('~/work_items/components/work_item_detail.vue'),
WorkItemDetail: () => import('~/work_items/components/work_item_detail.vue'),
},
},
inject: ['fullPath'],
inject: ['fullPath'],
@@ -31,6 +36,11 @@ export default {
@@ -31,6 +36,11 @@ export default {
default: TYPE_ISSUE,
default: TYPE_ISSUE,
},
},
},
},
 
data() {
 
return {
 
copyTooltipText: this.$options.i18n.copyTooltipText,
 
};
 
},
computed: {
computed: {
activeItemFullPath() {
activeItemFullPath() {
if (this.activeItem?.fullPath) {
if (this.activeItem?.fullPath) {
@@ -45,6 +55,10 @@ export default {
@@ -45,6 +55,10 @@ export default {
modalIsGroup() {
modalIsGroup() {
return this.issuableType === TYPE_EPIC;
return this.issuableType === TYPE_EPIC;
},
},
 
headerReference() {
 
const path = this.activeItemFullPath.substring(this.activeItemFullPath.lastIndexOf('/') + 1);
 
return `${path}#${this.activeItem.iid}`;
 
},
},
},
methods: {
methods: {
async deleteWorkItem({ workItemId }) {
async deleteWorkItem({ workItemId }) {
@@ -62,8 +76,12 @@ export default {
@@ -62,8 +76,12 @@ export default {
Sentry.captureException(error);
Sentry.captureException(error);
}
}
},
},
redirectToWorkItem() {
redirectToWorkItem(e) {
const workItem = this.activeItem;
const workItem = this.activeItem;
 
if (e.metaKey || e.ctrlKey) {
 
return;
 
}
 
e.preventDefault();
const escapedFullPath = escapeRegExp(this.fullPath);
const escapedFullPath = escapeRegExp(this.fullPath);
// eslint-disable-next-line no-useless-escape
// eslint-disable-next-line no-useless-escape
const regex = new RegExp(`groups\/${escapedFullPath}\/-\/(work_items|epics)\/\\d+`);
const regex = new RegExp(`groups\/${escapedFullPath}\/-\/(work_items|epics)\/\\d+`);
@@ -80,6 +98,17 @@ export default {
@@ -80,6 +98,17 @@ export default {
visitUrl(workItem.webUrl);
visitUrl(workItem.webUrl);
}
}
},
},
 
handleCopyToClipboard() {
 
this.copyTooltipText = this.$options.i18n.copiedTooltipText;
 
setTimeout(() => {
 
this.copyTooltipText = this.$options.i18n.copyTooltipText;
 
}, 2000);
 
},
 
},
 
i18n: {
 
copyTooltipText: __('Copy item URL'),
 
copiedTooltipText: __('Copied'),
 
openTooltipText: __('Open in full page'),
},
},
};
};
</script>
</script>
@@ -94,12 +123,39 @@ export default {
@@ -94,12 +123,39 @@ export default {
@close="$emit('close')"
@close="$emit('close')"
>
>
<template #title>
<template #title>
<gl-link
<div class="gl-text gl-flex gl-w-full gl-items-center gl-gap-x-2 xl:gl-px-4">
class="gl-text-default"
<gl-link
:href="activeItem.webUrl"
:href="activeItem.webUrl"
@click.prevent="redirectToWorkItem"
class="gl-text-sm gl-font-bold gl-text-default"
>{{ __('Open full view') }}</gl-link
@click="redirectToWorkItem"
>
>
 
{{ headerReference }}
 
</gl-link>
 
<gl-button
 
v-gl-tooltip
 
data-testid="work-item-drawer-copy-button"
 
:title="copyTooltipText"
 
category="tertiary"
 
class="gl-text-secondary"
 
icon="link"
 
size="small"
 
:aria-label="$options.i18n.copyTooltipText"
 
:data-clipboard-text="activeItem.webUrl"
 
@click="handleCopyToClipboard"
 
/>
 
<gl-button
 
v-gl-tooltip
 
data-testid="work-item-drawer-link-button"
 
:href="activeItem.webUrl"
 
:title="$options.i18n.openTooltipText"
 
category="tertiary"
 
class="gl-text-secondary"
 
icon="maximize"
 
size="small"
 
:aria-label="$options.i18n.openTooltipText"
 
@click="redirectToWorkItem"
 
/>
 
</div>
</template>
</template>
<template #default>
<template #default>
<work-item-detail
<work-item-detail
Loading