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.
- Add alert for fork suggestion from overflow menu actions
- Fork suggestion becomes page-level alert
- Rearrange and introduce overflow menu to single file page
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.
- 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);
- Impersonate a different user than root
- Go to a project, where that user is a guest
- Go to any file in that project and click Edit on a blob content viewer.
- A fork suggestion will show up on the blob viewer. Make sure you see the same suggestion in the alert.
- 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:
Related to #519316 (closed)