Skip to content

Commit

Permalink
Merge pull request #95 from MaterializeInc/disable-ui-when-loading-co…
Browse files Browse the repository at this point in the history
…ntext

auth: disable ui
  • Loading branch information
joacoc authored Sep 15, 2023
2 parents 436c8bd + 77a84db commit 38715c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/providers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export default class AuthProvider implements vscode.WebviewViewProvider {
this.state.isAddNewProfile = false;
if (appPasswordResponse) {
const { appPassword, region } = appPasswordResponse;

// Set the state loading to true. After the new context is loaded
// loading will turn false.
this.state.isLoading = true;
this.context.addAndSaveProfile(name, appPassword, region.toString());
} else {
// Cancel login process.
Expand Down Expand Up @@ -229,6 +233,13 @@ export default class AuthProvider implements vscode.WebviewViewProvider {
break;
}
case "onContinueRemoveProfile": {
this.state.isRemoveProfile = false;

// Set the state loading to true. After the new context is loaded
// loading will turn false.
this.state.isLoading = true;
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);

const name = this.context.getProfileName();

if (name) {
Expand All @@ -237,8 +248,6 @@ export default class AuthProvider implements vscode.WebviewViewProvider {
console.error("[Auth]", "Profile name is not available.");
}

this.state.isRemoveProfile = false;
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
break;
}
case "onRemoveProfile": {
Expand Down Expand Up @@ -352,7 +361,7 @@ export default class AuthProvider implements vscode.WebviewViewProvider {
<!-- https://github.com/microsoft/vscode-webview-ui-toolkit/tree/main/src/dropdown#with-label -->
<div class="dropdown-container">
<label for="profiles">Profile</label>
<vscode-dropdown id="profiles">
<vscode-dropdown id="profiles" ${this.state.isLoading ? "disabled=true" :""}>
<vscode-option>${(profileName)}</vscode-option>
${profileNames.filter(name => name !== profileName).map((name) => `<vscode-option>${name}</vscode-option>`).join('')}
</vscode-dropdown>
Expand Down
10 changes: 10 additions & 0 deletions src/providers/scripts/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@
break;
}
case "environmentChange": {
// Disable profile interactions of any kind.
const addProfileButton = document.getElementById("addProfileButton") as HTMLSelectElement;
addProfileButton.disabled = true;

const removeProfileButton = document.getElementById("removeProfileButton") as HTMLSelectElement;
removeProfileButton.disabled = true;

const profiles = document.getElementById("profiles") as HTMLSelectElement;
profiles.disabled = true;

const clusters = document.getElementById("clusters") as HTMLSelectElement;
clusters.disabled = true;

Expand Down

0 comments on commit 38715c1

Please sign in to comment.