Commit ce2bc5c0 authored by Phil Hughes's avatar Phil Hughes

correctly load up merge request

fixed pipeline request throwing an error
parent 03820e9b
...@@ -11,17 +11,17 @@ export default { ...@@ -11,17 +11,17 @@ export default {
}, },
computed: { computed: {
...mapGetters(['currentMergeRequest']), ...mapGetters(['currentMergeRequest']),
...mapState(['viewer']), ...mapState(['viewer', 'currentMergeRequestId']),
showLatestChangesText() { showLatestChangesText() {
return !this.currentMergeRequest || this.viewer === viewerTypes.diff; return !this.currentMergeRequestId || this.viewer === viewerTypes.diff;
}, },
showMergeRequestText() { showMergeRequestText() {
return this.currentMergeRequest && this.viewer === viewerTypes.mr; return this.currentMergeRequestId && this.viewer === viewerTypes.mr;
}, },
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.updateViewer(this.currentMergeRequest ? viewerTypes.mr : viewerTypes.diff); this.updateViewer(this.currentMergeRequestId ? viewerTypes.mr : viewerTypes.diff);
}); });
}, },
methods: { methods: {
...@@ -54,7 +54,10 @@ export default { ...@@ -54,7 +54,10 @@ export default {
</template> </template>
<template v-else-if="showMergeRequestText"> <template v-else-if="showMergeRequestText">
{{ __('Merge request') }} {{ __('Merge request') }}
(<a :href="currentMergeRequest.web_url">!{{ currentMergeRequest.iid }}</a>) (<a
v-if="currentMergeRequest"
:href="currentMergeRequest.web_url"
>!{{ currentMergeRequest.iid }}</a>)
</template> </template>
</div> </div>
</template> </template>
......
...@@ -65,6 +65,8 @@ export default { ...@@ -65,6 +65,8 @@ export default {
watch: { watch: {
currentBranchId() { currentBranchId() {
this.$nextTick(() => { this.$nextTick(() => {
if (!this.$refs.branchId) return;
this.showTooltip = this.$refs.branchId.scrollWidth > this.$refs.branchId.offsetWidth; this.showTooltip = this.$refs.branchId.scrollWidth > this.$refs.branchId.offsetWidth;
}); });
}, },
...@@ -145,6 +147,7 @@ export default { ...@@ -145,6 +147,7 @@ export default {
</div> </div>
<div class="d-flex"> <div class="d-flex">
<div <div
v-if="currentBranchId"
class="sidebar-context-title ide-sidebar-branch-title" class="sidebar-context-title ide-sidebar-branch-title"
ref="branchId" ref="branchId"
v-tooltip v-tooltip
...@@ -157,7 +160,10 @@ export default { ...@@ -157,7 +160,10 @@ export default {
</div> </div>
<div <div
v-if="currentMergeRequestId" 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 <icon
name="git-merge" name="git-merge"
......
...@@ -35,9 +35,7 @@ export default { ...@@ -35,9 +35,7 @@ export default {
}, },
watch: { watch: {
lastCommit() { lastCommit() {
if (!this.isPollingInitialized) { this.initPipelinePolling();
this.initPipelinePolling();
}
}, },
}, },
mounted() { mounted() {
...@@ -47,9 +45,8 @@ export default { ...@@ -47,9 +45,8 @@ export default {
if (this.intervalId) { if (this.intervalId) {
clearInterval(this.intervalId); clearInterval(this.intervalId);
} }
if (this.isPollingInitialized) {
this.stopPipelinePolling(); this.stopPipelinePolling();
}
}, },
methods: { methods: {
...mapActions('pipelines', ['fetchLatestPipeline', 'stopPipelinePolling']), ...mapActions('pipelines', ['fetchLatestPipeline', 'stopPipelinePolling']),
...@@ -59,8 +56,9 @@ export default { ...@@ -59,8 +56,9 @@ export default {
}, 1000); }, 1000);
}, },
initPipelinePolling() { initPipelinePolling() {
this.fetchLatestPipeline(); if (this.lastCommit) {
this.isPollingInitialized = true; this.fetchLatestPipeline();
}
}, },
commitAgeUpdate() { commitAgeUpdate() {
if (this.lastCommit) { if (this.lastCommit) {
......
...@@ -12,7 +12,6 @@ export default { ...@@ -12,7 +12,6 @@ export default {
}, },
computed: { computed: {
...mapGetters('mergeRequests', ['assignedData', 'createdData']), ...mapGetters('mergeRequests', ['assignedData', 'createdData']),
...mapState(['currentMergeRequestId']),
createdMergeRequestLength() { createdMergeRequestLength() {
return this.createdData.mergeRequests.length; return this.createdData.mergeRequests.length;
}, },
...@@ -37,7 +36,6 @@ export default { ...@@ -37,7 +36,6 @@ export default {
</template> </template>
<list <list
type="created" type="created"
:current-id="currentMergeRequestId"
:empty-text="__('You have not created any merge requests')" :empty-text="__('You have not created any merge requests')"
@hide="hideDropdown" @hide="hideDropdown"
/> />
...@@ -51,7 +49,6 @@ export default { ...@@ -51,7 +49,6 @@ export default {
</template> </template>
<list <list
type="assigned" type="assigned"
:current-id="currentMergeRequestId"
:empty-text="__('You do not have any assigned merge requests')" :empty-text="__('You do not have any assigned merge requests')"
@hide="hideDropdown" @hide="hideDropdown"
/> />
......
...@@ -14,10 +14,17 @@ export default { ...@@ -14,10 +14,17 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
currentProjectId: {
type: String,
required: true,
},
}, },
computed: { computed: {
isActive() { isActive() {
return this.item.iid === parseInt(this.currentId, 10); return (
this.item.iid === parseInt(this.currentId, 10) &&
this.currentProjectId === this.item.projectPathWithNamespace
);
}, },
pathWithID() { pathWithID() {
return `${this.item.projectPathWithNamespace}!${this.item.iid}`; return `${this.item.projectPathWithNamespace}!${this.item.iid}`;
...@@ -35,7 +42,7 @@ export default { ...@@ -35,7 +42,7 @@ export default {
<button <button
type="button" type="button"
class="d-flex align-items-center" class="d-flex align-items-center"
@click="clickItem" @click.prevent.stop="clickItem"
> >
<span <span
class="d-flex append-right-default" class="d-flex append-right-default"
......
<script> <script>
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import _ from 'underscore'; import _ from 'underscore';
import LoadingIcon from '../../../vue_shared/components/loading_icon.vue'; import LoadingIcon from '../../../vue_shared/components/loading_icon.vue';
import Item from './item.vue'; import Item from './item.vue';
...@@ -14,10 +14,6 @@ export default { ...@@ -14,10 +14,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
currentId: {
type: String,
required: true,
},
emptyText: { emptyText: {
type: String, type: String,
required: true, required: true,
...@@ -30,6 +26,7 @@ export default { ...@@ -30,6 +26,7 @@ export default {
}, },
computed: { computed: {
...mapGetters('mergeRequests', ['getData']), ...mapGetters('mergeRequests', ['getData']),
...mapState(['currentMergeRequestId', 'currentProjectId']),
data() { data() {
return this.getData(this.type); return this.getData(this.type);
}, },
...@@ -46,21 +43,26 @@ export default { ...@@ -46,21 +43,26 @@ export default {
return this.search !== '' && !this.hasMergeRequests; return this.search !== '' && !this.hasMergeRequests;
}, },
}, },
watch: {
isLoading: {
handler: 'focusSearch',
},
},
mounted() { mounted() {
this.loadMergeRequests(); this.loadMergeRequests();
}, },
methods: { methods: {
...mapActions('mergeRequests', ['fetchMergeRequests']), ...mapActions('mergeRequests', ['fetchMergeRequests', 'openMergeRequest']),
...mapActions(['closeAllFiles']), ...mapActions(['closeAllFiles']),
loadMergeRequests() { loadMergeRequests() {
this.fetchMergeRequests({ type: this.type, search: this.search }); this.fetchMergeRequests({ type: this.type, search: this.search });
}, },
viewMergeRequest(item) { viewMergeRequest(item) {
return this.closeAllFiles() this.$emit('hide');
.then(() => { this.openMergeRequest({
this.$emit('hide'); projectPath: item.projectPathWithNamespace,
this.$router.push(`/project/${item.projectPathWithNamespace}/merge_requests/${item.iid}`); id: item.iid,
}); });
}, },
searchMergeRequests: _.debounce(function debounceSearch() { searchMergeRequests: _.debounce(function debounceSearch() {
this.loadMergeRequests(); this.loadMergeRequests();
...@@ -107,7 +109,8 @@ export default { ...@@ -107,7 +109,8 @@ export default {
> >
<item <item
:item="item" :item="item"
:current-id="currentId" :current-id="currentMergeRequestId"
:current-project-id="currentProjectId"
@click="viewMergeRequest" @click="viewMergeRequest"
/> />
</li> </li>
......
...@@ -9,6 +9,7 @@ Vue.use(Translate); ...@@ -9,6 +9,7 @@ Vue.use(Translate);
export function initIde(el) { export function initIde(el) {
if (!el) return null; if (!el) return null;
window.store = store;
return new Vue({ return new Vue({
el, el,
......
...@@ -13,8 +13,7 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force ...@@ -13,8 +13,7 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
.then(data => { .then(data => {
commit(types.TOGGLE_LOADING, { entry: state }); commit(types.TOGGLE_LOADING, { entry: state });
commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data }); 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); resolve(data);
}) })
.catch(() => { .catch(() => {
......
import { __ } from '../../../../locale'; import { __ } from '../../../../locale';
import Api from '../../../../api'; import Api from '../../../../api';
import flash from '../../../../flash'; import flash from '../../../../flash';
import router from '../../../ide_router';
import { scopes } from './constants'; import { scopes } from './constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
import * as rootTypes from '../../mutation_types';
export const requestMergeRequests = ({ commit }, type) => export const requestMergeRequests = ({ commit }, type) =>
commit(types.REQUEST_MERGE_REQUESTS, type); commit(types.REQUEST_MERGE_REQUESTS, type);
...@@ -25,4 +27,17 @@ export const fetchMergeRequests = ({ dispatch, state: { state } }, { type, searc ...@@ -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 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 () => {}; export default () => {};
...@@ -102,4 +102,7 @@ export const fetchJobTrace = ({ dispatch, state }) => { ...@@ -102,4 +102,7 @@ export const fetchJobTrace = ({ dispatch, state }) => {
.catch(() => dispatch('receiveJobTraceError')); .catch(() => dispatch('receiveJobTraceError'));
}; };
export const resetLatestPipeline = ({ commit }) =>
commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, null);
export default () => {}; export default () => {};
...@@ -68,3 +68,6 @@ export const TOGGLE_FILE_FINDER = 'TOGGLE_FILE_FINDER'; ...@@ -68,3 +68,6 @@ export const TOGGLE_FILE_FINDER = 'TOGGLE_FILE_FINDER';
export const BURST_UNUSED_SEAL = 'BURST_UNUSED_SEAL'; export const BURST_UNUSED_SEAL = 'BURST_UNUSED_SEAL';
export const SET_RIGHT_PANE = 'SET_RIGHT_PANE'; export const SET_RIGHT_PANE = 'SET_RIGHT_PANE';
export const CLEAR_PROJECTS = 'CLEAR_PROJECTS';
export const RESET_OPEN_FILES = 'RESET_OPEN_FILES';
...@@ -157,6 +157,12 @@ export default { ...@@ -157,6 +157,12 @@ export default {
[types.SET_LINKS](state, links) { [types.SET_LINKS](state, links) {
Object.assign(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, ...projectMutations,
...mergeRequestMutation, ...mergeRequestMutation,
...fileMutations, ...fileMutations,
......
...@@ -23,6 +23,7 @@ export default { ...@@ -23,6 +23,7 @@ export default {
setTab(e, index) { setTab(e, index) {
if (this.stopPropagation) { if (this.stopPropagation) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault();
} }
this.tabs[this.currentIndex].localActive = false; this.tabs[this.currentIndex].localActive = false;
......
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
align-items: center; align-items: center;
padding: 10px 16px 10px 10px; padding: 10px 16px 10px 10px;
color: $gl-text-color; color: $gl-text-color;
}
&:hover, &:hover,
a:hover { a:hover {
background-color: $link-hover-background; background-color: $link-hover-background;
color: $gl-text-color; color: $gl-text-color;
}
} }
.avatar-container { .avatar-container {
......
...@@ -1143,6 +1143,10 @@ ...@@ -1143,6 +1143,10 @@
.sidebar-context-title { .sidebar-context-title {
white-space: nowrap; white-space: nowrap;
} }
.ide-sidebar-branch-title {
min-width: 50px;
}
} }
.ide-external-link { .ide-external-link {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment