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

Disable updateSSH on low balance #684

Merged
merged 2 commits into from
Jun 25, 2023
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
4 changes: 2 additions & 2 deletions packages/playground/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export function normalizeBalance(num: number | string | undefined, floor = false
return (+num).toFixed(3).replace(/0+$/g, "");
}

export function isEnoughBalance(balance: any): boolean {
return balance.free > 0.001 ? true : false;
export function isEnoughBalance(balance: any, min = 0.001): boolean {
return balance.free > min ? true : false;
}
2 changes: 1 addition & 1 deletion packages/playground/src/weblets/profile_manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
color="primary"
variant="text"
@click="updateSSH"
:disabled="!ssh || profileManager.profile.ssh === ssh || updatingSSH"
:disabled="!ssh || profileManager.profile.ssh === ssh || updatingSSH || !isEnoughBalance(balance)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:disabled="!ssh || profileManager.profile.ssh === ssh || updatingSSH || !isEnoughBalance(balance)"
:disabled="!ssh || profileManager.profile.ssh === ssh || updatingSSH || !isEnoughBalance(balance, 0.001)"

Please update isEnoughBalance to take the balance and the amount to check for because right now no idea what is the enough balance without digging into isEnoughBalance ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that leave room for error if the second param does not equal the lowest possible balance? The minimum balance should be the same in all cases and the suggested fix won't ensure that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a minimum amount by default in isEnoughBalance.

:loading="updatingSSH"
>
Update Public SSH Key
Expand Down