Make sure default values are used when project data is unavailable
What does this MR do and why?
Following the pattern from ee/app/assets/javascripts/repository/components/header_area/blob_overflow_menu.vue, this MR makes sure that optional chaining operator and default values are used for pathLocks and userPermission in the BlobContentViewer.
References
Screenshots or screen recordings
| Before | After |
|---|---|
| n/a | n/a |
How to set up and validate locally
- Go to Project / Repository and select a file to view
- Inspect BlobContentViewer with the Vue devTools
- Apply the following patch and make sure that devTools show values from
BLOB_DEFAULT_INFO
diff --git a/app/assets/javascripts/repository/components/blob_content_viewer.vue b/app/assets/javascripts/repository/components/blob_content_viewer.vue
index 4f35064d837e..66fb8b6ef493 100644
--- a/app/assets/javascripts/repository/components/blob_content_viewer.vue
+++ b/app/assets/javascripts/repository/components/blob_content_viewer.vue
@@ -72,8 +72,9 @@ export default {
this.displayError();
},
update({ project }) {
- this.pathLocks = project?.pathLocks || DEFAULT_BLOB_INFO.pathLocks;
- this.userPermissions = project?.userPermissions || DEFAULT_BLOB_INFO.userPermissions;
+ let prj = {}
+ this.pathLocks = prj?.pathLocks || DEFAULT_BLOB_INFO.pathLocks;
+ this.userPermissions = prj?.userPermissions || DEFAULT_BLOB_INFO.userPermissions;
},
},
project: {
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #523410 (closed)