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

66 lines
1.8 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
import { mapState, mapActions } from 'vuex';
import createFlash from '~/flash';
import { s__ } from '~/locale';
2019-12-21 20:55:43 +05:30
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
2018-05-09 12:01:36 +05:30
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,
2019-12-21 20:55:43 +05:30
GlModal: DeprecatedModal2,
2018-05-09 12:01:36 +05:30
},
computed: {
...mapState(['badgeInModal', 'isEditing']),
deleteModalText() {
return s__(
'Badges|You are going to delete this badge. Deleted badges <strong>cannot</strong> be restored.',
);
},
},
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
id="delete-badge-modal"
:header-title-text="s__('Badges|Delete badge?')"
:footer-primary-button-text="s__('Badges|Delete badge')"
2018-11-08 19:23:39 +05:30
footer-primary-button-variant="danger"
2019-02-15 15:39:39 +05:30
@submit="onSubmitModal"
>
2018-05-09 12:01:36 +05:30
<div class="well">
<badge
:image-url="badgeInModal ? badgeInModal.renderedImageUrl : ''"
:link-url="badgeInModal ? badgeInModal.renderedLinkUrl : ''"
/>
</div>
<p v-html="deleteModalText"></p>
</gl-modal>
2019-02-15 15:39:39 +05:30
<badge-form v-show="isEditing" :is-editing="true" />
2018-05-09 12:01:36 +05:30
2019-02-15 15:39:39 +05:30
<badge-form v-show="!isEditing" :is-editing="false" />
2018-05-09 12:01:36 +05:30
<badge-list v-show="!isEditing" />
</div>
</template>