From 09cee6046e686857258d55be2f639391880e73c2 Mon Sep 17 00:00:00 2001 From: khansadaoudi Date: Thu, 9 Jan 2025 16:22:31 +0100 Subject: [PATCH] show diff between samples before commit --- src/components/github/GithubCommitDialog.vue | 49 ++++++++++++++++++++ src/components/github/GithubOptions.vue | 7 ++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/components/github/GithubCommitDialog.vue b/src/components/github/GithubCommitDialog.vue index 25f59f80..bd35f851 100644 --- a/src/components/github/GithubCommitDialog.vue +++ b/src/components/github/GithubCommitDialog.vue @@ -4,6 +4,33 @@
{{ $t('github.commitDialog.title') }}
+ + + + + {{ sample.sample_name }} + + + {{ sample.changes_number }} {{ sample.changes_number == 1 ? 'change' : 'changes' }} + + + + Show changes + + + + +
{{ sample.sample_name }}
+
+ +
+                
+              
+            
+          
+        
+      
+    
     
       
         
@@ -31,12 +58,20 @@ export default defineComponent({
       type: String as PropType,
       required: true,
     },
+    modifiedSamples: {
+      type: Array as PropType,
+      required: true,
+    },
   },
   data() {
     return {
       message: '',
+      selectedModifiedSamples: [] as boolean[],
     };
   },
+  mounted() {
+    this.selectedModifiedSamples = new Array(this.modifiedSamples.length).fill(false);
+  },
   methods: {
     commitChanges() {
       const githubMessage = this.message + ': committed by ArboratorGrew';
@@ -51,6 +86,20 @@ export default defineComponent({
           notifyError({ error: 'Error while commiting changes' });
         });
     },
+    highlightedDiff(diff: string) {
+      return diff
+        .split('\n')
+        .map(line => {
+          if (line.startsWith('-')) {
+            return `${line}`;
+          } else if (line.startsWith('+')) {
+            return `${line}`;
+          } else {
+            return line;
+          }
+        })
+        .join('\n');
+    },
   },
 });
 
diff --git a/src/components/github/GithubOptions.vue b/src/components/github/GithubOptions.vue
index f1a3335f..9a4a240f 100644
--- a/src/components/github/GithubOptions.vue
+++ b/src/components/github/GithubOptions.vue
@@ -59,7 +59,7 @@
     
   
   
-    
+    
   
   
     
@@ -101,6 +101,7 @@ export default defineComponent({
   },
   data() {
     const confirmActionCallback = null as unknown as CallableFunction;
+    const modifiedSamples = [] as any[];
     return {
       isShowCommitDialog: false,
       isShowPullRequestDialog: false,
@@ -108,6 +109,7 @@ export default defineComponent({
       confirmActionCallback,
       checkPulls: false,
       changesNumber: 0,
+      modifiedSamples,
     };
   },
   computed: {
@@ -125,7 +127,8 @@ export default defineComponent({
       api
         .getChanges(this.projectName)
         .then((response) => {
-          this.changesNumber = response.data;
+          this.modifiedSamples = response.data;
+          this.changesNumber = this.modifiedSamples.map((sample) => sample.changes_number).reduce((a, b) => a + b, 0);
         })
         .catch((error) => {
           notifyError({ error });