ui: corosync addLink: more flexible params and pass emptyText

Use that instead of the label, as it's using less space

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-05-05 18:21:44 +02:00
parent 61b05a5d82
commit 4ea2cac2ae
2 changed files with 15 additions and 14 deletions

View File

@ -241,7 +241,7 @@ Ext.define('PVE.ClusterJoinNodeWindow', {
joinInfo.ring_addr[0] === joinInfo.ipAddress) {
links[0].allowBlank = true;
linkEditor.setInfoText(gettext("Leave empty to use IP resolved by node's hostname"));
links[0].emptyText = gettext("IP resolved by node's hostname");
}
linkEditor.setLinks(links);

View File

@ -14,7 +14,7 @@ Ext.define('PVE.form.CorosyncLinkEditorController', {
this.addLink();
},
addLink: function(number, value, allowBlank, text) {
addLink: function(link) {
let me = this;
let view = me.getView();
let vm = view.getViewModel();
@ -24,20 +24,23 @@ Ext.define('PVE.form.CorosyncLinkEditorController', {
return;
}
if (number === undefined) {
number = me.getNextFreeNumber();
link = link || {};
if (link.number === undefined) {
link.number = me.getNextFreeNumber();
}
if (value === undefined) {
value = me.getNextFreeNetwork();
if (link.value === undefined) {
link.value = me.getNextFreeNetwork();
}
let linkSelector = Ext.create('PVE.form.CorosyncLinkSelector', {
maxLinkNumber: vm.get('maxLinkCount') - 1,
allowNumberEdit: vm.get('allowNumberEdit'),
allowBlankNetwork: allowBlank,
initNumber: number,
initNetwork: value,
text: text,
allowBlankNetwork: link.allowBlank,
initNumber: link.number,
initNetwork: link.value,
text: link.text,
emptyText: link.emptyText,
// needs to be set here, because we need to update the viewmodel
removeBtnHandler: function() {
@ -127,6 +130,7 @@ Ext.define('PVE.form.CorosyncLinkSelector', {
allowNumberEdit: true,
allowBlankNetwork: false,
removeBtnHandler: undefined,
emptyText: '',
// values
initNumber: 0,
@ -348,10 +352,7 @@ Ext.define('PVE.form.CorosyncLinkEditor', {
me.removeAll();
vm.set('linkCount', 0);
Ext.Array.each(links, link => {
controller.addLink(link['number'], link['value'],
link['allowBlank'], link['text']);
});
Ext.Array.each(links, link => controller.addLink(link));
},
setDefaultLinks: function() {