Skip to content

Commit fcfbdcf

Browse files
authored
🎨 Wallets: some defaults (#4607)
1 parent 9d59b35 commit fcfbdcf

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

services/static-webserver/client/source/class/osparc/component/study/ResourceSelector.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,12 @@ qx.Class.define("osparc.component.study.ResourceSelector", {
268268
}
269269
if (Object.keys(lgInfo["resources"]).length) {
270270
const buttons = [];
271+
const smallButton = this.self().createMachineToggleButton(smInfo);
272+
const mediumButton = this.self().createMachineToggleButton(mdInfo);
271273
const largeButton = this.self().createMachineToggleButton(lgInfo);
272274
[
273-
this.self().createMachineToggleButton(smInfo),
274-
this.self().createMachineToggleButton(mdInfo),
275+
smallButton,
276+
mediumButton,
275277
largeButton
276278
].forEach(btn => {
277279
buttons.push(btn);
@@ -294,7 +296,8 @@ qx.Class.define("osparc.component.study.ResourceSelector", {
294296
});
295297
}
296298
}));
297-
largeButton.execute();
299+
// small by default
300+
smallButton.execute();
298301
}
299302
return machinesLayout;
300303
}
@@ -385,7 +388,9 @@ qx.Class.define("osparc.component.study.ResourceSelector", {
385388
this.setWallet(null);
386389
}
387390
});
388-
walletSelector.setSelection([]);
391+
if (!osparc.desktop.credits.Utils.autoSelectActiveWallet(walletSelector)) {
392+
walletSelector.setSelection([]);
393+
}
389394
},
390395

391396
__getCreditsLeftView: function() {

services/static-webserver/client/source/class/osparc/desktop/credits/Utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ qx.Class.define("osparc.desktop.credits.Utils", {
5050
store.addListener("changeWallets", () => populateSelectBox(walletSelector));
5151

5252
return walletSelector;
53+
},
54+
55+
autoSelectActiveWallet: function(walletSelector) {
56+
// If there is only one active wallet, select it
57+
const store = osparc.store.Store.getInstance();
58+
const wallets = store.getWallets();
59+
const activeWallets = wallets.filter(wallet => wallet.getStatus() === "ACTIVE");
60+
if (activeWallets.length === 1) {
61+
const found = walletSelector.getSelectables().find(sbItem => sbItem.walletId === activeWallets[0].getWalletId());
62+
if (found) {
63+
walletSelector.setSelection([found]);
64+
return true;
65+
}
66+
}
67+
return false;
5368
}
5469
}
5570
});

services/static-webserver/client/source/class/osparc/desktop/wallets/WalletsList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ qx.Class.define("osparc.desktop.wallets.WalletsList", {
3939

4040
const newWalletButton = this.__getCreateWalletSection();
4141
newWalletButton.setVisibility(osparc.data.Permissions.getInstance().canDo("user.wallets.create") ? "visible" : "excluded");
42+
this._add(newWalletButton);
4243

4344
this.loadWallets();
4445
},

0 commit comments

Comments
 (0)