Skip to content

Prepare util functions for a fork suggestion alert

What does this MR do and why?

This is a preparatory step for Add alert for fork suggestion from overflow menu actions. I'm moving some common parts to a new util function.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
n/a n/a

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Apply this snippet:
diff --git a/app/assets/javascripts/repository/components/blob_content_viewer.vue b/app/assets/javascripts/repository/components/blob_content_viewer.vue
index 1cf8d55450fc..45bbc4504631 100644
--- a/app/assets/javascripts/repository/components/blob_content_viewer.vue
+++ b/app/assets/javascripts/repository/components/blob_content_viewer.vue
@@ -27,6 +27,9 @@ import {
 import BlobButtonGroup from './blob_button_group.vue';
 import ForkSuggestion from './fork_suggestion.vue';
 import { loadViewer } from './blob_viewers';
+import {
+  showForkSuggestionAlert,
+} from '~/repository/utils/fork_suggestion_utils';
 
 export default {
   components: {
@@ -329,6 +332,7 @@ export default {
     },
     setForkTarget(target) {
       this.forkTarget = target;
+      showForkSuggestionAlert(this.forkPath);
     },
     onCopy() {
       navigator.clipboard.writeText(this.blobInfo.rawTextBlob);
  1. Impersonate a different user than root
  2. Go to a project, where that user is a guest
  3. Go to any file in that project and click Edit on a blob content viewer.
  4. A fork suggestion will show up on the blob viewer. Make sure you see the same suggestion in the alert.
  5. Verify that both Fork buttons in the alert and the suggestion have the same href value.

After applying the patch and triggering the suggestion you should see UI in this state:

Screenshot_2025-02-11_at_19.08.33

Related to #519316 (closed)

Edited by Paulina Sedlak-Jakubowska

Merge request reports

Loading