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

118 lines
3.1 KiB
Vue
Raw Normal View History

2021-01-29 00:20:46 +05:30
<script>
2021-12-11 22:18:48 +05:30
import { GlAlert, GlLink, GlSprintf, GlEmptyState } from '@gitlab/ui';
import { isEmpty } from 'lodash';
2021-04-17 20:07:23 +05:30
import { mapState, mapMutations } from 'vuex';
2021-12-11 22:18:48 +05:30
import { retrieveAlert } from '~/jira_connect/subscriptions/utils';
2021-04-17 20:07:23 +05:30
import { SET_ALERT } from '../store/mutation_types';
2021-04-29 21:17:54 +05:30
import SubscriptionsList from './subscriptions_list.vue';
2021-12-11 22:18:48 +05:30
import AddNamespaceButton from './add_namespace_button.vue';
import SignInButton from './sign_in_button.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,
2021-04-17 20:07:23 +05:30
GlLink,
GlSprintf,
2021-12-11 22:18:48 +05:30
GlEmptyState,
2021-04-29 21:17:54 +05:30
SubscriptionsList,
2021-12-11 22:18:48 +05:30
AddNamespaceButton,
SignInButton,
2021-03-08 18:12:59 +05:30
},
2021-03-11 19:13:27 +05:30
inject: {
usersPath: {
default: '',
},
2021-12-11 22:18:48 +05:30
subscriptions: {
default: [],
},
2021-03-11 19:13:27 +05:30
},
2021-02-22 17:27:13 +05:30
computed: {
2021-04-17 20:07:23 +05:30
...mapState(['alert']),
shouldShowAlert() {
return Boolean(this.alert?.message);
},
2021-12-11 22:18:48 +05:30
hasSubscriptions() {
return !isEmpty(this.subscriptions);
},
userSignedIn() {
return Boolean(!this.usersPath);
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
},
methods: {
2021-04-17 20:07:23 +05:30
...mapMutations({
setAlert: SET_ALERT,
}),
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-12-11 22:18:48 +05:30
<h2 class="gl-text-center gl-mb-7">{{ s__('JiraService|GitLab for Jira Configuration') }}</h2>
<div class="jira-connect-app-body gl-mx-auto gl-px-5 gl-mb-7">
<template v-if="hasSubscriptions">
<div class="gl-display-flex gl-justify-content-end">
<sign-in-button v-if="!userSignedIn" :users-path="usersPath" />
<add-namespace-button v-else />
</div>
2021-03-08 18:12:59 +05:30
2021-12-11 22:18:48 +05:30
<subscriptions-list />
</template>
<template v-else>
<div v-if="!userSignedIn" class="gl-text-center">
<p class="gl-mb-7">{{ s__('JiraService|Sign in to GitLab.com to get started.') }}</p>
<sign-in-button class="gl-mb-7" :users-path="usersPath">
{{ __('Sign in to GitLab') }}
</sign-in-button>
<p>
{{
s__(
'Integrations|Note: this integration only works with accounts on GitLab.com (SaaS).',
)
}}
</p>
</div>
<gl-empty-state
v-else
:title="s__('Integrations|No linked namespaces')"
:description="
s__(
'Integrations|Namespaces are the GitLab groups and subgroups you link to this Jira instance.',
)
"
2021-03-11 19:13:27 +05:30
>
2021-12-11 22:18:48 +05:30
<template #actions>
<add-namespace-button />
</template>
</gl-empty-state>
</template>
2021-03-08 18:12:59 +05:30
</div>
</div>
2021-01-29 00:20:46 +05:30
</template>