Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: onPaste separator logic in KeyValue.vue #1012

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,6 @@ export default {
@focusKey="focusKey"
@input="value.setLabels($event)"
>
<template #key="{ row, keyName, queueUpdate}">
<input
ref="key"
v-model="row[keyName]"
:placeholder="t('keyValue.keyPlaceholder')"
@input="queueUpdate"
/>
</template>

<template #value="{row, keyName, valueName, queueUpdate}">
<Select
v-if="internalAnnotations(row)"
Expand Down
2 changes: 1 addition & 1 deletion shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6916,7 +6916,7 @@ podAffinity:
keyValue:
keyPlaceholder: e.g. foo
valuePlaceholder: e.g. bar
protip: 'Paste lines of <em>key=value</em> or <em>key: value</em> into any key field for easy bulk entry'
protip: 'Paste lines of <em>key=value</em> or <em>key:value</em> into any key field for easy bulk entry'

registryMirror:
header: Mirrors
Expand Down
10 changes: 5 additions & 5 deletions shell/components/form/KeyValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default {
},
parserSeparators: {
type: Array,
default: () => [': ', '='],
default: () => [':', '='],
},
loading: {
default: false,
Expand Down Expand Up @@ -492,14 +492,14 @@ export default {
}
this.$emit('input', out);
},
onPaste(index, event, pastedValue) {
onPaste(index, event) {
const text = event.clipboardData.getData('text/plain');
const lines = text.split('\n');
const splits = lines.map((line) => {
const splitter = !line.includes(':') || ((line.indexOf('=') < line.indexOf(':')) && line.includes(':')) ? '=' : ':';
const splitter = this.parserSeparators.find(sep => line.includes(sep));

return line.split(splitter);
});
return splitter ? line.split(splitter) : '';
}).filter(split => split && split.length > 0);

if (splits.length === 0 || (splits.length === 1 && splits[0].length < 2)) {
return;
Expand Down
Loading