diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-27 09:13:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-27 09:13:06 +0300 |
commit | 3fbe43541ef99c27a9e4ab9c545ec0eb9bb50a9e (patch) | |
tree | df71ce391f93b65a4f44fa719c8def2b9e45d40f /app/assets/javascripts/jira_connect | |
parent | 0e1350d51ca2135e37743dfb7af98eae43c72892 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jira_connect')
15 files changed, 28 insertions, 178 deletions
diff --git a/app/assets/javascripts/jira_connect/subscriptions/api.js b/app/assets/javascripts/jira_connect/subscriptions/api.js index 8c5dc88f183..184635e63f3 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/api.js +++ b/app/assets/javascripts/jira_connect/subscriptions/api.js @@ -16,15 +16,6 @@ export const setApiBaseURL = (baseURL = null) => { axiosInstance.defaults.baseURL = baseURL; }; -export const addSubscription = async (addPath, namespace) => { - const jwt = await getJwt(); - - return axiosInstance.post(addPath, { - jwt, - namespace_path: namespace, - }); -}; - export const removeSubscription = async (removePath) => { const jwt = await getJwt(); diff --git a/app/assets/javascripts/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item.vue b/app/assets/javascripts/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item.vue index d918559a49f..cd0f4c2f66f 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item.vue @@ -1,27 +1,15 @@ <script> import { mapActions } from 'vuex'; import { GlButton } from '@gitlab/ui'; -import { addSubscription } from '~/jira_connect/subscriptions/api'; -import { persistAlert, reloadPage } from '~/jira_connect/subscriptions/utils'; -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import GroupItemName from '../group_item_name.vue'; -import { - INTEGRATIONS_DOC_LINK, - I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE, - I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE, - I18N_ADD_SUBSCRIPTIONS_ERROR_MESSAGE, -} from '../../constants'; +import { I18N_ADD_SUBSCRIPTIONS_ERROR_MESSAGE } from '../../constants'; export default { components: { GlButton, GroupItemName, }, - mixins: [glFeatureFlagMixin()], inject: { - addSubscriptionsPath: { - default: '', - }, subscriptionsPath: { default: '', }, @@ -46,30 +34,15 @@ export default { ...mapActions(['addSubscription']), async onClick() { this.isLoading = true; - await this.addSubscription({ - namespacePath: this.group.full_path, - subscriptionsPath: this.subscriptionsPath, - }); - this.isLoading = false; - }, - deprecatedAddSubscription() { - this.isLoading = true; - - addSubscription(this.addSubscriptionsPath, this.group.full_path) - .then(() => { - persistAlert({ - title: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE, - message: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE, - linkUrl: INTEGRATIONS_DOC_LINK, - variant: 'success', - }); - - reloadPage(); - }) - .catch((error) => { - this.$emit('error', error?.response?.data?.error || I18N_ADD_SUBSCRIPTIONS_ERROR_MESSAGE); - this.isLoading = false; + try { + await this.addSubscription({ + namespacePath: this.group.full_path, + subscriptionsPath: this.subscriptionsPath, }); + } catch (error) { + this.$emit('error', error?.response?.data?.error || I18N_ADD_SUBSCRIPTIONS_ERROR_MESSAGE); + } + this.isLoading = false; }, }, }; diff --git a/app/assets/javascripts/jira_connect/subscriptions/components/app.vue b/app/assets/javascripts/jira_connect/subscriptions/components/app.vue index 1dc3f76b253..15e61ff1cd9 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/components/app.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/components/app.vue @@ -4,7 +4,6 @@ import { isEmpty } from 'lodash'; import { mapState, mapMutations, mapActions } from 'vuex'; import { retrieveAlert } from '~/jira_connect/subscriptions/utils'; import AccessorUtilities from '~/lib/utils/accessor'; -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { I18N_DEFAULT_SIGN_IN_ERROR_MESSAGE } from '../constants'; import { SET_ALERT } from '../store/mutation_types'; import SignInPage from '../pages/sign_in/sign_in_page.vue'; @@ -23,11 +22,7 @@ export default { SubscriptionsPage, UserLink, }, - mixins: [glFeatureFlagMixin()], inject: { - usersPath: { - default: '', - }, subscriptionsPath: { default: '', }, diff --git a/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_legacy_button.vue b/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_legacy_button.vue deleted file mode 100644 index ec718d5b3ca..00000000000 --- a/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_legacy_button.vue +++ /dev/null @@ -1,40 +0,0 @@ -<script> -import { GlButton } from '@gitlab/ui'; -import { getGitlabSignInURL } from '~/jira_connect/subscriptions/utils'; -import { I18N_DEFAULT_SIGN_IN_BUTTON_TEXT } from '~/jira_connect/subscriptions/constants'; - -export default { - components: { - GlButton, - }, - props: { - usersPath: { - type: String, - required: true, - }, - }, - data() { - return { - signInURL: '', - }; - }, - created() { - this.setSignInURL(); - }, - methods: { - async setSignInURL() { - this.signInURL = await getGitlabSignInURL(this.usersPath); - }, - }, - i18n: { - defaultButtonText: I18N_DEFAULT_SIGN_IN_BUTTON_TEXT, - }, -}; -</script> -<template> - <gl-button category="primary" variant="info" :href="signInURL" target="_blank"> - <slot> - {{ $options.i18n.defaultButtonText }} - </slot> - </gl-button> -</template> diff --git a/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_oauth_button.vue b/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_oauth_button.vue index 65c69bcfa82..bc8cdf35701 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_oauth_button.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/components/sign_in_oauth_button.vue @@ -12,6 +12,7 @@ import { I18N_OAUTH_FAILED_MESSAGE, OAUTH_SELF_MANAGED_DOC_LINK, OAUTH_WINDOW_OPTIONS, + OAUTH_CALLBACK_MESSAGE_TYPE, PKCE_CODE_CHALLENGE_DIGEST_ALGORITHM, } from '~/jira_connect/subscriptions/constants'; import { fetchOAuthApplicationId, fetchOAuthToken } from '~/jira_connect/subscriptions/api'; @@ -130,6 +131,11 @@ export default { } }, async handleWindowMessage(event) { + // Make sure this ia a message from the OAuth flow in pages/jira_connect/oauth_callbacks/index.js + if (event.data?.type !== OAUTH_CALLBACK_MESSAGE_TYPE) { + return; + } + if (window.origin !== event.origin) { this.loading = false; return; diff --git a/app/assets/javascripts/jira_connect/subscriptions/components/user_link.vue b/app/assets/javascripts/jira_connect/subscriptions/components/user_link.vue index 9e1203f21d2..d05e0d8610e 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/components/user_link.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/components/user_link.vue @@ -1,8 +1,6 @@ <script> import { GlLink, GlSprintf } from '@gitlab/ui'; -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { __ } from '~/locale'; -import { getGitlabSignInURL } from '~/jira_connect/subscriptions/utils'; export default { components: { @@ -10,11 +8,7 @@ export default { GlSprintf, SignInOauthButton: () => import('./sign_in_oauth_button.vue'), }, - mixins: [glFeatureFlagMixin()], inject: { - usersPath: { - default: '', - }, gitlabUserPath: { default: '', }, @@ -34,11 +28,6 @@ export default { default: null, }, }, - data() { - return { - signInURL: '', - }; - }, computed: { gitlabUserName() { return gon.current_username ?? this.user?.username; @@ -55,9 +44,6 @@ export default { : this.$options.i18n.signedInText; }, }, - async created() { - this.signInURL = await getGitlabSignInURL(this.usersPath); - }, i18n: { signInText: __('Sign in to GitLab'), signedInAsUserText: __('Signed in to GitLab as %{user_link}'), diff --git a/app/assets/javascripts/jira_connect/subscriptions/constants.js b/app/assets/javascripts/jira_connect/subscriptions/constants.js index bb22a4ef252..321d10205e6 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/constants.js +++ b/app/assets/javascripts/jira_connect/subscriptions/constants.js @@ -54,6 +54,8 @@ export const OAUTH_WINDOW_OPTIONS = [ `top=${window.screen.height / 2 - OAUTH_WINDOW_SIZE / 2}`, ].join(','); +export const OAUTH_CALLBACK_MESSAGE_TYPE = 'jiraConnectOauthCallback'; + export const PKCE_CODE_CHALLENGE_DIGEST_ALGORITHM = { long: 'SHA-256', short: 'S256', diff --git a/app/assets/javascripts/jira_connect/subscriptions/index.js b/app/assets/javascripts/jira_connect/subscriptions/index.js index 21ff85e58e2..8854157054d 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/index.js +++ b/app/assets/javascripts/jira_connect/subscriptions/index.js @@ -2,7 +2,6 @@ import '~/webpack'; import setConfigs from '@gitlab/ui/dist/config'; import Vue from 'vue'; -import GlFeatureFlagsPlugin from '~/vue_shared/gl_feature_flags_plugin'; import Translate from '~/vue_shared/translate'; import JiraConnectApp from './components/app.vue'; @@ -17,14 +16,11 @@ export function initJiraConnect() { setConfigs(); Vue.use(Translate); - Vue.use(GlFeatureFlagsPlugin); const { groupsPath, subscriptions, - addSubscriptionsPath, subscriptionsPath, - usersPath, gitlabUserPath, oauthMetadata, publicKeyStorageEnabled, @@ -38,9 +34,7 @@ export function initJiraConnect() { store, provide: { groupsPath, - addSubscriptionsPath, subscriptionsPath, - usersPath, gitlabUserPath, oauthMetadata: oauthMetadata ? JSON.parse(oauthMetadata) : null, publicKeyStorageEnabled, diff --git a/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com.vue b/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com.vue index 8a3a1768d5e..113ce34fdcd 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com.vue @@ -2,7 +2,6 @@ import { s__ } from '~/locale'; import { GITLAB_COM_BASE_PATH } from '~/jira_connect/subscriptions/constants'; -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import SubscriptionsList from '../../components/subscriptions_list.vue'; export default { @@ -11,8 +10,6 @@ export default { SubscriptionsList, SignInOauthButton: () => import('../../components/sign_in_oauth_button.vue'), }, - mixins: [glFeatureFlagMixin()], - inject: ['usersPath'], props: { hasSubscriptions: { type: Boolean, diff --git a/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_page.vue b/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_page.vue index 97ac88a03e9..ee20e21011f 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_page.vue +++ b/app/assets/javascripts/jira_connect/subscriptions/pages/sign_in/sign_in_page.vue @@ -1,12 +1,10 @@ <script> -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import SignInGitlabCom from './sign_in_gitlab_com.vue'; import SignInGitlabMultiversion from './sign_in_gitlab_multiversion/index.vue'; export default { name: 'SignInPage', components: { SignInGitlabCom, SignInGitlabMultiversion }, - mixins: [glFeatureFlagMixin()], props: { hasSubscriptions: { type: Boolean, diff --git a/app/assets/javascripts/jira_connect/subscriptions/store/actions.js b/app/assets/javascripts/jira_connect/subscriptions/store/actions.js index fff34e1d75d..3b8e4c7540b 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/store/actions.js +++ b/app/assets/javascripts/jira_connect/subscriptions/store/actions.js @@ -14,8 +14,6 @@ import { SET_SUBSCRIPTIONS, SET_SUBSCRIPTIONS_LOADING, SET_SUBSCRIPTIONS_ERROR, - ADD_SUBSCRIPTION_LOADING, - ADD_SUBSCRIPTION_ERROR, SET_ALERT, SET_CURRENT_USER, SET_CURRENT_USER_ERROR, @@ -51,25 +49,17 @@ export const addSubscription = async ( { commit, state, dispatch }, { namespacePath, subscriptionsPath }, ) => { - try { - commit(ADD_SUBSCRIPTION_LOADING, true); - - await addJiraConnectSubscription(namespacePath, { - jwt: await getJwt(), - accessToken: state.accessToken, - }); + await addJiraConnectSubscription(namespacePath, { + jwt: await getJwt(), + accessToken: state.accessToken, + }); - commit(SET_ALERT, { - title: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE, - message: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE, - linkUrl: INTEGRATIONS_DOC_LINK, - variant: 'success', - }); + commit(SET_ALERT, { + title: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE, + message: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE, + linkUrl: INTEGRATIONS_DOC_LINK, + variant: 'success', + }); - dispatch('fetchSubscriptions', subscriptionsPath); - } catch (e) { - commit(ADD_SUBSCRIPTION_ERROR, e); - } finally { - commit(ADD_SUBSCRIPTION_LOADING, false); - } + dispatch('fetchSubscriptions', subscriptionsPath); }; diff --git a/app/assets/javascripts/jira_connect/subscriptions/store/mutation_types.js b/app/assets/javascripts/jira_connect/subscriptions/store/mutation_types.js index d4893fbcaf6..63aad27aeb6 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/store/mutation_types.js +++ b/app/assets/javascripts/jira_connect/subscriptions/store/mutation_types.js @@ -4,9 +4,6 @@ export const SET_SUBSCRIPTIONS = 'SET_SUBSCRIPTIONS'; export const SET_SUBSCRIPTIONS_LOADING = 'SET_SUBSCRIPTIONS_LOADING'; export const SET_SUBSCRIPTIONS_ERROR = 'SET_SUBSCRIPTIONS_ERROR'; -export const ADD_SUBSCRIPTION_LOADING = 'ADD_SUBSCRIPTION_LOADING'; -export const ADD_SUBSCRIPTION_ERROR = 'ADD_SUBSCRIPTION_ERROR'; - export const SET_CURRENT_USER = 'SET_CURRENT_USER'; export const SET_CURRENT_USER_ERROR = 'SET_CURRENT_USER_ERROR'; diff --git a/app/assets/javascripts/jira_connect/subscriptions/store/mutations.js b/app/assets/javascripts/jira_connect/subscriptions/store/mutations.js index 60076c918fd..270ce9fab66 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/store/mutations.js +++ b/app/assets/javascripts/jira_connect/subscriptions/store/mutations.js @@ -3,8 +3,6 @@ import { SET_SUBSCRIPTIONS, SET_SUBSCRIPTIONS_LOADING, SET_SUBSCRIPTIONS_ERROR, - ADD_SUBSCRIPTION_LOADING, - ADD_SUBSCRIPTION_ERROR, SET_CURRENT_USER, SET_CURRENT_USER_ERROR, SET_ACCESS_TOKEN, @@ -25,13 +23,6 @@ export default { state.subscriptionsError = subscriptionsError; }, - [ADD_SUBSCRIPTION_LOADING](state, loading) { - state.addSubscriptionLoading = loading; - }, - [ADD_SUBSCRIPTION_ERROR](state, error) { - state.addSubscriptionError = error; - }, - [SET_CURRENT_USER](state, currentUser) { state.currentUser = currentUser; }, diff --git a/app/assets/javascripts/jira_connect/subscriptions/store/state.js b/app/assets/javascripts/jira_connect/subscriptions/store/state.js index 82a8517b511..f35f79e3f53 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/store/state.js +++ b/app/assets/javascripts/jira_connect/subscriptions/store/state.js @@ -10,9 +10,6 @@ export default function createState({ subscriptionsLoading, subscriptionsError: false, - addSubscriptionLoading: false, - addSubscriptionError: false, - currentUser, currentUserError: null, diff --git a/app/assets/javascripts/jira_connect/subscriptions/utils.js b/app/assets/javascripts/jira_connect/subscriptions/utils.js index 6db8b62d692..0b88e83f8da 100644 --- a/app/assets/javascripts/jira_connect/subscriptions/utils.js +++ b/app/assets/javascripts/jira_connect/subscriptions/utils.js @@ -1,5 +1,4 @@ import AccessorUtilities from '~/lib/utils/accessor'; -import { objectToQuery } from '~/lib/utils/url_utility'; import { ALERT_LOCALSTORAGE_KEY, BASE_URL_LOCALSTORAGE_KEY } from './constants'; const isFunction = (fn) => typeof fn === 'function'; @@ -76,18 +75,6 @@ export const getJwt = () => { }); }; -export const getLocation = () => { - return new Promise((resolve) => { - if (isFunction(AP?.getLocation)) { - AP.getLocation((location) => { - resolve(location); - }); - } else { - resolve(); - } - }); -}; - export const reloadPage = () => { if (isFunction(AP?.navigator?.reload)) { AP.navigator.reload(); @@ -101,17 +88,3 @@ export const sizeToParent = () => { AP.sizeToParent(); } }; - -export const getGitlabSignInURL = async (signInURL) => { - const location = await getLocation(); - - if (location) { - const queryParams = { - return_to: location, - }; - - return `${signInURL}?${objectToQuery(queryParams)}`; - } - - return signInURL; -}; |