2018-03-27 19:54:05 +05:30
|
|
|
<script>
|
2021-01-29 00:20:46 +05:30
|
|
|
import { GlSprintf, GlModal } from '@gitlab/ui';
|
2022-11-25 23:54:43 +05:30
|
|
|
import { createAlert } from '~/flash';
|
2021-03-11 19:13:27 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2018-12-13 13:39:08 +05:30
|
|
|
import { visitUrl } from '~/lib/utils/url_utility';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { s__, __, sprintf } from '~/locale';
|
2018-12-13 13:39:08 +05:30
|
|
|
import eventHub from '../event_hub';
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
2021-01-29 00:20:46 +05:30
|
|
|
primaryProps: {
|
|
|
|
text: s__('Labels|Promote Label'),
|
2022-07-23 23:45:48 +05:30
|
|
|
attributes: [{ variant: 'confirm' }],
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
cancelProps: {
|
|
|
|
text: __('Cancel'),
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
components: {
|
2021-01-29 00:20:46 +05:30
|
|
|
GlModal,
|
2020-10-24 23:57:45 +05:30
|
|
|
GlSprintf,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
labelTitle: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
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-04-22 19:07:51 +05:30
|
|
|
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-12-13 13:39:08 +05:30
|
|
|
{
|
2018-05-01 15:08:00 +05:30
|
|
|
labelTitle: this.labelTitle,
|
|
|
|
groupName: this.groupName,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onSubmit() {
|
|
|
|
eventHub.$emit('promoteLabelModal.requestStarted', this.url);
|
|
|
|
return axios
|
|
|
|
.post(this.url, { params: { format: 'json' } })
|
2021-03-08 18:12:59 +05:30
|
|
|
.then((response) => {
|
2018-12-13 13:39:08 +05:30
|
|
|
eventHub.$emit('promoteLabelModal.requestFinished', {
|
|
|
|
labelUrl: this.url,
|
|
|
|
successful: true,
|
|
|
|
});
|
|
|
|
visitUrl(response.data.url);
|
|
|
|
})
|
2021-03-08 18:12:59 +05:30
|
|
|
.catch((error) => {
|
2018-12-13 13:39:08 +05:30
|
|
|
eventHub.$emit('promoteLabelModal.requestFinished', {
|
|
|
|
labelUrl: this.url,
|
|
|
|
successful: false,
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
2022-11-25 23:54:43 +05:30
|
|
|
createAlert({
|
2021-09-04 01:27:46 +05:30
|
|
|
message: error,
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-27 19:54:05 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<gl-modal
|
2021-01-29 00:20:46 +05:30
|
|
|
modal-id="promote-label-modal"
|
|
|
|
:action-primary="$options.primaryProps"
|
|
|
|
:action-cancel="$options.cancelProps"
|
|
|
|
@primary="onSubmit"
|
2018-03-27 19:54:05 +05:30
|
|
|
>
|
2021-09-30 23:02:18 +05:30
|
|
|
<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-10-24 23:57:45 +05:30
|
|
|
>
|
2021-09-30 23:02:18 +05:30
|
|
|
<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-03-27 19:54:05 +05:30
|
|
|
{{ text }}
|
|
|
|
</gl-modal>
|
|
|
|
</template>
|