debian-mirror-gitlab/app/assets/javascripts/design_management/components/toolbar/index.vue

127 lines
3 KiB
Vue
Raw Normal View History

2020-05-24 23:13:21 +05:30
<script>
2020-10-24 23:57:45 +05:30
import { GlButton, GlIcon } from '@gitlab/ui';
2020-05-24 23:13:21 +05:30
import { __, sprintf } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago';
2020-10-24 23:57:45 +05:30
import DesignNavigation from './design_navigation.vue';
2020-05-24 23:13:21 +05:30
import DeleteButton from '../delete_button.vue';
import permissionsQuery from '../../graphql/queries/design_permissions.query.graphql';
import { DESIGNS_ROUTE_NAME } from '../../router/constants';
export default {
components: {
2020-10-24 23:57:45 +05:30
GlButton,
GlIcon,
DesignNavigation,
2020-05-24 23:13:21 +05:30
DeleteButton,
},
mixins: [timeagoMixin],
props: {
id: {
type: String,
required: true,
},
isDeleting: {
type: Boolean,
required: true,
},
filename: {
type: String,
required: false,
default: '',
},
updatedAt: {
type: String,
required: false,
default: null,
},
updatedBy: {
type: Object,
required: false,
default: () => ({}),
},
isLatestVersion: {
type: Boolean,
required: true,
},
image: {
type: String,
required: true,
},
},
data() {
return {
permissions: {
createDesign: false,
},
};
},
2020-10-24 23:57:45 +05:30
inject: {
projectPath: {
default: '',
2020-05-24 23:13:21 +05:30
},
2020-10-24 23:57:45 +05:30
issueIid: {
default: '',
},
},
apollo: {
2020-05-24 23:13:21 +05:30
permissions: {
query: permissionsQuery,
variables() {
return {
fullPath: this.projectPath,
iid: this.issueIid,
};
},
update: data => data.project.issue.userPermissions,
},
},
computed: {
updatedText() {
return sprintf(__('Updated %{updated_at} by %{updated_by}'), {
updated_at: this.timeFormatted(this.updatedAt),
updated_by: this.updatedBy.name,
});
},
canDeleteDesign() {
return this.permissions.createDesign;
},
},
DESIGNS_ROUTE_NAME,
};
</script>
<template>
2020-10-24 23:57:45 +05:30
<header
class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-bg-white gl-py-4 gl-pl-4 js-design-header"
>
<div class="gl-display-flex gl-align-items-center">
<router-link
:to="{
name: $options.DESIGNS_ROUTE_NAME,
query: $route.query,
}"
:aria-label="s__('DesignManagement|Go back to designs')"
data-testid="close-design"
class="gl-mr-5 gl-display-flex gl-align-items-center gl-justify-content-center text-plain"
>
<gl-icon name="close" />
</router-link>
<div class="overflow-hidden d-flex align-items-center">
<h2 class="m-0 str-truncated-100 gl-font-base">{{ filename }}</h2>
<small v-if="updatedAt" class="text-secondary">{{ updatedText }}</small>
</div>
2020-05-24 23:13:21 +05:30
</div>
2020-10-24 23:57:45 +05:30
<design-navigation :id="id" class="ml-auto flex-shrink-0" />
<gl-button :href="image" icon="download" />
2020-05-24 23:13:21 +05:30
<delete-button
v-if="isLatestVersion && canDeleteDesign"
2020-10-24 23:57:45 +05:30
class="gl-ml-3"
2020-05-24 23:13:21 +05:30
:is-deleting="isDeleting"
2020-10-24 23:57:45 +05:30
button-variant="warning"
button-icon="archive"
button-category="secondary"
2020-05-24 23:13:21 +05:30
@deleteSelectedDesigns="$emit('delete')"
2020-10-24 23:57:45 +05:30
/>
2020-05-24 23:13:21 +05:30
</header>
</template>