debian-mirror-gitlab/app/assets/javascripts/jira_connect/subscriptions/components/app.vue

126 lines
3 KiB
Vue
Raw Normal View History

2021-01-29 00:20:46 +05:30
<script>
2021-04-29 21:17:54 +05:30
import { GlAlert, GlButton, GlLink, GlModal, GlModalDirective, GlSprintf } from '@gitlab/ui';
2021-04-17 20:07:23 +05:30
import { mapState, mapMutations } from 'vuex';
2021-10-27 15:23:28 +05:30
import { retrieveAlert, getLocation } from '~/jira_connect/subscriptions/utils';
2021-03-08 18:12:59 +05:30
import { __ } from '~/locale';
2021-04-17 20:07:23 +05:30
import { SET_ALERT } from '../store/mutation_types';
2021-03-08 18:12:59 +05:30
import GroupsList from './groups_list.vue';
2021-04-29 21:17:54 +05:30
import SubscriptionsList from './subscriptions_list.vue';
2021-03-08 18:12:59 +05:30
2021-02-22 17:27:13 +05:30
export default {
name: 'JiraConnectApp',
2021-03-08 18:12:59 +05:30
components: {
GlAlert,
GlButton,
2021-04-17 20:07:23 +05:30
GlLink,
2021-04-29 21:17:54 +05:30
GlModal,
2021-04-17 20:07:23 +05:30
GlSprintf,
2021-04-29 21:17:54 +05:30
GroupsList,
SubscriptionsList,
2021-03-08 18:12:59 +05:30
},
directives: {
GlModalDirective,
},
2021-03-11 19:13:27 +05:30
inject: {
usersPath: {
default: '',
},
},
data() {
return {
location: '',
};
},
2021-02-22 17:27:13 +05:30
computed: {
2021-04-17 20:07:23 +05:30
...mapState(['alert']),
2021-03-11 19:13:27 +05:30
usersPathWithReturnTo() {
if (this.location) {
return `${this.usersPath}?return_to=${this.location}`;
}
return this.usersPath;
},
2021-04-17 20:07:23 +05:30
shouldShowAlert() {
return Boolean(this.alert?.message);
},
2021-03-08 18:12:59 +05:30
},
modal: {
cancelProps: {
text: __('Cancel'),
2021-02-22 17:27:13 +05:30
},
},
2021-03-11 19:13:27 +05:30
created() {
2021-04-17 20:07:23 +05:30
this.setInitialAlert();
2021-03-11 19:13:27 +05:30
this.setLocation();
},
methods: {
2021-04-17 20:07:23 +05:30
...mapMutations({
setAlert: SET_ALERT,
}),
2021-03-11 19:13:27 +05:30
async setLocation() {
this.location = await getLocation();
},
2021-04-17 20:07:23 +05:30
setInitialAlert() {
const { linkUrl, title, message, variant } = retrieveAlert() || {};
this.setAlert({ linkUrl, title, message, variant });
},
2021-03-11 19:13:27 +05:30
},
2021-02-22 17:27:13 +05:30
};
2021-01-29 00:20:46 +05:30
</script>
2021-03-08 18:12:59 +05:30
2021-01-29 00:20:46 +05:30
<template>
2021-03-08 18:12:59 +05:30
<div>
2021-04-17 20:07:23 +05:30
<gl-alert
v-if="shouldShowAlert"
class="gl-mb-7"
:variant="alert.variant"
:title="alert.title"
@dismiss="setAlert"
>
<gl-sprintf v-if="alert.linkUrl" :message="alert.message">
<template #link="{ content }">
<gl-link :href="alert.linkUrl" target="_blank">{{ content }}</gl-link>
</template>
</gl-sprintf>
<template v-else>
{{ alert.message }}
</template>
2021-03-08 18:12:59 +05:30
</gl-alert>
2021-04-17 20:07:23 +05:30
<h2 class="gl-text-center">{{ s__('JiraService|GitLab for Jira Configuration') }}</h2>
2021-03-08 18:12:59 +05:30
2021-04-29 21:17:54 +05:30
<div class="jira-connect-app-body gl-my-7 gl-px-5 gl-pb-4">
<div class="gl-display-flex gl-justify-content-end">
2021-03-11 19:13:27 +05:30
<gl-button
2021-04-29 21:17:54 +05:30
v-if="usersPath"
2021-03-11 19:13:27 +05:30
category="primary"
variant="info"
class="gl-align-self-center"
2021-04-29 21:17:54 +05:30
:href="usersPathWithReturnTo"
target="_blank"
>{{ s__('Integrations|Sign in to add namespaces') }}</gl-button
2021-03-11 19:13:27 +05:30
>
2021-04-29 21:17:54 +05:30
<template v-else>
<gl-button
v-gl-modal-directive="'add-namespace-modal'"
category="primary"
variant="info"
class="gl-align-self-center"
>{{ s__('Integrations|Add namespace') }}</gl-button
>
<gl-modal
modal-id="add-namespace-modal"
:title="s__('Integrations|Link namespaces')"
:action-cancel="$options.modal.cancelProps"
>
<groups-list />
</gl-modal>
</template>
</div>
<subscriptions-list />
2021-03-08 18:12:59 +05:30
</div>
</div>
2021-01-29 00:20:46 +05:30
</template>