Show upstream lock state on files inside locked directories

What does this MR do and why?

When a directory is locked, files inside it showed a Lock button that did nothing when clicked, and users without unlock permission saw no lock indicator at all. This MR makes files inside a locked directory show the Locked disclosure for all users, with an alert explaining the parent directory lock and a View lock link to the locked directory. It reuses the slot-based treatment the directory lock button already uses; an exact file lock still takes precedence.

The change is behind the default-off repository_lock_information feature flag.

References

Related to #545279 (closed)

Screenshots or screen recordings

Videos of the previous behavior are in the bug report note linked above.

Scenario After
Maintainer viewing a file inside a locked directory lock-maintainer-child-file
Reporter (no lock permission) viewing the same file — previously saw no lock state at all lock-reporter-child-file
Maintainer viewing an unlocked file — plain Lock button unchanged lock-maintainer-unlocked-file

How to set up and validate locally

  1. Enable the feature flag in the rails console: Feature.enable(:repository_lock_information).
  2. Make sure your instance has an EE license that includes file locks.
  3. Lock a directory, either from the directory page lock button or in the rails console with PathLocks::LockService.
  4. Visit a file inside that directory as a user with push access: the Locked disclosure appears with the parent directory alert and a View lock link, and no Unlock file action.
  5. Visit the same file as a user without push access (for example a Reporter): the same Locked disclosure appears instead of nothing.
  6. Visit a file outside the locked directory: the plain Lock button still appears for users who can lock.

Merge request reports

Loading
Loading