Use consistent default values for locks
What does this MR do and why?
Use consistant default values for locks
Making sure we do not retrieve values when the project returns null, using the same approach as in other Blob and Repository components.
Changelog: other
References
- Fix TypeError regarding pathLocks in blob_content_viewer
- Make sure default values are used when project data is unavailable
- example errors
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 LockDirectoryButton with the Vue devTools
- Apply the following patch and make sure that devTools show values from
BLOB_DEFAULT_INFO
diff --git a/ee/app/assets/javascripts/repository/components/lock_directory_button.vue b/ee/app/assets/javascripts/repository/components/lock_directory_button.vue
index 0f7cc48042e4..0d5b281e6fc6 100644
--- a/ee/app/assets/javascripts/repository/components/lock_directory_button.vue
+++ b/ee/app/assets/javascripts/repository/components/lock_directory_button.vue
@@ -55,13 +55,14 @@ export default {
};
},
update({ project }) {
- const allPathLocks = project?.pathLocks?.nodes?.map((lock) => this.mapPathLocks(lock));
+ let prj = null;
+ const allPathLocks = prj?.pathLocks?.nodes?.map((lock) => this.mapPathLocks(lock));
this.pathLock =
allPathLocks.find(
(lock) =>
this.isDownstreamLock(lock) || this.isUpstreamLock(lock) || this.isExactLock(lock),
) || {};
- this.projectUserPermissions = project?.userPermissions || {
+ this.projectUserPermissions = prj?.userPermissions || {
...DEFAULT_BLOB_INFO.userPermissions,
createPathLock: false,
};
- With the default value, the Lock button will be seen in a disabled state with a tooltip that you don't have enough permissions to lock.
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)
Edited by Paulina Sedlak-Jakubowska