2018-02-16 19:11:36 -05:00
|
|
|
<script>
|
2020-10-27 08:08:33 -04:00
|
|
|
import { GlSprintf, GlModal } from '@gitlab/ui';
|
2021-06-02 17:10:00 -04:00
|
|
|
import createFlash from '~/flash';
|
2021-02-14 13:09:20 -05:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2018-10-10 02:41:22 -04:00
|
|
|
import { visitUrl } from '~/lib/utils/url_utility';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { s__, __, sprintf } from '~/locale';
|
2018-10-10 02:41:22 -04:00
|
|
|
import eventHub from '../event_hub';
|
2018-02-16 19:11:36 -05:00
|
|
|
|
2018-10-10 02:41:22 -04:00
|
|
|
export default {
|
2020-10-27 08:08:33 -04:00
|
|
|
primaryProps: {
|
|
|
|
text: s__('Labels|Promote Label'),
|
2022-05-31 14:08:16 -04:00
|
|
|
attributes: [{ variant: 'confirm' }],
|
2020-10-27 08:08:33 -04:00
|
|
|
},
|
|
|
|
cancelProps: {
|
|
|
|
text: __('Cancel'),
|
|
|
|
},
|
2018-10-10 02:41:22 -04:00
|
|
|
components: {
|
2020-10-27 08:08:33 -04:00
|
|
|
GlModal,
|
2020-08-18 17:09:57 -04:00
|
|
|
GlSprintf,
|
2018-10-10 02:41:22 -04:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-02-16 19:11:36 -05:00
|
|
|
},
|
2018-10-10 02:41:22 -04:00
|
|
|
labelTitle: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-02-16 19:11:36 -05:00
|
|
|
},
|
2018-10-10 02:41:22 -04:00
|
|
|
labelColor: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
labelTextColor: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
groupName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
text() {
|
|
|
|
return sprintf(
|
|
|
|
s__(`Labels|Promoting %{labelTitle} will make it available for all projects inside %{groupName}.
|
2020-03-30 14:08:07 -04:00
|
|
|
Existing project labels with the same title will be merged. If a group label with the same title exists,
|
|
|
|
it will also be merged. This action cannot be reversed.`),
|
2018-10-10 02:41:22 -04:00
|
|
|
{
|
2018-03-13 12:36:13 -04:00
|
|
|
labelTitle: this.labelTitle,
|
|
|
|
groupName: this.groupName,
|
2018-10-10 02:41:22 -04:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onSubmit() {
|
|
|
|
eventHub.$emit('promoteLabelModal.requestStarted', this.url);
|
|
|
|
return axios
|
|
|
|
.post(this.url, { params: { format: 'json' } })
|
2020-12-23 16:10:24 -05:00
|
|
|
.then((response) => {
|
2018-10-10 02:41:22 -04:00
|
|
|
eventHub.$emit('promoteLabelModal.requestFinished', {
|
|
|
|
labelUrl: this.url,
|
|
|
|
successful: true,
|
|
|
|
});
|
|
|
|
visitUrl(response.data.url);
|
|
|
|
})
|
2020-12-23 16:10:24 -05:00
|
|
|
.catch((error) => {
|
2018-10-10 02:41:22 -04:00
|
|
|
eventHub.$emit('promoteLabelModal.requestFinished', {
|
|
|
|
labelUrl: this.url,
|
|
|
|
successful: false,
|
2018-02-16 19:11:36 -05:00
|
|
|
});
|
2021-06-02 17:10:00 -04:00
|
|
|
createFlash({
|
|
|
|
message: error,
|
|
|
|
});
|
2018-10-10 02:41:22 -04:00
|
|
|
});
|
2018-02-16 19:11:36 -05:00
|
|
|
},
|
2018-10-10 02:41:22 -04:00
|
|
|
},
|
|
|
|
};
|
2018-02-16 19:11:36 -05:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<gl-modal
|
2020-10-27 08:08:33 -04:00
|
|
|
modal-id="promote-label-modal"
|
|
|
|
:action-primary="$options.primaryProps"
|
|
|
|
:action-cancel="$options.cancelProps"
|
|
|
|
@primary="onSubmit"
|
2018-02-16 19:11:36 -05:00
|
|
|
>
|
2021-06-24 20:08:34 -04:00
|
|
|
<template #modal-title>
|
|
|
|
<div class="modal-title-with-label">
|
|
|
|
<gl-sprintf
|
|
|
|
:message="
|
|
|
|
s__(
|
|
|
|
'Labels|%{spanStart}Promote label%{spanEnd} %{labelTitle} %{spanStart}to Group Label?%{spanEnd}',
|
|
|
|
)
|
|
|
|
"
|
2020-08-18 17:09:57 -04:00
|
|
|
>
|
2021-06-24 20:08:34 -04:00
|
|
|
<template #labelTitle>
|
|
|
|
<span
|
|
|
|
class="label color-label"
|
|
|
|
:style="`background-color: ${labelColor}; color: ${labelTextColor};`"
|
|
|
|
>
|
|
|
|
{{ labelTitle }}
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
<template #span="{ content }"
|
|
|
|
><span>{{ content }}</span></template
|
|
|
|
>
|
|
|
|
</gl-sprintf>
|
|
|
|
</div>
|
|
|
|
</template>
|
2018-02-16 19:11:36 -05:00
|
|
|
{{ text }}
|
|
|
|
</gl-modal>
|
|
|
|
</template>
|