addDatabasePane provide backward compatibility

This commit is contained in:
hardiknai-techm
2021-04-24 13:39:13 +05:30
parent 42552bad07
commit 28bbba5522
6 changed files with 237 additions and 239 deletions

View File

@@ -1,131 +1,131 @@
<div data-bind="visible: visible, event: { keydown: onPaneKeyDown }"> <div data-bind="visible: visible, event: { keydown: onPaneKeyDown }">
<div class="contextual-pane-out" data-bind="click: cancel, clickBubble: false"></div> <div class="contextual-pane-out" data-bind="click: cancel, clickBubble: false"></div>
<div class="contextual-pane" data-bind="attr: { id: id }"> <div class="contextual-pane" data-bind="attr: { id: id }">
<!-- Add database form -- Start --> <!-- Add database form -- Start -->
<div class="contextual-pane-in"> <div class="contextual-pane-in">
<form data-bind="submit: submit" style="height: 100%"> <form data-bind="submit: submit" style="height: 100%">
<div <div
class="paneContentContainer" class="paneContentContainer"
role="dialog" role="dialog"
aria-labelledby="databaseTitle" aria-labelledby="databaseTitle"
data-bind="template: { name: 'add-database-inputs' }" data-bind="template: { name: 'add-database-inputs' }"
></div> ></div>
</form> </form>
</div> </div>
<!-- Add database form -- End --> <!-- Add database form -- End -->
<!-- Loader - Start --> <!-- Loader - Start -->
<div class="dataExplorerLoaderContainer dataExplorerPaneLoaderContainer" data-bind="visible: isExecuting"> <div class="dataExplorerLoaderContainer dataExplorerPaneLoaderContainer" data-bind="visible: isExecuting">
<img class="dataExplorerLoader" src="/LoadingIndicator_3Squares.gif" /> <img class="dataExplorerLoader" src="/LoadingIndicator_3Squares.gif" />
</div> </div>
<!-- Loader - End --> <!-- Loader - End -->
</div>
</div>
<script type="text/html" id="add-database-inputs">
<!-- Add database header - Start -->
<div class="firstdivbg headerline">
<span id="databaseTitle" role="heading" aria-level="2" data-bind="text: title"></span>
<div
class="closeImg"
role="button"
aria-label="Close pane"
data-bind="click: cancel, event: { keypress: onCloseKeyPress }"
tabindex="0"
>
<img src="../../../images/close-black.svg" title="Close" alt="Close" />
</div> </div>
</div> </div>
<!-- Add database header - End -->
<script type="text/html" id="add-database-inputs">
<!-- Add database header - Start --> <!-- Add database errors - Start -->
<div class="firstdivbg headerline"> <div class="warningErrorContainer" aria-live="assertive" data-bind="visible: formErrors() && formErrors() !== ''">
<span id="databaseTitle" role="heading" aria-level="2" data-bind="text: title"></span> <div class="warningErrorContent">
<div <span><img class="paneErrorIcon" src="/error_red.svg" alt="Error" /></span>
class="closeImg" <span class="warningErrorDetailsLinkContainer">
role="button" <span class="formErrors" data-bind="text: formErrors, attr: { title: formErrors }"></span>
aria-label="Close pane" <a
data-bind="click: cancel, event: { keypress: onCloseKeyPress }" class="errorLink"
tabindex="0" role="link"
> data-bind="visible: formErrorsDetails() && formErrorsDetails() !== '', click: showErrorDetails, event: { keypress: onMoreDetailsKeyPress }"
<img src="../../../images/close-black.svg" title="Close" alt="Close" /> tabindex="0"
</div> >
More details</a
>
</span>
</div> </div>
<!-- Add database header - End --> </div>
<!-- Add database errors - End -->
<!-- Add database errors - Start -->
<div class="warningErrorContainer" aria-live="assertive" data-bind="visible: formErrors() && formErrors() !== ''"> <!-- upsell message - start -->
<div class="warningErrorContent"> <div
<span><img class="paneErrorIcon" src="/error_red.svg" alt="Error" /></span> class="infoBoxContainer"
<span class="warningErrorDetailsLinkContainer"> aria-live="assertive"
<span class="formErrors" data-bind="text: formErrors, attr: { title: formErrors }"></span> data-bind="visible: showUpsellMessage && showUpsellMessage() && formErrors && !formErrors()"
<a >
class="errorLink" <div class="infoBoxContent">
role="link" <span><img class="infoBoxIcon" src="/info_color.svg" alt="Promo" /></span>
data-bind="visible: formErrorsDetails() && formErrorsDetails() !== '', click: showErrorDetails, event: { keypress: onMoreDetailsKeyPress }" <span class="infoBoxDetails">
tabindex="0" <span class="infoBoxMessage" data-bind="text: upsellMessage, attr: { title: upsellMessage }"></span>
> <a
More details</a class="underlinedLink"
> id="linkAddDatabase"
data-bind="text: upsellAnchorText, attr: { 'href': upsellAnchorUrl, 'aria-label': upsellMessageAriaLabel }"
target="_blank"
href=""
tabindex="0"
></a>
</span>
</div>
</div>
<!-- upsell message - end -->
<!-- Add database inputs - Start -->
<div class="paneMainContent">
<div>
<p>
<span class="mandatoryStar">*</span>
<span data-bind="text: databaseIdLabel"></span>
<span class="infoTooltip" role="tooltip" tabindex="0">
<img class="infoImg" src="/info-bubble.svg" alt="More information" />
<span class="tooltiptext infoTooltipWidth" data-bind="text: databaseIdTooltipText"></span>
</span> </span>
</div> </p>
</div>
<!-- Add database errors - End --> <input
id="database-id"
<!-- upsell message - start --> type="text"
<div aria-required="true"
class="infoBoxContainer" autocomplete="off"
aria-live="assertive" pattern="[^/?#\\]*[^/?# \\]"
data-bind="visible: showUpsellMessage && showUpsellMessage() && formErrors && !formErrors()" title="May not end with space nor contain characters '\' '/' '#' '?'"
> size="40"
<div class="infoBoxContent"> class="collid"
<span><img class="infoBoxIcon" src="/info_color.svg" alt="Promo" /></span> data-bind="textInput: databaseId, hasFocus: firstFieldHasFocus, attr: { 'aria-label': databaseIdLabel, 'placeholder': databaseIdPlaceHolder }"
<span class="infoBoxDetails"> autofocus
<span class="infoBoxMessage" data-bind="text: upsellMessage, attr: { title: upsellMessage }"></span> />
<a
class="underlinedLink" <!-- Database provisioned throughput - Start -->
id="linkAddDatabase" <!-- ko if: canConfigureThroughput -->
data-bind="text: upsellAnchorText, attr: { 'href': upsellAnchorUrl, 'aria-label': upsellMessageAriaLabel }" <div class="databaseProvision" aria-label="New database provision support">
target="_blank"
href=""
tabindex="0"
></a>
</span>
</div>
</div>
<!-- upsell message - end -->
<!-- Add database inputs - Start -->
<div class="paneMainContent">
<div>
<p>
<span class="mandatoryStar">*</span>
<span data-bind="text: databaseIdLabel"></span>
<span class="infoTooltip" role="tooltip" tabindex="0">
<img class="infoImg" src="/info-bubble.svg" alt="More information" />
<span class="tooltiptext infoTooltipWidth" data-bind="text: databaseIdTooltipText"></span>
</span>
</p>
<input <input
id="database-id" tabindex="0"
type="text" type="checkbox"
aria-required="true" id="addDatabasePane-databaseSharedThroughput"
autocomplete="off" title="Provision shared throughput"
pattern="[^/?#\\]*[^/?# \\]" data-bind="checked: databaseCreateNewShared"
title="May not end with space nor contain characters '\' '/' '#' '?'"
size="40"
class="collid"
data-bind="textInput: databaseId, hasFocus: firstFieldHasFocus, attr: { 'aria-label': databaseIdLabel, 'placeholder': databaseIdPlaceHolder }"
autofocus
/> />
<span class="databaseProvisionText" for="databaseSharedThroughput">Provision throughput</span>
<!-- Database provisioned throughput - Start --> <span class="infoTooltip" role="tooltip" tabindex="0">
<!-- ko if: canConfigureThroughput --> <img class="infoImg" src="/info-bubble.svg" alt="More information" />
<div class="databaseProvision" aria-label="New database provision support"> <span
<input class="tooltiptext provisionDatabaseThroughput"
tabindex="0" data-bind="text: databaseLevelThroughputTooltipText"
type="checkbox" ></span>
id="addDatabasePane-databaseSharedThroughput" </span>
title="Provision shared throughput" </div>
data-bind="checked: databaseCreateNewShared" <div data-bind="visible: databaseCreateNewShared">
/> <throughput-input-autopilot-v3
<span class="databaseProvisionText" for="databaseSharedThroughput">Provision throughput</span> params="{
<span class="infoTooltip" role="tooltip" tabindex="0">
<img class="infoImg" src="/info-bubble.svg" alt="More information" />
<span
class="tooltiptext provisionDatabaseThroughput"
data-bind="text: databaseLevelThroughputTooltipText"
></span>
</span>
</div>
<div data-bind="visible: databaseCreateNewShared">
<throughput-input-autopilot-v3
params="{
step: 100, step: 100,
value: throughput, value: throughput,
testId: 'sharedThroughputValue', testId: 'sharedThroughputValue',
@@ -151,24 +151,24 @@
canExceedMaximumValue: canExceedMaximumValue, canExceedMaximumValue: canExceedMaximumValue,
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
}" }"
>
</throughput-input-autopilot-v3>
<p data-bind="visible: canRequestSupport">
<!-- TODO: Replace link with call to the Azure Support blade --><a
href="https://aka.ms/cosmosdbfeedback?subject=Cosmos%20DB%20More%20Throughput%20Request"
>Contact support</a
> >
</throughput-input-autopilot-v3> for more than <span data-bind="text: maxThroughputRUText"></span> RU/s.
<p data-bind="visible: canRequestSupport"> </p>
<!-- TODO: Replace link with call to the Azure Support blade --><a
href="https://aka.ms/cosmosdbfeedback?subject=Cosmos%20DB%20More%20Throughput%20Request"
>Contact support</a
>
for more than <span data-bind="text: maxThroughputRUText"></span> RU/s.
</p>
</div>
<!-- /ko -->
<!-- Database provisioned throughput - End -->
</div> </div>
<!-- /ko -->
<!-- Database provisioned throughput - End -->
</div> </div>
<div class="paneFooter"> </div>
<div class="leftpanel-okbut"> <div class="paneFooter">
<input type="submit" value="OK" class="btncreatecoll1" /> <div class="leftpanel-okbut">
</div> <input type="submit" value="OK" class="btncreatecoll1" />
</div> </div>
<!-- Add database inputs - End --> </div>
</script> <!-- Add database inputs - End -->
</script>

