Skip to content

Add modal to upload file with code

Alexander Turinske requested to merge 428508-add-code-block-modal into master

What does this MR do and why?

Add button to upload file with code

  • create modal
  • add drag and drop section

Screenshots or screen recordings

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

Scenario Screenshot
Default Screenshot_2023-11-21_at_17.31.50
Success Screenshot_2023-11-21_at_17.32.23
Confirmation Modal Screenshot_2023-11-21_at_17.32.15
Error error_message

How to set up and validate locally

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

  1. Upload a GitLab Ultimate license
  2. Enable the following feature flag

echo "Feature.enable(:compliance_pipeline_in_policies)" | rails c

  1. Go to a project or group
  2. Secure -> Policies -> New policy -> Scan execution policy
  3. Add new action -> Execute a YAML code block
  4. Verify button appears and one can upload a file

To create an error:

  1. Apply the following patch
diff --git a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scan_execution/action/code_block_import.vue b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scan_execution/action/code_block_import.vue
index c07fcda3f6ad..13f49815e104 100644
--- a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scan_execution/action/code_block_import.vue
+++ b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scan_execution/action/code_block_import.vue
@@ -51,6 +51,7 @@ export default {
       this.uploadedFile = e?.target?.files[0];
       const processedFile = new FileReader();
       if (this.uploadedFile) {
+        debugger;
         processedFile.readAsText(this.uploadedFile);
         processedFile.onload = this.handleFileProcessed;
         processedFile.onerror = this.showError;
  1. Open the browser debugger
  2. Upload a file
  3. When the code gets stuck on the debugger, delete the chosen file
  4. Continue the code execution

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #428508 (closed)

Edited by Alexander Turinske

Merge request reports