Commit ca07f8b1 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'ph/vueFileListErrorChecking' into 'master'

Add some extra checks for Vue file listing

See merge request gitlab-org/gitlab!23611
parents 2ac6df9e be34fed5
...@@ -34,7 +34,10 @@ export default { ...@@ -34,7 +34,10 @@ export default {
projectPath: this.projectPath, projectPath: this.projectPath,
}; };
}, },
update: data => data.project.userPermissions, update: data => data.project?.userPermissions,
error(error) {
throw error;
},
}, },
}, },
mixins: [getRefMixin], mixins: [getRefMixin],
...@@ -172,7 +175,7 @@ export default { ...@@ -172,7 +175,7 @@ export default {
); );
} }
if (this.userPermissions.pushCode) { if (this.userPermissions?.pushCode) {
items.push( items.push(
{ {
type: ROW_TYPES.divider, type: ROW_TYPES.divider,
......
...@@ -40,16 +40,19 @@ export default { ...@@ -40,16 +40,19 @@ export default {
}; };
}, },
update: data => { update: data => {
const pipelines = data.project.repository.tree.lastCommit.pipelines.edges; const pipelines = data.project?.repository?.tree?.lastCommit?.pipelines?.edges;
return { return {
...data.project.repository.tree.lastCommit, ...data.project?.repository?.tree?.lastCommit,
pipeline: pipelines.length && pipelines[0].node, pipeline: pipelines?.length && pipelines[0].node,
}; };
}, },
context: { context: {
isSingleRequest: true, isSingleRequest: true,
}, },
error(error) {
throw error;
},
}, },
}, },
props: { props: {
...@@ -62,7 +65,7 @@ export default { ...@@ -62,7 +65,7 @@ export default {
data() { data() {
return { return {
projectPath: '', projectPath: '',
commit: {}, commit: null,
showDescription: false, showDescription: false,
}; };
}, },
...@@ -79,6 +82,11 @@ export default { ...@@ -79,6 +82,11 @@ export default {
return this.commit.sha.substr(0, 8); return this.commit.sha.substr(0, 8);
}, },
}, },
watch: {
currentPath() {
this.commit = null;
},
},
methods: { methods: {
toggleShowDescription() { toggleShowDescription() {
this.showDescription = !this.showDescription; this.showDescription = !this.showDescription;
...@@ -91,7 +99,7 @@ export default { ...@@ -91,7 +99,7 @@ export default {
<template> <template>
<div class="info-well d-none d-sm-flex project-last-commit commit p-3"> <div class="info-well d-none d-sm-flex project-last-commit commit p-3">
<gl-loading-icon v-if="isLoading" size="md" color="dark" class="m-auto" /> <gl-loading-icon v-if="isLoading" size="md" color="dark" class="m-auto" />
<template v-else> <template v-else-if="commit">
<user-avatar-link <user-avatar-link
v-if="commit.author" v-if="commit.author"
:link-href="commit.author.webUrl" :link-href="commit.author.webUrl"
......
...@@ -86,7 +86,8 @@ export default { ...@@ -86,7 +86,8 @@ export default {
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
if (!data) return; if (data.errors) throw data.errors;
if (!data?.project?.repository) return;
const pageInfo = this.hasNextPage(data.project.repository.tree); const pageInfo = this.hasNextPage(data.project.repository.tree);
...@@ -99,12 +100,15 @@ export default { ...@@ -99,12 +100,15 @@ export default {
{}, {},
); );
if (pageInfo && pageInfo.hasNextPage) { if (pageInfo?.hasNextPage) {
this.nextPageCursor = pageInfo.endCursor; this.nextPageCursor = pageInfo.endCursor;
this.fetchFiles(); this.fetchFiles();
} }
}) })
.catch(() => createFlash(__('An error occurred while fetching folder content.'))); .catch(error => {
createFlash(__('An error occurred while fetching folder content.'));
throw error;
});
}, },
normalizeData(key, data) { normalizeData(key, data) {
return this.entries[key].concat(data.map(({ node }) => node)); return this.entries[key].concat(data.map(({ node }) => node));
......
...@@ -23,7 +23,7 @@ export default function setupVueRepositoryList() { ...@@ -23,7 +23,7 @@ export default function setupVueRepositoryList() {
projectPath, projectPath,
projectShortPath, projectShortPath,
ref, ref,
vueFileListLfsBadge: gon?.features?.vueFileListLfsBadge, vueFileListLfsBadge: gon.features?.vueFileListLfsBadge || false,
commits: [], commits: [],
}, },
}); });
......
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