View File

@@ -6,100 +6,100 @@ import Explorer from "../Explorer";
import AddDatabasePane from "./AddDatabasePane"; import AddDatabasePane from "./AddDatabasePane";
describe("Add Database Pane", () => { describe("Add Database Pane", () => {
describe("getSharedThroughputDefault()", () => { describe("getSharedThroughputDefault()", () => {
let explorer: Explorer; let explorer: Explorer;
const mockDatabaseAccount: DatabaseAccount = { const mockDatabaseAccount: DatabaseAccount = {
id: "mock", id: "mock",
kind: "DocumentDB", kind: "DocumentDB",
location: "", location: "",
name: "mock", name: "mock",
properties: { properties: {
documentEndpoint: "", documentEndpoint: "",
cassandraEndpoint: "", cassandraEndpoint: "",
gremlinEndpoint: "", gremlinEndpoint: "",
tableEndpoint: "", tableEndpoint: "",
enableFreeTier: false, enableFreeTier: false,
}, },
type: undefined, type: undefined,
tags: [], tags: [],
}; };
const mockFreeTierDatabaseAccount: DatabaseAccount = { const mockFreeTierDatabaseAccount: DatabaseAccount = {
id: "mock", id: "mock",
kind: "DocumentDB", kind: "DocumentDB",
location: "", location: "",
name: "mock", name: "mock",
properties: { properties: {
documentEndpoint: "", documentEndpoint: "",
cassandraEndpoint: "", cassandraEndpoint: "",
gremlinEndpoint: "", gremlinEndpoint: "",
tableEndpoint: "", tableEndpoint: "",
enableFreeTier: true, enableFreeTier: true,
}, },
type: undefined, type: undefined,
tags: [], tags: [],
}; };
beforeEach(() => { beforeEach(() => {
explorer = new Explorer(); explorer = new Explorer();
});
it("should be true if subscription type is Benefits", () => {
updateUserContext({
subscriptionType: SubscriptionType.Benefits,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be false if subscription type is EA", () => {
updateUserContext({
subscriptionType: SubscriptionType.EA,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(false);
});
it("should be true if subscription type is Free", () => {
updateUserContext({
subscriptionType: SubscriptionType.Free,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be true if subscription type is Internal", () => {
updateUserContext({
subscriptionType: SubscriptionType.Internal,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be true if subscription type is PAYG", () => {
updateUserContext({
subscriptionType: SubscriptionType.PAYG,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should display free tier text in upsell messaging", () => {
explorer.databaseAccount(mockFreeTierDatabaseAccount);
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.isFreeTierAccount()).toBe(true);
expect(addDatabasePane.upsellMessage()).toContain("With free tier");
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.freeTierInformation);
expect(addDatabasePane.upsellAnchorText()).toBe("Learn more");
});
it("should display standard texr in upsell messaging", () => {
explorer.databaseAccount(mockDatabaseAccount);
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.isFreeTierAccount()).toBe(false);
expect(addDatabasePane.upsellMessage()).toContain("Start at");
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.cosmosPricing);
expect(addDatabasePane.upsellAnchorText()).toBe("More details");
});
}); });
});
it("should be true if subscription type is Benefits", () => {
updateUserContext({
subscriptionType: SubscriptionType.Benefits,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be false if subscription type is EA", () => {
updateUserContext({
subscriptionType: SubscriptionType.EA,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(false);
});
it("should be true if subscription type is Free", () => {
updateUserContext({
subscriptionType: SubscriptionType.Free,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be true if subscription type is Internal", () => {
updateUserContext({
subscriptionType: SubscriptionType.Internal,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should be true if subscription type is PAYG", () => {
updateUserContext({
subscriptionType: SubscriptionType.PAYG,
});
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
});
it("should display free tier text in upsell messaging", () => {
explorer.databaseAccount(mockFreeTierDatabaseAccount);
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.isFreeTierAccount()).toBe(true);
expect(addDatabasePane.upsellMessage()).toContain("With free tier");
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.freeTierInformation);
expect(addDatabasePane.upsellAnchorText()).toBe("Learn more");
});
it("should display standard texr in upsell messaging", () => {
explorer.databaseAccount(mockDatabaseAccount);
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
expect(addDatabasePane.isFreeTierAccount()).toBe(false);
expect(addDatabasePane.upsellMessage()).toContain("Start at");
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.cosmosPricing);
expect(addDatabasePane.upsellAnchorText()).toBe("More details");
});
});
});

View File

@@ -71,8 +71,9 @@ export default class AddDatabasePane extends ContextualPaneBase {
this.databaseIdTooltipText = ko.computed<string>(() => { this.databaseIdTooltipText = ko.computed<string>(() => {
const isCassandraAccount: boolean = userContext.apiType === "Cassandra"; const isCassandraAccount: boolean = userContext.apiType === "Cassandra";
return `A ${isCassandraAccount ? "keyspace" : "database"} is a logical container of one or more ${isCassandraAccount ? "tables" : "collections" return `A ${isCassandraAccount ? "keyspace" : "database"} is a logical container of one or more ${
}`; isCassandraAccount ? "tables" : "collections"
}`;
}); });
this.databaseLevelThroughputTooltipText = ko.computed<string>(() => { this.databaseLevelThroughputTooltipText = ko.computed<string>(() => {
const isCassandraAccount: boolean = userContext.apiType === "Cassandra"; const isCassandraAccount: boolean = userContext.apiType === "Cassandra";

View File

@@ -614,7 +614,7 @@ exports[`AddDatabasePane Pane should render Default properly 1`] = `
} }
} }
formError="" formError=""
id="copynotebookpane" id="add-database-inputs"
isExecuting={false} isExecuting={false}
onClose={[Function]} onClose={[Function]}
onSubmit={[Function]} onSubmit={[Function]}

View File

@@ -7,7 +7,6 @@ import StringInputPaneTemplate from "./StringInputPane.html";
import TableAddEntityPaneTemplate from "./Tables/TableAddEntityPane.html"; import TableAddEntityPaneTemplate from "./Tables/TableAddEntityPane.html";
import TableEditEntityPaneTemplate from "./Tables/TableEditEntityPane.html"; import TableEditEntityPaneTemplate from "./Tables/TableEditEntityPane.html";
export class PaneComponent { export class PaneComponent {
constructor(data: any) { constructor(data: any) {
return data.data; return data.data;

View File

@@ -630,9 +630,7 @@ exports[`Upload Items Pane should render Default properly 1`] = `
multiple={true} multiple={true}
onUpload={[Function]} onUpload={[Function]}
tabIndex={0} tabIndex={0}
tooltip="Select one or more JSON files to upload. Each file can contain a single JSON document or an array of JSON tooltip="Select one or more JSON files to upload. Each file can contain a single JSON document or an array of JSON documents. The combined size of all files in an individual upload operation must be less than 2 MB. You can perform multiple upload operations for larger data sets."
documents. The combined size of all files in an individual upload operation must be less than 2 MB. You
can perform multiple upload operations for larger data sets."
/> />
</div> </div>
</GenericRightPaneComponent> </GenericRightPaneComponent>