diff options
author | Phil Hughes <me@iamphill.com> | 2018-06-04 14:11:00 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-06-06 13:19:27 +0300 |
commit | ce2bc5c0a8021e876308b4990bc17f95aad90387 (patch) | |
tree | c7a63044cac9746c5c6564dc593ccb52df32e862 /app/assets/javascripts | |
parent | 03820e9b03fb25c94263231aaee30fec0b6468f4 (diff) |
correctly load up merge request
fixed pipeline request throwing an error
Diffstat (limited to 'app/assets/javascripts')
13 files changed, 75 insertions, 33 deletions
diff --git a/app/assets/javascripts/ide/components/ide_review.vue b/app/assets/javascripts/ide/components/ide_review.vue index 0c9ec3b00f0..ec2af50283a 100644 --- a/app/assets/javascripts/ide/components/ide_review.vue +++ b/app/assets/javascripts/ide/components/ide_review.vue @@ -11,17 +11,17 @@ export default { }, computed: { ...mapGetters(['currentMergeRequest']), - ...mapState(['viewer']), + ...mapState(['viewer', 'currentMergeRequestId']), showLatestChangesText() { - return !this.currentMergeRequest || this.viewer === viewerTypes.diff; + return !this.currentMergeRequestId || this.viewer === viewerTypes.diff; }, showMergeRequestText() { - return this.currentMergeRequest && this.viewer === viewerTypes.mr; + return this.currentMergeRequestId && this.viewer === viewerTypes.mr; }, }, mounted() { this.$nextTick(() => { - this.updateViewer(this.currentMergeRequest ? viewerTypes.mr : viewerTypes.diff); + this.updateViewer(this.currentMergeRequestId ? viewerTypes.mr : viewerTypes.diff); }); }, methods: { @@ -54,7 +54,10 @@ export default { </template> <template v-else-if="showMergeRequestText"> {{ __('Merge request') }} - (<a :href="currentMergeRequest.web_url">!{{ currentMergeRequest.iid }}</a>) + (<a + v-if="currentMergeRequest" + :href="currentMergeRequest.web_url" + >!{{ currentMergeRequest.iid }}</a>) </template> </div> </template> diff --git a/app/assets/javascripts/ide/components/ide_side_bar.vue b/app/assets/javascripts/ide/components/ide_side_bar.vue index 631c995b59e..fdf191b3352 100644 --- a/app/assets/javascripts/ide/components/ide_side_bar.vue +++ b/app/assets/javascripts/ide/components/ide_side_bar.vue @@ -65,6 +65,8 @@ export default { watch: { currentBranchId() { this.$nextTick(() => { + if (!this.$refs.branchId) return; + this.showTooltip = this.$refs.branchId.scrollWidth > this.$refs.branchId.offsetWidth; }); }, @@ -145,6 +147,7 @@ export default { </div> <div class="d-flex"> <div + v-if="currentBranchId" class="sidebar-context-title ide-sidebar-branch-title" ref="branchId" v-tooltip @@ -157,7 +160,10 @@ export default { </div> <div v-if="currentMergeRequestId" - class="sidebar-context-title ide-sidebar-branch-title prepend-left-8" + class="sidebar-context-title ide-sidebar-branch-title" + :class="{ + 'prepend-left-8': currentBranchId + }" > <icon name="git-merge" diff --git a/app/assets/javascripts/ide/components/ide_status_bar.vue b/app/assets/javascripts/ide/components/ide_status_bar.vue index 368a2995ed9..e40f137d998 100644 --- a/app/assets/javascripts/ide/components/ide_status_bar.vue +++ b/app/assets/javascripts/ide/components/ide_status_bar.vue @@ -35,9 +35,7 @@ export default { }, watch: { lastCommit() { - if (!this.isPollingInitialized) { - this.initPipelinePolling(); - } + this.initPipelinePolling(); }, }, mounted() { @@ -47,9 +45,8 @@ export default { if (this.intervalId) { clearInterval(this.intervalId); } - if (this.isPollingInitialized) { - this.stopPipelinePolling(); - } + + this.stopPipelinePolling(); }, methods: { ...mapActions('pipelines', ['fetchLatestPipeline', 'stopPipelinePolling']), @@ -59,8 +56,9 @@ export default { }, 1000); }, initPipelinePolling() { - this.fetchLatestPipeline(); - this.isPollingInitialized = true; + if (this.lastCommit) { + this.fetchLatestPipeline(); + } }, commitAgeUpdate() { if (this.lastCommit) { diff --git a/app/assets/javascripts/ide/components/merge_requests/dropdown.vue b/app/assets/javascripts/ide/components/merge_requests/dropdown.vue index 86186b48854..cfc075d48d8 100644 --- a/app/assets/javascripts/ide/components/merge_requests/dropdown.vue +++ b/app/assets/javascripts/ide/components/merge_requests/dropdown.vue @@ -12,7 +12,6 @@ export default { }, computed: { ...mapGetters('mergeRequests', ['assignedData', 'createdData']), - ...mapState(['currentMergeRequestId']), createdMergeRequestLength() { return this.createdData.mergeRequests.length; }, @@ -37,7 +36,6 @@ export default { </template> <list type="created" - :current-id="currentMergeRequestId" :empty-text="__('You have not created any merge requests')" @hide="hideDropdown" /> @@ -51,7 +49,6 @@ export default { </template> <list type="assigned" - :current-id="currentMergeRequestId" :empty-text="__('You do not have any assigned merge requests')" @hide="hideDropdown" /> diff --git a/app/assets/javascripts/ide/components/merge_requests/item.vue b/app/assets/javascripts/ide/components/merge_requests/item.vue index 11eb5c8b31b..677ceab8075 100644 --- a/app/assets/javascripts/ide/components/merge_requests/item.vue +++ b/app/assets/javascripts/ide/components/merge_requests/item.vue @@ -14,10 +14,17 @@ export default { type: String, required: true, }, + currentProjectId: { + type: String, + required: true, + }, }, computed: { isActive() { - return this.item.iid === parseInt(this.currentId, 10); + return ( + this.item.iid === parseInt(this.currentId, 10) && + this.currentProjectId === this.item.projectPathWithNamespace + ); }, pathWithID() { return `${this.item.projectPathWithNamespace}!${this.item.iid}`; @@ -35,7 +42,7 @@ export default { <button type="button" class="d-flex align-items-center" - @click="clickItem" + @click.prevent.stop="clickItem" > <span class="d-flex append-right-default" diff --git a/app/assets/javascripts/ide/components/merge_requests/list.vue b/app/assets/javascripts/ide/components/merge_requests/list.vue index 829fe219603..b661545a714 100644 --- a/app/assets/javascripts/ide/components/merge_requests/list.vue +++ b/app/assets/javascripts/ide/components/merge_requests/list.vue @@ -1,5 +1,5 @@ <script> -import { mapActions, mapGetters } from 'vuex'; +import { mapActions, mapGetters, mapState } from 'vuex'; import _ from 'underscore'; import LoadingIcon from '../../../vue_shared/components/loading_icon.vue'; import Item from './item.vue'; @@ -14,10 +14,6 @@ export default { type: String, required: true, }, - currentId: { - type: String, - required: true, - }, emptyText: { type: String, required: true, @@ -30,6 +26,7 @@ export default { }, computed: { ...mapGetters('mergeRequests', ['getData']), + ...mapState(['currentMergeRequestId', 'currentProjectId']), data() { return this.getData(this.type); }, @@ -46,21 +43,26 @@ export default { return this.search !== '' && !this.hasMergeRequests; }, }, + watch: { + isLoading: { + handler: 'focusSearch', + }, + }, mounted() { this.loadMergeRequests(); }, methods: { - ...mapActions('mergeRequests', ['fetchMergeRequests']), + ...mapActions('mergeRequests', ['fetchMergeRequests', 'openMergeRequest']), ...mapActions(['closeAllFiles']), loadMergeRequests() { this.fetchMergeRequests({ type: this.type, search: this.search }); }, viewMergeRequest(item) { - return this.closeAllFiles() - .then(() => { - this.$emit('hide'); - this.$router.push(`/project/${item.projectPathWithNamespace}/merge_requests/${item.iid}`); - }); + this.$emit('hide'); + this.openMergeRequest({ + projectPath: item.projectPathWithNamespace, + id: item.iid, + }); }, searchMergeRequests: _.debounce(function debounceSearch() { this.loadMergeRequests(); @@ -107,7 +109,8 @@ export default { > <item :item="item" - :current-id="currentId" + :current-id="currentMergeRequestId" + :current-project-id="currentProjectId" @click="viewMergeRequest" /> </li> diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js index 2d74192e6b3..13fc1b6b731 100644 --- a/app/assets/javascripts/ide/index.js +++ b/app/assets/javascripts/ide/index.js @@ -9,6 +9,7 @@ Vue.use(Translate); export function initIde(el) { if (!el) return null; + window.store = store; return new Vue({ el, diff --git a/app/assets/javascripts/ide/stores/actions/project.js b/app/assets/javascripts/ide/stores/actions/project.js index 46af47d2f81..0b99bce4a8e 100644 --- a/app/assets/javascripts/ide/stores/actions/project.js +++ b/app/assets/javascripts/ide/stores/actions/project.js @@ -13,8 +13,7 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force .then(data => { commit(types.TOGGLE_LOADING, { entry: state }); commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data }); - if (!state.currentProjectId) - commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`); + commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`); resolve(data); }) .catch(() => { diff --git a/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js b/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js index 83b5b93d3a8..3a572a012fe 100644 --- a/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js +++ b/app/assets/javascripts/ide/stores/modules/merge_requests/actions.js @@ -1,8 +1,10 @@ import { __ } from '../../../../locale'; import Api from '../../../../api'; import flash from '../../../../flash'; +import router from '../../../ide_router'; import { scopes } from './constants'; import * as types from './mutation_types'; +import * as rootTypes from '../../mutation_types'; export const requestMergeRequests = ({ commit }, type) => commit(types.REQUEST_MERGE_REQUESTS, type); @@ -25,4 +27,17 @@ export const fetchMergeRequests = ({ dispatch, state: { state } }, { type, searc export const resetMergeRequests = ({ commit }, type) => commit(types.RESET_MERGE_REQUESTS, type); +export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => { + commit(rootTypes.CLEAR_PROJECTS, null, { root: true }); + commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true }); + commit(rootTypes.RESET_OPEN_FILES, null, { root: true }); + dispatch('pipelines/stopPipelinePolling', null, { root: true }); + dispatch('pipelines/clearEtagPoll', null, { root: true }); + dispatch('pipelines/resetLatestPipeline', null, { root: true }); + + return dispatch('setCurrentBranchId', '', { root: true }).then(() => + router.push(`/project/${projectPath}/merge_requests/${id}`), + ); +}; + export default () => {}; diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js index 3de3e6d3376..0a4ea80c4c1 100644 --- a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js +++ b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js @@ -102,4 +102,7 @@ export const fetchJobTrace = ({ dispatch, state }) => { .catch(() => dispatch('receiveJobTraceError')); }; +export const resetLatestPipeline = ({ commit }) => + commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, null); + export default () => {}; diff --git a/app/assets/javascripts/ide/stores/mutation_types.js b/app/assets/javascripts/ide/stores/mutation_types.js index fbfb92105d6..99b315ac4db 100644 --- a/app/assets/javascripts/ide/stores/mutation_types.js +++ b/app/assets/javascripts/ide/stores/mutation_types.js @@ -68,3 +68,6 @@ export const TOGGLE_FILE_FINDER = 'TOGGLE_FILE_FINDER'; export const BURST_UNUSED_SEAL = 'BURST_UNUSED_SEAL'; export const SET_RIGHT_PANE = 'SET_RIGHT_PANE'; + +export const CLEAR_PROJECTS = 'CLEAR_PROJECTS'; +export const RESET_OPEN_FILES = 'RESET_OPEN_FILES'; diff --git a/app/assets/javascripts/ide/stores/mutations.js b/app/assets/javascripts/ide/stores/mutations.js index eeaa7cb0ec3..48f1da4eccf 100644 --- a/app/assets/javascripts/ide/stores/mutations.js +++ b/app/assets/javascripts/ide/stores/mutations.js @@ -157,6 +157,12 @@ export default { [types.SET_LINKS](state, links) { Object.assign(state, { links }); }, + [types.CLEAR_PROJECTS](state) { + Object.assign(state, { projects: {}, trees: {} }); + }, + [types.RESET_OPEN_FILES](state) { + Object.assign(state, { openFiles: [] }); + }, ...projectMutations, ...mergeRequestMutation, ...fileMutations, diff --git a/app/assets/javascripts/vue_shared/components/tabs/tabs.js b/app/assets/javascripts/vue_shared/components/tabs/tabs.js index 4b2996f76d5..9b9e4bb47bd 100644 --- a/app/assets/javascripts/vue_shared/components/tabs/tabs.js +++ b/app/assets/javascripts/vue_shared/components/tabs/tabs.js @@ -23,6 +23,7 @@ export default { setTab(e, index) { if (this.stopPropagation) { e.stopPropagation(); + e.preventDefault(); } this.tabs[this.currentIndex].localActive = false; |