/
ApplyModificationConfirmation.vue
70 lines (64 loc) 路 1.42 KB
/
ApplyModificationConfirmation.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<n-card :bordered="false">
<n-p v-if="safeToApply">
Apply the following modifications?
</n-p>
<n-p v-else>
Override modifications made in the code editor with target code and subtree modifications?
</n-p>
<n-form-item
label-placement="left"
label="Diff between"
>
<n-select
v-model:value="diffMode"
:options="diffOptions"
/>
</n-form-item>
<diff-view
:prev="diffPrev[diffMode]"
:current="diffCurrent[diffMode]"
/>
</n-card>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import {
NCard,
NFormItem,
NP,
NSelect,
} from 'naive-ui';
import DiffView from './DiffView.vue';
const props = defineProps<{
lastGuess: string,
current: string,
applied: string,
safeToApply: boolean,
}>();
const diffPrev = {
'current-applied': props.current,
'last-current': props.lastGuess,
'last-applied': props.lastGuess,
} as const;
const diffCurrent = {
'current-applied': props.applied,
'last-current': props.current,
'last-applied': props.applied,
} as const;
const diffMode = ref<keyof typeof diffPrev>('current-applied');
const diffOptions = [
{
label: 'Current code & Incoming modifications',
value: 'current-applied',
},
{
label: 'Last guess & Current code',
value: 'last-current',
},
{
label: 'Last guess & Incoming modifications',
value: 'last-applied',
},
];
</script>