Commit 854bcedd authored by Samantha Ming's avatar Samantha Ming

Add suggestion patch

- Use computed hasRichViewer instead as a data
- Update date to suit
parent 56ffe743
......@@ -23,18 +23,10 @@ export default {
filePath: this.path,
};
},
result({ data }) {
const [blob] = data?.project?.repository?.blobs?.nodes;
if (!blob) {
return;
}
const hasRichViewer = blob?.richViewer !== null;
this.hasRichViewer = hasRichViewer;
this.activeViewerType =
hasRichViewer && !window.location.hash ? RICH_BLOB_VIEWER : SIMPLE_BLOB_VIEWER;
result() {
this.switchViewer(
this.hasRichViewer && !window.location.hash ? RICH_BLOB_VIEWER : SIMPLE_BLOB_VIEWER,
);
},
error() {
createFlash({ message: __('An error occurred while loading the file. Please try again.') });
......@@ -58,7 +50,6 @@ export default {
},
data() {
return {
hasRichViewer: false,
activeViewerType: SIMPLE_BLOB_VIEWER,
project: {
repository: {
......@@ -85,7 +76,7 @@ export default {
canModifyBlob: true,
forkPath: '',
simpleViewer: {},
richViewer: {},
richViewer: null,
},
],
},
......@@ -106,6 +97,9 @@ export default {
const { richViewer, simpleViewer } = this.blobInfo;
return this.activeViewerType === RICH_BLOB_VIEWER ? richViewer : simpleViewer;
},
hasRichViewer() {
return Boolean(this.blobInfo.richViewer);
},
hasRenderError() {
return Boolean(this.viewer.renderError);
},
......
......@@ -108,7 +108,7 @@ describe('Blob content viewer component', () => {
describe('rich viewer', () => {
beforeEach(() => {
factory({
mockData: { blobInfo: richMockData, hasRichViewer: true, activeViewerType: 'rich' },
mockData: { blobInfo: richMockData, activeViewerType: 'rich' },
});
});
......
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