mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 09:51:11 +00:00
Remove AdHoc Access and Token Renewal Pane (#445)
This commit is contained in:
@@ -11,7 +11,6 @@ import TableQuerySelectPaneTemplate from "./Tables/TableQuerySelectPane.html";
|
||||
import CassandraAddCollectionPaneTemplate from "./CassandraAddCollectionPane.html";
|
||||
import SettingsPaneTemplate from "./SettingsPane.html";
|
||||
import ExecuteSprocParamsPaneTemplate from "./ExecuteSprocParamsPane.html";
|
||||
import RenewAdHocAccessPaneTemplate from "./RenewAdHocAccessPane.html";
|
||||
import UploadItemsPaneTemplate from "./UploadItemsPane.html";
|
||||
import LoadQueryPaneTemplate from "./LoadQueryPane.html";
|
||||
import SaveQueryPaneTemplate from "./SaveQueryPane.html";
|
||||
@@ -144,15 +143,6 @@ export class ExecuteSprocParamsComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class RenewAdHocAccessPane {
|
||||
constructor() {
|
||||
return {
|
||||
viewModel: PaneComponent,
|
||||
template: RenewAdHocAccessPaneTemplate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class UploadItemsPaneComponent {
|
||||
constructor() {
|
||||
return {
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<div data-bind="visible: visible, event: { keydown: onPaneKeyDown }">
|
||||
<div
|
||||
class="contextual-pane-out"
|
||||
data-bind="
|
||||
click: cancel,
|
||||
clickBubble: false"
|
||||
></div>
|
||||
<div class="contextual-pane" id="renewadhocaccesspane">
|
||||
<!-- Renew ad-hoc access form - Start -->
|
||||
<div class="contextual-pane-in">
|
||||
<form class="paneContentContainer" data-bind="submit: submit">
|
||||
<!-- Renew ad-hoc access header - Start -->
|
||||
<div class="firstdivbg headerline">
|
||||
<span role="heading" aria-level="2" data-bind="text: title"></span>
|
||||
<div
|
||||
class="closeImg"
|
||||
role="button"
|
||||
aria-label="Close pane"
|
||||
tabindex="0"
|
||||
data-bind="
|
||||
click: cancel"
|
||||
>
|
||||
<img src="../../../images/close-black.svg" title="Close" alt="Close" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Renew ad-hoc access header - End -->
|
||||
|
||||
<!-- Renew ad-hoc access errors - Start -->
|
||||
<div
|
||||
class="warningErrorContainer"
|
||||
aria-live="assertive"
|
||||
data-bind="visible: formErrors() && formErrors() !== ''"
|
||||
>
|
||||
<div class="warningErrorContent">
|
||||
<span><img class="paneErrorIcon" src="/error_red.svg" alt="Error" /></span>
|
||||
<span class="warningErrorDetailsLinkContainer">
|
||||
<span class="formErrors" data-bind="text: formErrors, attr: { title: formErrors }"></span>
|
||||
<a
|
||||
class="errorLink"
|
||||
role="link"
|
||||
data-bind="
|
||||
visible: formErrorsDetails() && formErrorsDetails() !== '',
|
||||
click: showErrorDetails"
|
||||
>More details</a
|
||||
>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Renew ad-hoc access errors - End -->
|
||||
|
||||
<!-- Renew ad-hoc access inputs - Start -->
|
||||
<div class="paneMainContent">
|
||||
<div class="renewUploadItemsHeader">Provide a valid account connection string</div>
|
||||
<input
|
||||
class="accessKeyInput"
|
||||
type="text"
|
||||
placeholder="Enter a connection string"
|
||||
required
|
||||
data-bind="value: accessKey"
|
||||
/>
|
||||
<div
|
||||
class="renewAccessExpandCollapse"
|
||||
data-bind="click: onShowHelperImageClick, event: { keypress: onShowHelperImageKeyPress }"
|
||||
>
|
||||
<img src="/Triangle-right.svg" alt="Show renew access image" data-bind="visible: !isHelperImageVisible()" />
|
||||
<img src="/Triangle-down.svg" alt="Hide renew access image" data-bind="visible: isHelperImageVisible()" />
|
||||
<span class="AccountNavigationText">Where do I find the Connection String?</span>
|
||||
</div>
|
||||
<div class="renewAccessImg" data-bind="visible: isHelperImageVisible()">
|
||||
<span class="AccountNavigationText"
|
||||
>To get the connection string, navigate to your Azure Cosmos DB account in Azure Portal, select Keys and
|
||||
copy the connection string.</span
|
||||
>
|
||||
<img src="/ConnectionString_Artwork.png" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="paneFooter">
|
||||
<div class="leftpanel-okbut"><input type="submit" value="Connect" class="btncreatecoll1" /></div>
|
||||
</div>
|
||||
<!-- Renew ad-hoc access - End -->
|
||||
</form>
|
||||
</div>
|
||||
<!-- Renew ad-hoc access form - Start -->
|
||||
<!-- Loader - Start -->
|
||||
<div class="dataExplorerLoaderContainer dataExplorerPaneLoaderContainer" data-bind="visible: isExecuting">
|
||||
<img class="dataExplorerLoader" src="/LoadingIndicator_3Squares.gif" />
|
||||
</div>
|
||||
<!-- Loader - End -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,101 +0,0 @@
|
||||
import * as ko from "knockout";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { parseConnectionString } from "../../Platform/Hosted/Helpers/ConnectionStringParser";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
|
||||
|
||||
export class RenewAdHocAccessPane extends ContextualPaneBase {
|
||||
public accessKey: ko.Observable<string>;
|
||||
public isHelperImageVisible: ko.Observable<boolean>;
|
||||
|
||||
constructor(options: ViewModels.PaneOptions) {
|
||||
super(options);
|
||||
this.title("Connect to Azure Cosmos DB");
|
||||
this.accessKey = ko.observable<string>();
|
||||
this.isHelperImageVisible = ko.observable<boolean>(false);
|
||||
}
|
||||
|
||||
public submit(): void {
|
||||
this.formErrors("");
|
||||
this.formErrorsDetails("");
|
||||
|
||||
if (this._shouldShowContextSwitchPrompt()) {
|
||||
this.container.displayContextSwitchPromptForConnectionString(this.accessKey());
|
||||
} else if (!!this.formErrors()) {
|
||||
return;
|
||||
} else {
|
||||
this.isExecuting(true);
|
||||
this._renewShareAccess();
|
||||
}
|
||||
}
|
||||
|
||||
public onShowHelperImageClick = (src: any, event: MouseEvent): void => {
|
||||
this.isHelperImageVisible(!this.isHelperImageVisible());
|
||||
};
|
||||
|
||||
public onShowHelperImageKeyPress = (src: any, event: KeyboardEvent): boolean => {
|
||||
if (event.keyCode === Constants.KeyCodes.Enter || event.keyCode === Constants.KeyCodes.Space) {
|
||||
this.onShowHelperImageClick(src, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
private _shouldShowContextSwitchPrompt(): boolean {
|
||||
const inputMetadata: DataModels.AccessInputMetadata = parseConnectionString(this.accessKey());
|
||||
const apiKind: DataModels.ApiKind =
|
||||
this.container && DefaultExperienceUtility.getApiKindFromDefaultExperience(this.container.defaultExperience());
|
||||
const hasOpenedTabs: boolean =
|
||||
(this.container && this.container.tabsManager && this.container.tabsManager.openedTabs().length > 0) || false;
|
||||
|
||||
if (!inputMetadata || inputMetadata.apiKind == null || !inputMetadata.accountName) {
|
||||
this.formErrors("Invalid connection string input");
|
||||
this.formErrorsDetails("Please enter a valid connection string");
|
||||
}
|
||||
|
||||
if (
|
||||
!inputMetadata ||
|
||||
this.formErrors() ||
|
||||
!this.container ||
|
||||
apiKind == null ||
|
||||
!this.container.databaseAccount ||
|
||||
!this.container.defaultExperience ||
|
||||
!hasOpenedTabs ||
|
||||
(this.container.databaseAccount().name === inputMetadata.accountName &&
|
||||
apiKind === inputMetadata.apiKind &&
|
||||
!hasOpenedTabs)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private _renewShareAccess = (): void => {
|
||||
this.container
|
||||
.renewShareAccess(this.accessKey())
|
||||
.fail((error: any) => {
|
||||
const errorMessage: string = getErrorMessage(error);
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, `Failed to connect: ${errorMessage}`);
|
||||
this.formErrors(errorMessage);
|
||||
this.formErrorsDetails(errorMessage);
|
||||
})
|
||||
.finally(() => {
|
||||
this.isExecuting(false);
|
||||
});
|
||||
};
|
||||
|
||||
public close(): void {
|
||||
super.close();
|
||||
this.isHelperImageVisible(false);
|
||||
this.formErrors("");
|
||||
this.formErrorsDetails("");
|
||||
this.accessKey("");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user