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 {
projectPath: this.projectPath,
};
},
update: data => data.project.userPermissions,
update: data => data.project?.userPermissions,
error(error) {
throw error;
},
},
},
mixins: [getRefMixin],
......@@ -172,7 +175,7 @@ export default {
);
}
if (this.userPermissions.pushCode) {
if (this.userPermissions?.pushCode) {
items.push(
{
type: ROW_TYPES.divider,
......
......@@ -40,16 +40,19 @@ export default {
};
},
update: data => {
const pipelines = data.project.repository.tree.lastCommit.pipelines.edges;
const pipelines = data.project?.repository?.tree?.lastCommit?.pipelines?.edges;
return {
...data.project.repository.tree.lastCommit,
pipeline: pipelines.length && pipelines[0].node,
...data.project?.repository?.tree?.lastCommit,
pipeline: pipelines?.length && pipelines[0].node,
};
},
context: {
isSingleRequest: true,
},
error(error) {
throw error;
},
},
},
props: {
......@@ -62,7 +65,7 @@ export default {
data() {
return {
projectPath: '',
commit: {},
commit: null,
showDescription: false,
};
},
......@@ -79,6 +82,11 @@ export default {
return this.commit.sha.substr(0, 8);
},
},
watch: {
currentPath() {
this.commit = null;
},
},
methods: {
toggleShowDescription() {
this.showDescription = !this.showDescription;
......@@ -91,7 +99,7 @@ export default {
<template>
<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" />
<template v-else>
<template v-else-if="commit">
<user-avatar-link
v-if="commit.author"
:link-href="commit.author.webUrl"
......
......@@ -86,7 +86,8 @@ export default {
},
})
.then(({ data }) => {
if (!data) return;
if (data.errors) throw data.errors;
if (!data?.project?.repository) return;
const pageInfo = this.hasNextPage(data.project.repository.tree);
......@@ -99,12 +100,15 @@ export default {
{},
);
if (pageInfo && pageInfo.hasNextPage) {
if (pageInfo?.hasNextPage) {
this.nextPageCursor = pageInfo.endCursor;
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) {
return this.entries[key].concat(data.map(({ node }) => node));
......
......@@ -23,7 +23,7 @@ export default function setupVueRepositoryList() {
projectPath,
projectShortPath,
ref,
vueFileListLfsBadge: gon?.features?.vueFileListLfsBadge,
vueFileListLfsBadge: gon.features?.vueFileListLfsBadge || false,
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