mirror of https://github.com/rancher/dashboard.git
Merge pull request #10959 from rancher/fix_10958
fix: support colon as separator when onPaste context in label key field
This commit is contained in:
commit
4dffddb0f2
|
|
@ -7125,7 +7125,7 @@ podAffinity:
|
||||||
keyValue:
|
keyValue:
|
||||||
keyPlaceholder: e.g. foo
|
keyPlaceholder: e.g. foo
|
||||||
valuePlaceholder: e.g. bar
|
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:
|
registryMirror:
|
||||||
header: Mirrors
|
header: Mirrors
|
||||||
|
|
|
||||||
|
|
@ -6953,7 +6953,7 @@ podAffinity:
|
||||||
keyValue:
|
keyValue:
|
||||||
keyPlaceholder: 例如:foo
|
keyPlaceholder: 例如:foo
|
||||||
valuePlaceholder: 例如:bar
|
valuePlaceholder: 例如:bar
|
||||||
protip: '把多行 <em>key=value</em> 或 <em>key: value</em> 键值对复制到各字段中,以便批量输入'
|
protip: '把多行 <em>key=value</em> 或 <em>key:value</em> 键值对复制到各字段中,以便批量输入'
|
||||||
|
|
||||||
registryMirror:
|
registryMirror:
|
||||||
header: Mirror
|
header: Mirror
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ export default {
|
||||||
},
|
},
|
||||||
parserSeparators: {
|
parserSeparators: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [': ', '='],
|
default: () => [':', '='],
|
||||||
},
|
},
|
||||||
loading: {
|
loading: {
|
||||||
default: false,
|
default: false,
|
||||||
|
|
@ -515,14 +515,14 @@ export default {
|
||||||
|
|
||||||
this.$emit('input', out);
|
this.$emit('input', out);
|
||||||
},
|
},
|
||||||
onPaste(index, event, pastedValue) {
|
onPaste(index, event) {
|
||||||
const text = event.clipboardData.getData('text/plain');
|
const text = event.clipboardData.getData('text/plain');
|
||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
const splits = lines.map((line) => {
|
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)) {
|
if (splits.length === 0 || (splits.length === 1 && splits[0].length < 2)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue