2018-05-09 12:01:36 +05:30
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { GlSprintf, GlModal } from '@gitlab/ui';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { deprecatedCreateFlash as createFlash } from '~/flash';
|
2018-05-09 12:01:36 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import Badge from './badge.vue';
|
|
|
|
import BadgeForm from './badge_form.vue';
|
|
|
|
import BadgeList from './badge_list.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BadgeSettings',
|
|
|
|
components: {
|
|
|
|
Badge,
|
|
|
|
BadgeForm,
|
|
|
|
BadgeList,
|
2021-01-03 14:25:43 +05:30
|
|
|
GlModal,
|
2020-10-24 23:57:45 +05:30
|
|
|
GlSprintf,
|
|
|
|
},
|
|
|
|
i18n: {
|
|
|
|
deleteModalText: s__(
|
|
|
|
'Badges|You are going to delete this badge. Deleted badges %{strongStart}cannot%{strongEnd} be restored.',
|
|
|
|
),
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(['badgeInModal', 'isEditing']),
|
2021-01-03 14:25:43 +05:30
|
|
|
primaryProps() {
|
|
|
|
return {
|
|
|
|
text: s__('Delete badge'),
|
|
|
|
attributes: [{ category: 'primary' }, { variant: 'danger' }],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
cancelProps() {
|
|
|
|
return {
|
|
|
|
text: s__('Cancel'),
|
|
|
|
};
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['deleteBadge']),
|
|
|
|
onSubmitModal() {
|
|
|
|
this.deleteBadge(this.badgeInModal)
|
|
|
|
.then(() => {
|
|
|
|
createFlash(s__('Badges|The badge was deleted.'), 'notice');
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
createFlash(s__('Badges|Deleting the badge failed, please try again.'));
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="badge-settings">
|
|
|
|
<gl-modal
|
2021-01-03 14:25:43 +05:30
|
|
|
modal-id="delete-badge-modal"
|
|
|
|
:title="s__('Badges|Delete badge?')"
|
|
|
|
:action-primary="primaryProps"
|
|
|
|
:action-cancel="cancelProps"
|
|
|
|
@primary="onSubmitModal"
|
2019-02-15 15:39:39 +05:30
|
|
|
>
|
2018-05-09 12:01:36 +05:30
|
|
|
<div class="well">
|
|
|
|
<badge
|
|
|
|
:image-url="badgeInModal ? badgeInModal.renderedImageUrl : ''"
|
|
|
|
:link-url="badgeInModal ? badgeInModal.renderedLinkUrl : ''"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-10-24 23:57:45 +05:30
|
|
|
<p>
|
|
|
|
<gl-sprintf :message="$options.i18n.deleteModalText">
|
|
|
|
<template #strong="{ content }">
|
|
|
|
<strong>{{ content }}</strong>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</p>
|
2018-05-09 12:01:36 +05:30
|
|
|
</gl-modal>
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
<badge-form v-show="isEditing" :is-editing="true" data-testid="edit-badge" />
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
<badge-form v-show="!isEditing" :is-editing="false" data-testid="add-new-badge" />
|
2018-05-09 12:01:36 +05:30
|
|
|
<badge-list v-show="!isEditing" />
|
|
|
|
</div>
|
|
|
|
</template>
|