debian-mirror-gitlab/app/assets/javascripts/badges/components/badge_settings.vue

89 lines
2.2 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2021-01-03 14:25:43 +05:30
import { GlSprintf, GlModal } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapState, mapActions } from 'vuex';
2021-09-04 01:27:46 +05:30
import 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(() => {
2021-09-04 01:27:46 +05:30
createFlash({
message: s__('Badges|The badge was deleted.'),
type: 'notice',
});
2018-05-09 12:01:36 +05:30
})
2021-03-08 18:12:59 +05:30
.catch((error) => {
2021-09-04 01:27:46 +05:30
createFlash({
message: s__('Badges|Deleting the badge failed, please try again.'),
});
2018-05-09 12:01:36 +05:30
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>