Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-17 18:10:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-17 18:10:09 +0300
commit073ebdcae8630bbcc849f7cfb4c27fd81bef99a5 (patch)
tree0d73076a9fa08b46b19a3220401bc6c1be1a1cb5 /app/assets/javascripts/jira_import
parent4203215d542505bba491a01d637479934c8005d6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jira_import')
-rw-r--r--app/assets/javascripts/jira_import/components/jira_import_app.vue75
-rw-r--r--app/assets/javascripts/jira_import/components/jira_import_form.vue77
2 files changed, 71 insertions, 81 deletions
diff --git a/app/assets/javascripts/jira_import/components/jira_import_app.vue b/app/assets/javascripts/jira_import/components/jira_import_app.vue
index a1b1fec9c8b..0f690d17da9 100644
--- a/app/assets/javascripts/jira_import/components/jira_import_app.vue
+++ b/app/assets/javascripts/jira_import/components/jira_import_app.vue
@@ -1,11 +1,7 @@
<script>
import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
import { last } from 'lodash';
-import { __ } from '~/locale';
import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql';
-import getJiraUserMappingMutation from '../queries/get_jira_user_mapping.mutation.graphql';
-import initiateJiraImportMutation from '../queries/initiate_jira_import.mutation.graphql';
-import { addInProgressImportToStore } from '../utils/cache_update';
import { isInProgress, extractJiraProjectsOptions } from '../utils/jira_import_utils';
import JiraImportForm from './jira_import_form.vue';
import JiraImportProgress from './jira_import_progress.vue';
@@ -52,9 +48,7 @@ export default {
},
data() {
return {
- isSubmitting: false,
jiraImportDetails: {},
- userMappings: [],
errorMessage: '',
showAlert: false,
};
@@ -78,70 +72,7 @@ export default {
},
},
},
- mounted() {
- if (this.isJiraConfigured) {
- this.$apollo
- .mutate({
- mutation: getJiraUserMappingMutation,
- variables: {
- input: {
- projectPath: this.projectPath,
- },
- },
- })
- .then(({ data }) => {
- if (data.jiraImportUsers.errors.length) {
- this.setAlertMessage(data.jiraImportUsers.errors.join('. '));
- } else {
- this.userMappings = data.jiraImportUsers.jiraUsers;
- }
- })
- .catch(() => this.setAlertMessage(__('There was an error retrieving the Jira users.')));
- }
- },
methods: {
- initiateJiraImport(project) {
- this.isSubmitting = true;
-
- this.$apollo
- .mutate({
- mutation: initiateJiraImportMutation,
- variables: {
- input: {
- jiraProjectKey: project,
- projectPath: this.projectPath,
- usersMapping: this.userMappings.map(({ gitlabId, jiraAccountId }) => ({
- gitlabId,
- jiraAccountId,
- })),
- },
- },
- update: (store, { data }) =>
- addInProgressImportToStore(store, data.jiraImportStart, this.projectPath),
- })
- .then(({ data }) => {
- if (data.jiraImportStart.errors.length) {
- this.setAlertMessage(data.jiraImportStart.errors.join('. '));
- } else {
- this.selectedProject = undefined;
- }
- })
- .catch(() => this.setAlertMessage(__('There was an error importing the Jira project.')))
- .finally(() => {
- this.isSubmitting = false;
- });
- },
- updateMapping(jiraAccountId, gitlabId, gitlabUsername) {
- this.userMappings = this.userMappings.map(userMapping =>
- userMapping.jiraAccountId === jiraAccountId
- ? {
- ...userMapping,
- gitlabId,
- gitlabUsername,
- }
- : userMapping,
- );
- },
setAlertMessage(message) {
this.errorMessage = message;
this.showAlert = true;
@@ -175,14 +106,12 @@ export default {
/>
<jira-import-form
v-else
- :is-submitting="isSubmitting"
:issues-path="issuesPath"
:jira-imports="jiraImportDetails.imports"
:jira-projects="jiraImportDetails.projects"
:project-id="projectId"
- :user-mappings="userMappings"
- @initiateJiraImport="initiateJiraImport"
- @updateMapping="updateMapping"
+ :project-path="projectPath"
+ @error="setAlertMessage"
/>
</div>
</template>
diff --git a/app/assets/javascripts/jira_import/components/jira_import_form.vue b/app/assets/javascripts/jira_import/components/jira_import_form.vue
index db3b295642a..b5d17398f3a 100644
--- a/app/assets/javascripts/jira_import/components/jira_import_form.vue
+++ b/app/assets/javascripts/jira_import/components/jira_import_form.vue
@@ -16,6 +16,10 @@ import {
} from '@gitlab/ui';
import { debounce } from 'lodash';
import axios from '~/lib/utils/axios_utils';
+import { __ } from '~/locale';
+import getJiraUserMappingMutation from '../queries/get_jira_user_mapping.mutation.graphql';
+import initiateJiraImportMutation from '../queries/initiate_jira_import.mutation.graphql';
+import { addInProgressImportToStore } from '../utils/cache_update';
import {
debounceWait,
dropdownLabel,
@@ -47,10 +51,6 @@ export default {
tableConfig,
userMappingMessage,
props: {
- isSubmitting: {
- type: Boolean,
- required: true,
- },
issuesPath: {
type: String,
required: true,
@@ -67,17 +67,19 @@ export default {
type: String,
required: true,
},
- userMappings: {
- type: Array,
+ projectPath: {
+ type: String,
required: true,
},
},
data() {
return {
isFetching: false,
+ isSubmitting: false,
searchTerm: '',
selectedProject: undefined,
selectState: null,
+ userMappings: [],
users: [],
};
},
@@ -106,6 +108,24 @@ export default {
}, debounceWait),
},
mounted() {
+ this.$apollo
+ .mutate({
+ mutation: getJiraUserMappingMutation,
+ variables: {
+ input: {
+ projectPath: this.projectPath,
+ },
+ },
+ })
+ .then(({ data }) => {
+ if (data.jiraImportUsers.errors.length) {
+ this.$emit('error', data.jiraImportUsers.errors.join('. '));
+ } else {
+ this.userMappings = data.jiraImportUsers.jiraUsers;
+ }
+ })
+ .catch(() => this.$emit('error', __('There was an error retrieving the Jira users.')));
+
this.searchUsers()
.then(data => {
this.initialUsers = data;
@@ -138,13 +158,54 @@ export default {
},
initiateJiraImport(event) {
event.preventDefault();
+
if (this.selectedProject) {
this.hideValidationError();
- this.$emit('initiateJiraImport', this.selectedProject);
+
+ this.isSubmitting = true;
+
+ this.$apollo
+ .mutate({
+ mutation: initiateJiraImportMutation,
+ variables: {
+ input: {
+ jiraProjectKey: this.selectedProject,
+ projectPath: this.projectPath,
+ usersMapping: this.userMappings.map(({ gitlabId, jiraAccountId }) => ({
+ gitlabId,
+ jiraAccountId,
+ })),
+ },
+ },
+ update: (store, { data }) =>
+ addInProgressImportToStore(store, data.jiraImportStart, this.projectPath),
+ })
+ .then(({ data }) => {
+ if (data.jiraImportStart.errors.length) {
+ this.$emit('error', data.jiraImportStart.errors.join('. '));
+ } else {
+ this.selectedProject = undefined;
+ }
+ })
+ .catch(() => this.$emit('error', __('There was an error importing the Jira project.')))
+ .finally(() => {
+ this.isSubmitting = false;
+ });
} else {
this.showValidationError();
}
},
+ updateMapping(jiraAccountId, gitlabId, gitlabUsername) {
+ this.userMappings = this.userMappings.map(userMapping =>
+ userMapping.jiraAccountId === jiraAccountId
+ ? {
+ ...userMapping,
+ gitlabId,
+ gitlabUsername,
+ }
+ : userMapping,
+ );
+ },
hideValidationError() {
this.selectState = null;
},
@@ -227,7 +288,7 @@ export default {
v-for="user in users"
v-else
:key="user.id"
- @click="$emit('updateMapping', data.item.jiraAccountId, user.id, user.username)"
+ @click="updateMapping(data.item.jiraAccountId, user.id, user.username)"
>
{{ user.username }} ({{ user.name }})
</gl-new-dropdown-item>