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:
Diffstat (limited to 'app/assets/javascripts/issue_show/components/app.vue')
-rw-r--r--app/assets/javascripts/issue_show/components/app.vue62
1 files changed, 51 insertions, 11 deletions
diff --git a/app/assets/javascripts/issue_show/components/app.vue b/app/assets/javascripts/issue_show/components/app.vue
index 01b4e81a11a..b7e24a8b17e 100644
--- a/app/assets/javascripts/issue_show/components/app.vue
+++ b/app/assets/javascripts/issue_show/components/app.vue
@@ -1,12 +1,20 @@
<script>
import { GlIcon, GlIntersectionObserver } from '@gitlab/ui';
import Visibility from 'visibilityjs';
-import { deprecatedCreateFlash as createFlash } from '~/flash';
+import createFlash from '~/flash';
import Poll from '~/lib/utils/poll';
import { visitUrl } from '~/lib/utils/url_utility';
import { __, s__, sprintf } from '~/locale';
-import { IssuableStatus, IssuableStatusText, IssuableType } from '../constants';
+import {
+ IssuableStatus,
+ IssuableStatusText,
+ IssuableType,
+ IssueTypePath,
+ IncidentTypePath,
+ IncidentType,
+} from '../constants';
import eventHub from '../event_hub';
+import getIssueStateQuery from '../queries/get_issue_state.query.graphql';
import Service from '../services/index';
import Store from '../stores';
import descriptionComponent from './description.vue';
@@ -195,8 +203,14 @@ export default {
showForm: false,
templatesRequested: false,
isStickyHeaderShowing: false,
+ issueState: {},
};
},
+ apollo: {
+ issueState: {
+ query: getIssueStateQuery,
+ },
+ },
computed: {
issuableTemplates() {
return this.store.formState.issuableTemplates;
@@ -288,7 +302,7 @@ export default {
methods: {
handleBeforeUnloadEvent(e) {
const event = e;
- if (this.showForm && this.issueChanged) {
+ if (this.showForm && this.issueChanged && !this.issueState.isDirty) {
event.returnValue = __('Are you sure you want to lose your issue information?');
}
return undefined;
@@ -302,7 +316,9 @@ export default {
this.store.updateState(data);
})
.catch(() => {
- createFlash(this.defaultErrorMessage);
+ createFlash({
+ message: this.defaultErrorMessage,
+ });
});
},
@@ -327,7 +343,9 @@ export default {
this.updateAndShowForm(res.data);
})
.catch(() => {
- createFlash(this.defaultErrorMessage);
+ createFlash({
+ message: this.defaultErrorMessage,
+ });
this.updateAndShowForm();
});
},
@@ -346,14 +364,32 @@ export default {
},
updateIssuable() {
+ const {
+ store: { formState },
+ issueState,
+ } = this;
+ const issuablePayload = issueState.isDirty
+ ? { ...formState, issue_type: issueState.issueType }
+ : formState;
this.clearFlash();
return this.service
- .updateIssuable(this.store.formState)
+ .updateIssuable(issuablePayload)
.then((res) => res.data)
.then((data) => {
- if (!window.location.pathname.includes(data.web_url)) {
+ if (
+ !window.location.pathname.includes(data.web_url) &&
+ issueState.issueType !== IncidentType
+ ) {
visitUrl(data.web_url);
}
+
+ if (issueState.isDirty) {
+ const URI =
+ issueState.issueType === IncidentType
+ ? data.web_url.replace(IssueTypePath, IncidentTypePath)
+ : data.web_url;
+ visitUrl(URI);
+ }
})
.then(this.updateStoreState)
.then(() => {
@@ -374,7 +410,9 @@ export default {
errMsg += `. ${message}`;
}
- this.flashContainer = createFlash(errMsg);
+ this.flashContainer = createFlash({
+ message: errMsg,
+ });
});
},
@@ -389,9 +427,11 @@ export default {
visitUrl(data.web_url);
})
.catch(() => {
- createFlash(
- sprintf(s__('Error deleting %{issuableType}'), { issuableType: this.issuableType }),
- );
+ createFlash({
+ message: sprintf(s__('Error deleting %{issuableType}'), {
+ issuableType: this.issuableType,
+ }),
+ });
});
},