mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-14 15:56:50 +01:00
merge master
This commit is contained in:
commit
e20931fbfe
@ -191,5 +191,4 @@ src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/index.tsx
|
|||||||
src/Explorer/Notebook/temp/inputs/connected-editors/codemirror.tsx
|
src/Explorer/Notebook/temp/inputs/connected-editors/codemirror.tsx
|
||||||
src/Explorer/Tree/ResourceTreeAdapter.tsx
|
src/Explorer/Tree/ResourceTreeAdapter.tsx
|
||||||
__mocks__/monaco-editor.ts
|
__mocks__/monaco-editor.ts
|
||||||
src/Explorer/Tree/ResourceTreeAdapterForResourceToken.test.tsx
|
|
||||||
src/Explorer/Tree/ResourceTree.tsx
|
src/Explorer/Tree/ResourceTree.tsx
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
.dataResourceTree {
|
.dataResourceTree {
|
||||||
margin-left: @MediumSpace;
|
margin-left: @MediumSpace;
|
||||||
|
overflow: auto;
|
||||||
|
|
||||||
.databaseHeader {
|
.databaseHeader {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
@import "./Common/Constants";
|
@import "./Common/Constants";
|
||||||
|
|
||||||
|
|
||||||
.resourceTree {
|
.resourceTree {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 20%;
|
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
.main {
|
.main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -46,20 +44,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.contextmenushowing {
|
.contextmenushowing {
|
||||||
background-color: #EEE;
|
background-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.collectionstree {
|
.collectionstree {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: @DefaultSpace;
|
margin-top: @DefaultSpace;
|
||||||
|
|
||||||
|
|
||||||
.databaseList {
|
.databaseList {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding-left: 0px;
|
padding-left: 0px;
|
||||||
|
|
||||||
.collectionList {
|
.collectionList {
|
||||||
padding-left:(2 * @MediumSpace);
|
padding-left: (2 * @MediumSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
.collectionChildList {
|
.collectionChildList {
|
||||||
@ -85,7 +82,7 @@
|
|||||||
left: 0px;
|
left: 0px;
|
||||||
float: right;
|
float: right;
|
||||||
display: none;
|
display: none;
|
||||||
padding-left: 6px!important;
|
padding-left: 6px !important;
|
||||||
line-height: @TreeLineHeight;
|
line-height: @TreeLineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +189,7 @@ img.collectionsTreeCollapseExpand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.expanded::before {
|
.expanded::before {
|
||||||
content: '\23F7';
|
content: "\23F7";
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
@ -211,7 +208,7 @@ img.collectionsTreeCollapseExpand {
|
|||||||
transform: rotate(-90deg) translateX(-100%);
|
transform: rotate(-90deg) translateX(-100%);
|
||||||
-webkit-transform: rotate(-90deg) translateX(-100%);
|
-webkit-transform: rotate(-90deg) translateX(-100%);
|
||||||
-ms-transform: rotate(-90deg) translateX(-100%);
|
-ms-transform: rotate(-90deg) translateX(-100%);
|
||||||
border-bottom: 1px solid #CCC;
|
border-bottom: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-nav-img {
|
.main-nav-img {
|
||||||
@ -257,11 +254,11 @@ ul.nav {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight:hover>.contextmenubutton {
|
.highlight:hover > .contextmenubutton {
|
||||||
display: unset;
|
display: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight:hover>.contextmenubutton::after {
|
.highlight:hover > .contextmenubutton::after {
|
||||||
content: "\2026";
|
content: "\2026";
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
24
package-lock.json
generated
24
package-lock.json
generated
@ -20623,9 +20623,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"playwright": {
|
"playwright": {
|
||||||
"version": "1.10.0",
|
"version": "1.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.13.0.tgz",
|
||||||
"integrity": "sha512-b7SGBcCPq4W3pb4ImEDmNXtO0ZkJbZMuWiShsaNJd+rGfY/6fqwgllsAojmxGSgFmijYw7WxCoPiAIEDIH16Kw==",
|
"integrity": "sha512-GA5OyEeKx1v/pRcANmYncCT67Y7Y4N5zLRU5E690dn/Id10sooR5hQZmCDYsjXlutZb/1q0R3sITALnvhEjCjg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"commander": "^6.1.0",
|
"commander": "^6.1.0",
|
||||||
@ -20640,7 +20640,8 @@
|
|||||||
"proxy-from-env": "^1.1.0",
|
"proxy-from-env": "^1.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"stack-utils": "^2.0.3",
|
"stack-utils": "^2.0.3",
|
||||||
"ws": "^7.3.1"
|
"ws": "^7.4.6",
|
||||||
|
"yazl": "^2.5.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": {
|
"commander": {
|
||||||
@ -20672,6 +20673,12 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"escape-string-regexp": "^2.0.0"
|
"escape-string-regexp": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ws": {
|
||||||
|
"version": "7.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz",
|
||||||
|
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==",
|
||||||
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -26162,6 +26169,15 @@
|
|||||||
"fd-slicer": "~1.1.0"
|
"fd-slicer": "~1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"yazl": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"buffer-crc32": "~0.2.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"yocto-queue": {
|
"yocto-queue": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||||
|
@ -164,7 +164,7 @@
|
|||||||
"mini-css-extract-plugin": "0.4.3",
|
"mini-css-extract-plugin": "0.4.3",
|
||||||
"monaco-editor-webpack-plugin": "1.7.0",
|
"monaco-editor-webpack-plugin": "1.7.0",
|
||||||
"node-fetch": "2.6.1",
|
"node-fetch": "2.6.1",
|
||||||
"playwright": "1.10.0",
|
"playwright": "1.13.0",
|
||||||
"prettier": "2.2.1",
|
"prettier": "2.2.1",
|
||||||
"raw-loader": "0.5.1",
|
"raw-loader": "0.5.1",
|
||||||
"react-dev-utils": "11.0.4",
|
"react-dev-utils": "11.0.4",
|
||||||
|
@ -3,6 +3,7 @@ import arrowLeftImg from "../../images/imgarrowlefticon.svg";
|
|||||||
import refreshImg from "../../images/refresh-cosmos.svg";
|
import refreshImg from "../../images/refresh-cosmos.svg";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import Explorer from "../Explorer/Explorer";
|
import Explorer from "../Explorer/Explorer";
|
||||||
|
import { ResourceTokenTree } from "../Explorer/Tree/ResourceTokenTree";
|
||||||
import { ResourceTree } from "../Explorer/Tree/ResourceTree";
|
import { ResourceTree } from "../Explorer/Tree/ResourceTree";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ export const ResourceTreeContainer: FunctionComponent<ResourceTreeContainerProps
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{userContext.authType === AuthType.ResourceToken ? (
|
{userContext.authType === AuthType.ResourceToken ? (
|
||||||
<div style={{ overflowY: "auto" }} data-bind="react:resourceTreeForResourceToken" />
|
<ResourceTokenTree />
|
||||||
) : userContext.features.enableKOResourceTree ? (
|
) : userContext.features.enableKOResourceTree ? (
|
||||||
<div style={{ overflowY: "auto" }} data-bind="react:resourceTree" />
|
<div style={{ overflowY: "auto" }} data-bind="react:resourceTree" />
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
jest.mock("../../Utils/arm/request");
|
jest.mock("../../Utils/arm/request");
|
||||||
jest.mock("../CosmosClient");
|
jest.mock("../CosmosClient");
|
||||||
|
import ko from "knockout";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { CreateCollectionParams, DatabaseAccount } from "../../Contracts/DataModels";
|
import { CreateCollectionParams, DatabaseAccount } from "../../Contracts/DataModels";
|
||||||
|
import { Database } from "../../Contracts/ViewModels";
|
||||||
|
import { useDatabases } from "../../Explorer/useDatabases";
|
||||||
import { updateUserContext } from "../../UserContext";
|
import { updateUserContext } from "../../UserContext";
|
||||||
import { armRequest } from "../../Utils/arm/request";
|
import { armRequest } from "../../Utils/arm/request";
|
||||||
import { client } from "../CosmosClient";
|
import { client } from "../CosmosClient";
|
||||||
@ -23,6 +26,15 @@ describe("createCollection", () => {
|
|||||||
} as DatabaseAccount,
|
} as DatabaseAccount,
|
||||||
apiType: "SQL",
|
apiType: "SQL",
|
||||||
});
|
});
|
||||||
|
useDatabases.setState({
|
||||||
|
databases: [
|
||||||
|
{
|
||||||
|
id: ko.observable("testDatabase"),
|
||||||
|
loadCollections: () => undefined,
|
||||||
|
collections: ko.observableArray([]),
|
||||||
|
} as Database,
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call ARM if logged in with AAD", async () => {
|
it("should call ARM if logged in with AAD", async () => {
|
||||||
|
@ -4,20 +4,16 @@ import { ContainerRequest } from "@azure/cosmos/dist-esm/client/Container/Contai
|
|||||||
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
|
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
|
import { useDatabases } from "../../Explorer/useDatabases";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import {
|
import { getCollectionName } from "../../Utils/APITypeUtils";
|
||||||
createUpdateCassandraTable,
|
import { createUpdateCassandraTable } from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
||||||
getCassandraTable,
|
import { createUpdateGremlinGraph } from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
import { createUpdateMongoDBCollection } from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
||||||
import { createUpdateGremlinGraph, getGremlinGraph } from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
import { createUpdateSqlContainer } from "../../Utils/arm/generatedClients/cosmos/sqlResources";
|
||||||
import {
|
import { createUpdateTable } from "../../Utils/arm/generatedClients/cosmos/tableResources";
|
||||||
createUpdateMongoDBCollection,
|
|
||||||
getMongoDBCollection,
|
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
|
||||||
import { createUpdateSqlContainer, getSqlContainer } from "../../Utils/arm/generatedClients/cosmos/sqlResources";
|
|
||||||
import { createUpdateTable, getTable } from "../../Utils/arm/generatedClients/cosmos/tableResources";
|
|
||||||
import * as ARMTypes from "../../Utils/arm/generatedClients/cosmos/types";
|
import * as ARMTypes from "../../Utils/arm/generatedClients/cosmos/types";
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { client } from "../CosmosClient";
|
import { client } from "../CosmosClient";
|
||||||
@ -59,6 +55,16 @@ export const createCollection = async (params: DataModels.CreateCollectionParams
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createCollectionWithARM = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createCollectionWithARM = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
|
if (!params.createNewDatabase) {
|
||||||
|
const isValid = await useDatabases.getState().validateCollectionId(params.databaseId, params.collectionId);
|
||||||
|
if (!isValid) {
|
||||||
|
const collectionName = getCollectionName().toLocaleLowerCase();
|
||||||
|
throw new Error(
|
||||||
|
`Create ${collectionName} failed: ${collectionName} with id ${params.collectionId} already exists`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { apiType } = userContext;
|
const { apiType } = userContext;
|
||||||
switch (apiType) {
|
switch (apiType) {
|
||||||
case "SQL":
|
case "SQL":
|
||||||
@ -77,23 +83,6 @@ const createCollectionWithARM = async (params: DataModels.CreateCollectionParams
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createSqlContainer = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createSqlContainer = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
try {
|
|
||||||
const getResponse = await getSqlContainer(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId,
|
|
||||||
params.collectionId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create container failed: container with id ${params.collectionId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
||||||
const resource: ARMTypes.SqlContainerResource = {
|
const resource: ARMTypes.SqlContainerResource = {
|
||||||
id: params.collectionId,
|
id: params.collectionId,
|
||||||
@ -131,23 +120,6 @@ const createSqlContainer = async (params: DataModels.CreateCollectionParams): Pr
|
|||||||
|
|
||||||
const createMongoCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createMongoCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
const mongoWildcardIndexOnAllFields: ARMTypes.MongoIndex[] = [{ key: { keys: ["$**"] } }, { key: { keys: ["_id"] } }];
|
const mongoWildcardIndexOnAllFields: ARMTypes.MongoIndex[] = [{ key: { keys: ["$**"] } }, { key: { keys: ["_id"] } }];
|
||||||
try {
|
|
||||||
const getResponse = await getMongoDBCollection(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId,
|
|
||||||
params.collectionId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create collection failed: collection with id ${params.collectionId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
||||||
const resource: ARMTypes.MongoDBCollectionResource = {
|
const resource: ARMTypes.MongoDBCollectionResource = {
|
||||||
id: params.collectionId,
|
id: params.collectionId,
|
||||||
@ -189,23 +161,6 @@ const createMongoCollection = async (params: DataModels.CreateCollectionParams):
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createCassandraTable = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createCassandraTable = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
try {
|
|
||||||
const getResponse = await getCassandraTable(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId,
|
|
||||||
params.collectionId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create table failed: table with id ${params.collectionId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
||||||
const resource: ARMTypes.CassandraTableResource = {
|
const resource: ARMTypes.CassandraTableResource = {
|
||||||
id: params.collectionId,
|
id: params.collectionId,
|
||||||
@ -233,23 +188,6 @@ const createCassandraTable = async (params: DataModels.CreateCollectionParams):
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createGraph = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createGraph = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
try {
|
|
||||||
const getResponse = await getGremlinGraph(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId,
|
|
||||||
params.collectionId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create graph failed: graph with id ${params.collectionId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
||||||
const resource: ARMTypes.GremlinGraphResource = {
|
const resource: ARMTypes.GremlinGraphResource = {
|
||||||
id: params.collectionId,
|
id: params.collectionId,
|
||||||
@ -284,22 +222,6 @@ const createGraph = async (params: DataModels.CreateCollectionParams): Promise<D
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createTable = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createTable = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
try {
|
|
||||||
const getResponse = await getTable(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.collectionId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create table failed: table with id ${params.collectionId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
const options: ARMTypes.CreateUpdateOptions = constructRpOptions(params);
|
||||||
const resource: ARMTypes.TableResource = {
|
const resource: ARMTypes.TableResource = {
|
||||||
id: params.collectionId,
|
id: params.collectionId,
|
||||||
|
@ -2,20 +2,13 @@ import { DatabaseResponse } from "@azure/cosmos";
|
|||||||
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
|
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
|
import { useDatabases } from "../../Explorer/useDatabases";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import {
|
import { getDatabaseName } from "../../Utils/APITypeUtils";
|
||||||
createUpdateCassandraKeyspace,
|
import { createUpdateCassandraKeyspace } from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
||||||
getCassandraKeyspace,
|
import { createUpdateGremlinDatabase } from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
import { createUpdateMongoDBDatabase } from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
||||||
import {
|
import { createUpdateSqlDatabase } from "../../Utils/arm/generatedClients/cosmos/sqlResources";
|
||||||
createUpdateGremlinDatabase,
|
|
||||||
getGremlinDatabase,
|
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
|
||||||
import {
|
|
||||||
createUpdateMongoDBDatabase,
|
|
||||||
getMongoDBDatabase,
|
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
|
||||||
import { createUpdateSqlDatabase, getSqlDatabase } from "../../Utils/arm/generatedClients/cosmos/sqlResources";
|
|
||||||
import {
|
import {
|
||||||
CassandraKeyspaceCreateUpdateParameters,
|
CassandraKeyspaceCreateUpdateParameters,
|
||||||
CreateUpdateOptions,
|
CreateUpdateOptions,
|
||||||
@ -48,6 +41,11 @@ export async function createDatabase(params: DataModels.CreateDatabaseParams): P
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createDatabaseWithARM(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
async function createDatabaseWithARM(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
||||||
|
if (!useDatabases.getState().validateDatabaseId(params.databaseId)) {
|
||||||
|
const databaseName = getDatabaseName().toLocaleLowerCase();
|
||||||
|
throw new Error(`Create ${databaseName} failed: ${databaseName} with id ${params.databaseId} already exists`);
|
||||||
|
}
|
||||||
|
|
||||||
const { apiType } = userContext;
|
const { apiType } = userContext;
|
||||||
|
|
||||||
switch (apiType) {
|
switch (apiType) {
|
||||||
@ -65,22 +63,6 @@ async function createDatabaseWithARM(params: DataModels.CreateDatabaseParams): P
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createSqlDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
async function createSqlDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
||||||
try {
|
|
||||||
const getResponse = await getSqlDatabase(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create database failed: database with id ${params.databaseId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: CreateUpdateOptions = constructRpOptions(params);
|
const options: CreateUpdateOptions = constructRpOptions(params);
|
||||||
const rpPayload: SqlDatabaseCreateUpdateParameters = {
|
const rpPayload: SqlDatabaseCreateUpdateParameters = {
|
||||||
properties: {
|
properties: {
|
||||||
@ -101,22 +83,6 @@ async function createSqlDatabase(params: DataModels.CreateDatabaseParams): Promi
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createMongoDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
async function createMongoDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
||||||
try {
|
|
||||||
const getResponse = await getMongoDBDatabase(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create database failed: database with id ${params.databaseId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: CreateUpdateOptions = constructRpOptions(params);
|
const options: CreateUpdateOptions = constructRpOptions(params);
|
||||||
const rpPayload: MongoDBDatabaseCreateUpdateParameters = {
|
const rpPayload: MongoDBDatabaseCreateUpdateParameters = {
|
||||||
properties: {
|
properties: {
|
||||||
@ -137,22 +103,6 @@ async function createMongoDatabase(params: DataModels.CreateDatabaseParams): Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createCassandraKeyspace(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
async function createCassandraKeyspace(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
||||||
try {
|
|
||||||
const getResponse = await getCassandraKeyspace(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create database failed: database with id ${params.databaseId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: CreateUpdateOptions = constructRpOptions(params);
|
const options: CreateUpdateOptions = constructRpOptions(params);
|
||||||
const rpPayload: CassandraKeyspaceCreateUpdateParameters = {
|
const rpPayload: CassandraKeyspaceCreateUpdateParameters = {
|
||||||
properties: {
|
properties: {
|
||||||
@ -173,22 +123,6 @@ async function createCassandraKeyspace(params: DataModels.CreateDatabaseParams):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createGremlineDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
async function createGremlineDatabase(params: DataModels.CreateDatabaseParams): Promise<DataModels.Database> {
|
||||||
try {
|
|
||||||
const getResponse = await getGremlinDatabase(
|
|
||||||
userContext.subscriptionId,
|
|
||||||
userContext.resourceGroup,
|
|
||||||
userContext.databaseAccount.name,
|
|
||||||
params.databaseId
|
|
||||||
);
|
|
||||||
if (getResponse?.properties?.resource) {
|
|
||||||
throw new Error(`Create database failed: database with id ${params.databaseId} already exists`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: CreateUpdateOptions = constructRpOptions(params);
|
const options: CreateUpdateOptions = constructRpOptions(params);
|
||||||
const rpPayload: GremlinDatabaseCreateUpdateParameters = {
|
const rpPayload: GremlinDatabaseCreateUpdateParameters = {
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -44,10 +44,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
|
||||||
"container": [Circular],
|
|
||||||
"parameters": [Function],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"databaseId": "test",
|
"databaseId": "test",
|
||||||
"defaultTtl": [Function],
|
"defaultTtl": [Function],
|
||||||
@ -115,10 +111,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
|
||||||
"container": [Circular],
|
|
||||||
"parameters": [Function],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"databaseId": "test",
|
"databaseId": "test",
|
||||||
"defaultTtl": [Function],
|
"defaultTtl": [Function],
|
||||||
|
@ -59,7 +59,6 @@ import TerminalTab from "./Tabs/TerminalTab";
|
|||||||
import Database from "./Tree/Database";
|
import Database from "./Tree/Database";
|
||||||
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
||||||
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
||||||
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
|
||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import { useDatabases } from "./useDatabases";
|
import { useDatabases } from "./useDatabases";
|
||||||
import { useSelectedNode } from "./useSelectedNode";
|
import { useSelectedNode } from "./useSelectedNode";
|
||||||
@ -74,9 +73,6 @@ export default class Explorer {
|
|||||||
// Resource Tree
|
// Resource Tree
|
||||||
private resourceTree: ResourceTreeAdapter;
|
private resourceTree: ResourceTreeAdapter;
|
||||||
|
|
||||||
// Resource Token
|
|
||||||
public resourceTreeForResourceToken: ResourceTreeAdapterForResourceToken;
|
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
public isTabsContentExpanded: ko.Observable<boolean>;
|
public isTabsContentExpanded: ko.Observable<boolean>;
|
||||||
|
|
||||||
@ -186,7 +182,6 @@ export default class Explorer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.resourceTree = new ResourceTreeAdapter(this);
|
this.resourceTree = new ResourceTreeAdapter(this);
|
||||||
this.resourceTreeForResourceToken = new ResourceTreeAdapterForResourceToken(this);
|
|
||||||
|
|
||||||
// Override notebook server parameters from URL parameters
|
// Override notebook server parameters from URL parameters
|
||||||
if (userContext.features.notebookServerUrl && userContext.features.notebookServerToken) {
|
if (userContext.features.notebookServerUrl && userContext.features.notebookServerToken) {
|
||||||
|
@ -153,35 +153,31 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
set({ myNotebooksContentRoot: root });
|
set({ myNotebooksContentRoot: root });
|
||||||
},
|
},
|
||||||
initializeNotebooksTree: async (notebookManager: NotebookManager): Promise<void> => {
|
initializeNotebooksTree: async (notebookManager: NotebookManager): Promise<void> => {
|
||||||
set({
|
const myNotebooksContentRoot = {
|
||||||
myNotebooksContentRoot: {
|
|
||||||
name: "My Notebooks",
|
name: "My Notebooks",
|
||||||
path: get().notebookBasePath,
|
path: get().notebookBasePath,
|
||||||
type: NotebookContentItemType.Directory,
|
type: NotebookContentItemType.Directory,
|
||||||
},
|
};
|
||||||
galleryContentRoot: {
|
const galleryContentRoot = {
|
||||||
name: "Gallery",
|
name: "Gallery",
|
||||||
path: "Gallery",
|
path: "Gallery",
|
||||||
type: NotebookContentItemType.File,
|
type: NotebookContentItemType.File,
|
||||||
},
|
};
|
||||||
});
|
const gitHubNotebooksContentRoot = notebookManager?.gitHubOAuthService?.isLoggedIn()
|
||||||
|
? {
|
||||||
if (notebookManager?.gitHubOAuthService?.isLoggedIn()) {
|
|
||||||
set({
|
|
||||||
gitHubNotebooksContentRoot: {
|
|
||||||
name: "GitHub repos",
|
name: "GitHub repos",
|
||||||
path: "PsuedoDir",
|
path: "PsuedoDir",
|
||||||
type: NotebookContentItemType.Directory,
|
type: NotebookContentItemType.Directory,
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
: undefined;
|
||||||
|
set({
|
||||||
|
myNotebooksContentRoot,
|
||||||
|
galleryContentRoot,
|
||||||
|
gitHubNotebooksContentRoot,
|
||||||
|
});
|
||||||
|
|
||||||
if (get().notebookServerInfo?.notebookServerEndpoint) {
|
if (get().notebookServerInfo?.notebookServerEndpoint) {
|
||||||
const updatedRoot = await notebookManager?.notebookContentClient?.updateItemChildren({
|
const updatedRoot = await notebookManager?.notebookContentClient?.updateItemChildren(myNotebooksContentRoot);
|
||||||
name: "My Notebooks",
|
|
||||||
path: get().notebookBasePath,
|
|
||||||
type: NotebookContentItemType.Directory,
|
|
||||||
});
|
|
||||||
set({ myNotebooksContentRoot: updatedRoot });
|
set({ myNotebooksContentRoot: updatedRoot });
|
||||||
|
|
||||||
if (updatedRoot?.children) {
|
if (updatedRoot?.children) {
|
||||||
|
@ -33,10 +33,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
|||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
|
||||||
"container": [Circular],
|
|
||||||
"parameters": [Function],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"getRepo": [Function],
|
"getRepo": [Function],
|
||||||
"pinRepo": [Function],
|
"pinRepo": [Function],
|
||||||
|
@ -150,9 +150,6 @@
|
|||||||
.backImageIcon {
|
.backImageIcon {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
.entityValueTextField {
|
|
||||||
margin: 24px;
|
|
||||||
}
|
|
||||||
.addEntityDatePicker {
|
.addEntityDatePicker {
|
||||||
max-width: 145px;
|
max-width: 145px;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
|
||||||
"container": [Circular],
|
|
||||||
"parameters": [Function],
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inProgressMessage="Creating directory "
|
inProgressMessage="Creating directory "
|
||||||
|
@ -218,7 +218,7 @@ export const AddTableEntityPanel: FunctionComponent<AddTableEntityPanelProps> =
|
|||||||
|
|
||||||
if (isEntityValuePanelOpen) {
|
if (isEntityValuePanelOpen) {
|
||||||
return (
|
return (
|
||||||
<Stack style={{ margin: "20px 0", padding: "0 34px" }}>
|
<Stack style={{ padding: "20px 34px" }}>
|
||||||
<Stack horizontal {...columnProps}>
|
<Stack horizontal {...columnProps}>
|
||||||
<Image {...backImageProps} src={RevertBackIcon} alt="back" onClick={() => setIsEntityValuePanelFalse()} />
|
<Image {...backImageProps} src={RevertBackIcon} alt="back" onClick={() => setIsEntityValuePanelFalse()} />
|
||||||
<Label>{entityAttributeProperty}</Label>
|
<Label>{entityAttributeProperty}</Label>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { IDropdownOption, Image, IPanelProps, IRenderFunction, Label, Stack, Text, TextField } from "@fluentui/react";
|
import { IDropdownOption, Image, Label, Stack, Text, TextField } from "@fluentui/react";
|
||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import AddPropertyIcon from "../../../../images/Add-property.svg";
|
import AddPropertyIcon from "../../../../images/Add-property.svg";
|
||||||
import RevertBackIcon from "../../../../images/RevertBack.svg";
|
import RevertBackIcon from "../../../../images/RevertBack.svg";
|
||||||
|
import { getErrorMessage, handleError } from "../../../Common/ErrorHandlingUtils";
|
||||||
import { TableEntity } from "../../../Common/TableEntity";
|
import { TableEntity } from "../../../Common/TableEntity";
|
||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import * as TableConstants from "../../Tables/Constants";
|
import * as TableConstants from "../../Tables/Constants";
|
||||||
import * as DataTableUtilities from "../../Tables/DataTable/DataTableUtilities";
|
import * as DataTableUtilities from "../../Tables/DataTable/DataTableUtilities";
|
||||||
@ -14,7 +14,7 @@ import * as Entities from "../../Tables/Entities";
|
|||||||
import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataClient";
|
import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataClient";
|
||||||
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
||||||
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import { PanelContainerComponent } from "../PanelContainerComponent";
|
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||||
import {
|
import {
|
||||||
attributeNameLabel,
|
attributeNameLabel,
|
||||||
attributeValueLabel,
|
attributeValueLabel,
|
||||||
@ -29,7 +29,6 @@ import {
|
|||||||
getEntityValuePlaceholder,
|
getEntityValuePlaceholder,
|
||||||
getFormattedTime,
|
getFormattedTime,
|
||||||
imageProps,
|
imageProps,
|
||||||
isValidEntities,
|
|
||||||
options,
|
options,
|
||||||
} from "./Validators/EntityTableHelper";
|
} from "./Validators/EntityTableHelper";
|
||||||
|
|
||||||
@ -59,12 +58,13 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
|
|||||||
tableEntityListViewModel,
|
tableEntityListViewModel,
|
||||||
cassandraApiClient,
|
cassandraApiClient,
|
||||||
}: EditTableEntityPanelProps): JSX.Element => {
|
}: EditTableEntityPanelProps): JSX.Element => {
|
||||||
const closeSidePanel = useSidePanel((state) => state.closeSidePanel);
|
|
||||||
const [entities, setEntities] = useState<EntityRowType[]>([]);
|
const [entities, setEntities] = useState<EntityRowType[]>([]);
|
||||||
const [selectedRow, setSelectedRow] = useState<number>(0);
|
const [selectedRow, setSelectedRow] = useState<number>(0);
|
||||||
const [entityAttributeValue, setEntityAttributeValue] = useState<string>("");
|
const [entityAttributeValue, setEntityAttributeValue] = useState<string>("");
|
||||||
const [originalDocument, setOriginalDocument] = useState<Entities.ITableEntity>({});
|
const [originalDocument, setOriginalDocument] = useState<Entities.ITableEntity>({});
|
||||||
const [entityAttributeProperty, setEntityAttributeProperty] = useState<string>("");
|
const [entityAttributeProperty, setEntityAttributeProperty] = useState<string>("");
|
||||||
|
const [formError, setFormError] = useState<string>("");
|
||||||
|
const [isExecuting, setIsExecuting] = useState<boolean>(false);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
isEntityValuePanelOpen,
|
isEntityValuePanelOpen,
|
||||||
@ -190,14 +190,26 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
|
|||||||
return displayValue;
|
return displayValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async (event: React.FormEvent<HTMLInputElement>): Promise<void> => {
|
const onSubmit = async (): Promise<void> => {
|
||||||
if (!isValidEntities(entities)) {
|
for (let i = 0; i < entities.length; i++) {
|
||||||
return undefined;
|
const { property, type } = entities[i];
|
||||||
|
if (property === "" || property === undefined) {
|
||||||
|
setFormError(`Property name cannot be empty. Please enter a property name`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
|
||||||
|
if (!type) {
|
||||||
|
setFormError(`Property type cannot be empty. Please select a type from the dropdown for property ${property}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsExecuting(true);
|
||||||
const entity: Entities.ITableEntity = entityFromAttributes(entities);
|
const entity: Entities.ITableEntity = entityFromAttributes(entities);
|
||||||
const newTableDataClient = userContext.apiType === "Cassandra" ? cassandraApiClient : tableDataClient;
|
const newTableDataClient = userContext.apiType === "Cassandra" ? cassandraApiClient : tableDataClient;
|
||||||
const originalDocumentData = userContext.apiType === "Cassandra" ? originalDocument[0] : originalDocument;
|
const originalDocumentData = userContext.apiType === "Cassandra" ? originalDocument[0] : originalDocument;
|
||||||
|
|
||||||
|
try {
|
||||||
const newEntity: Entities.ITableEntity = await newTableDataClient.updateDocument(
|
const newEntity: Entities.ITableEntity = await newTableDataClient.updateDocument(
|
||||||
queryTablesTab.collection,
|
queryTablesTab.collection,
|
||||||
originalDocumentData,
|
originalDocumentData,
|
||||||
@ -209,7 +221,13 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
|
|||||||
}
|
}
|
||||||
tableEntityListViewModel.selected.removeAll();
|
tableEntityListViewModel.selected.removeAll();
|
||||||
tableEntityListViewModel.selected.push(newEntity);
|
tableEntityListViewModel.selected.push(newEntity);
|
||||||
closeSidePanel();
|
} catch (error) {
|
||||||
|
const errorMessage = getErrorMessage(error);
|
||||||
|
handleError(errorMessage, "EditTableRow");
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
setIsExecuting(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const tryInsertNewHeaders = (viewModel: TableEntityListViewModel, newEntity: Entities.ITableEntity): boolean => {
|
const tryInsertNewHeaders = (viewModel: TableEntityListViewModel, newEntity: Entities.ITableEntity): boolean => {
|
||||||
@ -299,10 +317,35 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
|
|||||||
setIsEntityValuePanelTrue();
|
setIsEntityValuePanelTrue();
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderPanelContent = (): JSX.Element => {
|
if (isEntityValuePanelOpen) {
|
||||||
return (
|
return (
|
||||||
<form className="panelFormWrapper">
|
<Stack style={{ padding: "20px 34px" }}>
|
||||||
<div className="panelFormWrapper">
|
<Stack horizontal {...columnProps}>
|
||||||
|
<Image {...backImageProps} src={RevertBackIcon} alt="back" onClick={() => setIsEntityValuePanelFalse()} />
|
||||||
|
<Label>{entityAttributeProperty}</Label>
|
||||||
|
</Stack>
|
||||||
|
<TextField
|
||||||
|
multiline
|
||||||
|
rows={5}
|
||||||
|
value={entityAttributeValue}
|
||||||
|
onChange={(event, newInput?: string) => {
|
||||||
|
setEntityAttributeValue(newInput);
|
||||||
|
entityChange(newInput, selectedRow, "value");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const props: RightPaneFormProps = {
|
||||||
|
formError,
|
||||||
|
isExecuting,
|
||||||
|
submitButtonText: "Update",
|
||||||
|
onSubmit,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RightPaneForm {...props}>
|
||||||
<div className="panelMainContent">
|
<div className="panelMainContent">
|
||||||
{entities.map((entity, index) => {
|
{entities.map((entity, index) => {
|
||||||
return (
|
return (
|
||||||
@ -349,59 +392,6 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
|
|||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{renderPanelFooter()}
|
</RightPaneForm>
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderPanelFooter = (): JSX.Element => {
|
|
||||||
return (
|
|
||||||
<div className="paneFooter">
|
|
||||||
<div className="leftpanel-okbut">
|
|
||||||
<input type="submit" onClick={submit} className="genericPaneSubmitBtn" value="Update Entity" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onRenderNavigationContent: IRenderFunction<IPanelProps> = () => (
|
|
||||||
<Stack horizontal {...columnProps}>
|
|
||||||
<Image {...backImageProps} src={RevertBackIcon} alt="back" onClick={() => setIsEntityValuePanelFalse()} />
|
|
||||||
<Label>{entityAttributeProperty}</Label>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
if (isEntityValuePanelOpen) {
|
|
||||||
return (
|
|
||||||
<PanelContainerComponent
|
|
||||||
headerText=""
|
|
||||||
onRenderNavigationContent={onRenderNavigationContent}
|
|
||||||
panelWidth="700px"
|
|
||||||
isOpen={true}
|
|
||||||
panelContent={
|
|
||||||
<TextField
|
|
||||||
multiline
|
|
||||||
rows={5}
|
|
||||||
className="entityValueTextField"
|
|
||||||
value={entityAttributeValue}
|
|
||||||
onChange={(event, newInput?: string) => {
|
|
||||||
setEntityAttributeValue(newInput);
|
|
||||||
entityChange(newInput, selectedRow, "value");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
isConsoleExpanded={false}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PanelContainerComponent
|
|
||||||
headerText="Edit Table Entity"
|
|
||||||
panelWidth="700px"
|
|
||||||
isOpen={true}
|
|
||||||
panelContent={renderPanelContent()}
|
|
||||||
isConsoleExpanded={false}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -80,7 +80,7 @@ export const int64Placeholder = "Enter a signed 64-bit integer, in the range (-2
|
|||||||
|
|
||||||
export const columnProps: Partial<IStackProps> = {
|
export const columnProps: Partial<IStackProps> = {
|
||||||
tokens: { childrenGap: 10 },
|
tokens: { childrenGap: 10 },
|
||||||
styles: { root: { width: 680, marginBottom: 8 } },
|
styles: { root: { marginBottom: 8 } },
|
||||||
};
|
};
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -158,7 +158,8 @@ export default class QueryTablesTab extends TabsBase {
|
|||||||
queryTablesTab={this}
|
queryTablesTab={this}
|
||||||
tableEntityListViewModel={this.tableEntityListViewModel()}
|
tableEntityListViewModel={this.tableEntityListViewModel()}
|
||||||
cassandraApiClient={new CassandraAPIDataClient()}
|
cassandraApiClient={new CassandraAPIDataClient()}
|
||||||
/>
|
/>,
|
||||||
|
"700px"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,45 +1,18 @@
|
|||||||
import * as ko from "knockout";
|
import React from "react";
|
||||||
import * as React from "react";
|
|
||||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||||
import { ReactAdapter } from "../../Bindings/ReactBindingHandler";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { useTabs } from "../../hooks/useTabs";
|
import { useTabs } from "../../hooks/useTabs";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { TreeComponent, TreeNode } from "../Controls/TreeComponent/TreeComponent";
|
import { TreeComponent, TreeNode } from "../Controls/TreeComponent/TreeComponent";
|
||||||
import Explorer from "../Explorer";
|
|
||||||
import { useCommandBar } from "../Menus/CommandBar/CommandBarComponentAdapter";
|
import { useCommandBar } from "../Menus/CommandBar/CommandBarComponentAdapter";
|
||||||
import { mostRecentActivity } from "../MostRecentActivity/MostRecentActivity";
|
import { mostRecentActivity } from "../MostRecentActivity/MostRecentActivity";
|
||||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
|
||||||
import { useDatabases } from "../useDatabases";
|
import { useDatabases } from "../useDatabases";
|
||||||
import { useSelectedNode } from "../useSelectedNode";
|
import { useSelectedNode } from "../useSelectedNode";
|
||||||
|
|
||||||
export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
export const ResourceTokenTree: React.FC = (): JSX.Element => {
|
||||||
public parameters: ko.Observable<number>;
|
const collection = useDatabases((state) => state.resourceTokenCollection);
|
||||||
public myNotebooksContentRoot: NotebookContentItem;
|
|
||||||
|
|
||||||
public constructor(private container: Explorer) {
|
const buildCollectionNode = (): TreeNode => {
|
||||||
this.parameters = ko.observable(Date.now());
|
|
||||||
|
|
||||||
useDatabases.subscribe(
|
|
||||||
() => this.triggerRender(),
|
|
||||||
(state) => state.resourceTokenCollection
|
|
||||||
);
|
|
||||||
useSelectedNode.subscribe(() => this.triggerRender());
|
|
||||||
useTabs.subscribe(
|
|
||||||
() => this.triggerRender(),
|
|
||||||
(state) => state.activeTab
|
|
||||||
);
|
|
||||||
|
|
||||||
this.triggerRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
public renderComponent(): JSX.Element {
|
|
||||||
const dataRootNode = this.buildCollectionNode();
|
|
||||||
return <TreeComponent className="dataResourceTree" rootNode={dataRootNode} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
public buildCollectionNode(): TreeNode {
|
|
||||||
const collection: ViewModels.CollectionBase = useDatabases.getState().resourceTokenCollection;
|
|
||||||
if (!collection) {
|
if (!collection) {
|
||||||
return {
|
return {
|
||||||
label: undefined,
|
label: undefined,
|
||||||
@ -86,9 +59,7 @@ export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
|||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
children: [collectionNode],
|
children: [collectionNode],
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
public triggerRender() {
|
return <TreeComponent className="dataResourceTree" rootNode={buildCollectionNode()} />;
|
||||||
window.requestAnimationFrame(() => this.parameters(Date.now()));
|
};
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
import { shallow } from "enzyme";
|
|
||||||
import React from "react";
|
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
|
||||||
import { TreeComponent, TreeComponentProps, TreeNode } from "../Controls/TreeComponent/TreeComponent";
|
|
||||||
import Explorer from "../Explorer";
|
|
||||||
import { useDatabases } from "../useDatabases";
|
|
||||||
import ResourceTokenCollection from "./ResourceTokenCollection";
|
|
||||||
import { ResourceTreeAdapterForResourceToken } from "./ResourceTreeAdapterForResourceToken";
|
|
||||||
|
|
||||||
describe("Resource tree for resource token", () => {
|
|
||||||
const mockContainer = {} as Explorer;
|
|
||||||
const resourceTree = new ResourceTreeAdapterForResourceToken(mockContainer);
|
|
||||||
const mockCollection = {
|
|
||||||
_rid: "fakeRid",
|
|
||||||
_self: "fakeSelf",
|
|
||||||
id: "fakeId",
|
|
||||||
} as DataModels.Collection;
|
|
||||||
const mockResourceTokenCollection: ViewModels.CollectionBase = new ResourceTokenCollection(
|
|
||||||
mockContainer,
|
|
||||||
"fakeDatabaseId",
|
|
||||||
mockCollection
|
|
||||||
);
|
|
||||||
useDatabases.setState({ resourceTokenCollection: mockResourceTokenCollection });
|
|
||||||
|
|
||||||
it("should render", () => {
|
|
||||||
const rootNode: TreeNode = resourceTree.buildCollectionNode();
|
|
||||||
const props: TreeComponentProps = {
|
|
||||||
rootNode,
|
|
||||||
className: "dataResourceTree",
|
|
||||||
};
|
|
||||||
const wrapper = shallow(<TreeComponent {...props} />);
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,36 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`Resource tree for resource token should render 1`] = `
|
|
||||||
<div
|
|
||||||
className="treeComponent dataResourceTree"
|
|
||||||
role="tree"
|
|
||||||
>
|
|
||||||
<TreeNodeComponent
|
|
||||||
generation={0}
|
|
||||||
node={
|
|
||||||
Object {
|
|
||||||
"children": Array [
|
|
||||||
Object {
|
|
||||||
"children": Array [
|
|
||||||
Object {
|
|
||||||
"isSelected": [Function],
|
|
||||||
"label": "Items",
|
|
||||||
"onClick": [Function],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"className": "collectionHeader",
|
|
||||||
"iconSrc": "",
|
|
||||||
"isExpanded": true,
|
|
||||||
"isSelected": [Function],
|
|
||||||
"label": "fakeId",
|
|
||||||
"onClick": [Function],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"isExpanded": true,
|
|
||||||
"label": undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paddingLeft={0}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
`;
|
|
@ -19,6 +19,8 @@ interface DatabasesState {
|
|||||||
loadDatabaseOffers: () => Promise<void>;
|
loadDatabaseOffers: () => Promise<void>;
|
||||||
isFirstResourceCreated: () => boolean;
|
isFirstResourceCreated: () => boolean;
|
||||||
findSelectedDatabase: () => ViewModels.Database;
|
findSelectedDatabase: () => ViewModels.Database;
|
||||||
|
validateDatabaseId: (id: string) => boolean;
|
||||||
|
validateCollectionId: (databaseId: string, collectionId: string) => Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
|
export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
|
||||||
@ -129,4 +131,12 @@ export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
|
|||||||
|
|
||||||
return selectedNode.collection?.database;
|
return selectedNode.collection?.database;
|
||||||
},
|
},
|
||||||
|
validateDatabaseId: (id: string): boolean => {
|
||||||
|
return !get().databases.some((database) => database.id() === id);
|
||||||
|
},
|
||||||
|
validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => {
|
||||||
|
const database = get().databases.find((db) => db.id() === databaseId);
|
||||||
|
await database.loadCollections();
|
||||||
|
return !database.collections().some((collection) => collection.id() === collectionId);
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
23
src/Index.ts
23
src/Index.ts
@ -1,23 +0,0 @@
|
|||||||
import "../less/index.less";
|
|
||||||
import "./Libs/jquery";
|
|
||||||
|
|
||||||
import * as ko from "knockout";
|
|
||||||
|
|
||||||
class Index {
|
|
||||||
public navigationSelection: ko.Observable<string>;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.navigationSelection = ko.observable("quickstart");
|
|
||||||
}
|
|
||||||
|
|
||||||
public quickstart_click() {
|
|
||||||
this.navigationSelection("quickstart");
|
|
||||||
}
|
|
||||||
|
|
||||||
public explorer_click() {
|
|
||||||
this.navigationSelection("explorer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = new Index();
|
|
||||||
ko.applyBindings(index);
|
|
66
src/Index.tsx
Normal file
66
src/Index.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import ReactDOM from "react-dom";
|
||||||
|
import Arrow from "../images/Arrow.svg";
|
||||||
|
import CosmosDB_20170829 from "../images/CosmosDB_20170829.svg";
|
||||||
|
import Explorer from "../images/Explorer.svg";
|
||||||
|
import Feedback from "../images/Feedback.svg";
|
||||||
|
import Quickstart from "../images/Quickstart.svg";
|
||||||
|
import "../less/index.less";
|
||||||
|
|
||||||
|
const Index = (): JSX.Element => {
|
||||||
|
const [navigationSelection, setNavigationSelection] = useState("quickstart");
|
||||||
|
|
||||||
|
const quickstart_click = () => {
|
||||||
|
setNavigationSelection("quickstart");
|
||||||
|
};
|
||||||
|
|
||||||
|
const explorer_click = () => {
|
||||||
|
setNavigationSelection("explorer");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<header className="header HeaderBg">
|
||||||
|
<div className="items">
|
||||||
|
<img className="DocDBicon" src={CosmosDB_20170829} alt="Azure Cosmos DB" />
|
||||||
|
<a className="createdocdbacnt" href="https://aka.ms/documentdbcreate" rel="noreferrer" target="_blank">
|
||||||
|
Create an Azure Cosmos DB account <img className="rightarrowimg" src={Arrow} alt="" />
|
||||||
|
</a>
|
||||||
|
<span className="title">Azure Cosmos DB Emulator</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<nav className="fixedleftpane">
|
||||||
|
<div
|
||||||
|
id="Quickstart"
|
||||||
|
onClick={quickstart_click}
|
||||||
|
className={navigationSelection === "quickstart" ? "topSelected" : ""}
|
||||||
|
>
|
||||||
|
<img id="imgiconwidth1" src={Quickstart} alt="Open Quick Start" />
|
||||||
|
<span className="menuQuickStart">Quickstart</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="Explorer" onClick={explorer_click} className={navigationSelection === "explorer" ? "topSelected" : ""}>
|
||||||
|
<img id="imgiconwidth1" src={Explorer} alt="Open Data Explorer" />
|
||||||
|
<span className="menuExplorer">Explorer</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a className="feedbackstyle" href="https://aka.ms/cosmosdbfeedback?subject=Cosmos%20DB%20Emulator%20Feedback">
|
||||||
|
<img id="imgiconwidth1" src={Feedback} alt="Report Issue" />
|
||||||
|
<span className="menuExplorer">Report Issue</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{navigationSelection === "quickstart" && (
|
||||||
|
<iframe name="quickstart" className="iframe" src="quickstart.html"></iframe>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{navigationSelection === "explorer" && (
|
||||||
|
<iframe name="explorer" className="iframe" src="explorer.html?platform=Emulator"></iframe>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ReactDOM.render(<Index />, document.getElementById("root"));
|
@ -40,7 +40,7 @@
|
|||||||
"CosmosD4Details": "General Purpose Cosmos Compute with 4 vCPUs, 16 GB Memory",
|
"CosmosD4Details": "General Purpose Cosmos Compute with 4 vCPUs, 16 GB Memory",
|
||||||
"CosmosD8Details": "General Purpose Cosmos Compute with 8 vCPUs, 32 GB Memory",
|
"CosmosD8Details": "General Purpose Cosmos Compute with 8 vCPUs, 32 GB Memory",
|
||||||
"CosmosD16Details": "General Purpose Cosmos Compute with 16 vCPUs, 64 GB Memory",
|
"CosmosD16Details": "General Purpose Cosmos Compute with 16 vCPUs, 64 GB Memory",
|
||||||
"Cost": "Cost",
|
"ApproximateCost": "Approximate Cost Per Hour",
|
||||||
"CostText": "Hourly cost of the dedicated gateway resource depends on the SKU selection, number of instances per region, and number of regions.",
|
"CostText": "Hourly cost of the dedicated gateway resource depends on the SKU selection, number of instances per region, and number of regions.",
|
||||||
"ConnectionString": "Connection String",
|
"ConnectionString": "Connection String",
|
||||||
"ConnectionStringText": "To use the dedicated gateway, use the connection string shown in ",
|
"ConnectionStringText": "To use the dedicated gateway, use the connection string shown in ",
|
||||||
|
@ -4,7 +4,12 @@ import { armRequestWithoutPolling } from "../../Utils/arm/request";
|
|||||||
import { selfServeTraceFailure, selfServeTraceStart, selfServeTraceSuccess } from "../SelfServeTelemetryProcessor";
|
import { selfServeTraceFailure, selfServeTraceStart, selfServeTraceSuccess } from "../SelfServeTelemetryProcessor";
|
||||||
import { RefreshResult } from "../SelfServeTypes";
|
import { RefreshResult } from "../SelfServeTypes";
|
||||||
import SqlX from "./SqlX";
|
import SqlX from "./SqlX";
|
||||||
import { SqlxServiceResource, UpdateDedicatedGatewayRequestParameters } from "./SqlxTypes";
|
import {
|
||||||
|
FetchPricesResponse,
|
||||||
|
RegionsResponse,
|
||||||
|
SqlxServiceResource,
|
||||||
|
UpdateDedicatedGatewayRequestParameters,
|
||||||
|
} from "./SqlxTypes";
|
||||||
|
|
||||||
const apiVersion = "2021-04-01-preview";
|
const apiVersion = "2021-04-01-preview";
|
||||||
|
|
||||||
@ -128,3 +133,67 @@ export const refreshDedicatedGatewayProvisioning = async (): Promise<RefreshResu
|
|||||||
return { isUpdateInProgress: false, updateInProgressMessageTKey: undefined };
|
return { isUpdateInProgress: false, updateInProgressMessageTKey: undefined };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getGeneralPath = (subscriptionId: string, resourceGroup: string, name: string): string => {
|
||||||
|
return `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${name}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getReadRegions = async (): Promise<Array<string>> => {
|
||||||
|
try {
|
||||||
|
const readRegions = new Array<string>();
|
||||||
|
|
||||||
|
const response = await armRequestWithoutPolling<RegionsResponse>({
|
||||||
|
host: configContext.ARM_ENDPOINT,
|
||||||
|
path: getGeneralPath(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name),
|
||||||
|
method: "GET",
|
||||||
|
apiVersion: "2021-04-01-preview",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.result.location !== undefined) {
|
||||||
|
readRegions.push(response.result.location.replace(" ", "").toLowerCase());
|
||||||
|
} else {
|
||||||
|
for (const location of response.result.locations) {
|
||||||
|
readRegions.push(location.locationName.replace(" ", "").toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return readRegions;
|
||||||
|
} catch (err) {
|
||||||
|
return new Array<string>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getFetchPricesPathForRegion = (subscriptionId: string): string => {
|
||||||
|
return `/subscriptions/${subscriptionId}/providers/Microsoft.CostManagement/fetchPrices`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPriceMap = async (regions: Array<string>): Promise<Map<string, Map<string, number>>> => {
|
||||||
|
try {
|
||||||
|
const priceMap = new Map<string, Map<string, number>>();
|
||||||
|
|
||||||
|
for (const region of regions) {
|
||||||
|
const regionPriceMap = new Map<string, number>();
|
||||||
|
|
||||||
|
const response = await armRequestWithoutPolling<FetchPricesResponse>({
|
||||||
|
host: configContext.ARM_ENDPOINT,
|
||||||
|
path: getFetchPricesPathForRegion(userContext.subscriptionId),
|
||||||
|
method: "POST",
|
||||||
|
apiVersion: "2020-01-01-preview",
|
||||||
|
queryParams: {
|
||||||
|
filter:
|
||||||
|
"armRegionName eq '" +
|
||||||
|
region +
|
||||||
|
"' and serviceFamily eq 'Databases' and productName eq 'Azure Cosmos DB Dedicated Gateway - General Purpose'",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const item of response.result.Items) {
|
||||||
|
regionPriceMap.set(item.skuName, item.retailPrice);
|
||||||
|
}
|
||||||
|
priceMap.set(region, regionPriceMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return priceMap;
|
||||||
|
} catch (err) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -16,11 +16,13 @@ import { BladeType, generateBladeLink } from "../SelfServeUtils";
|
|||||||
import {
|
import {
|
||||||
deleteDedicatedGatewayResource,
|
deleteDedicatedGatewayResource,
|
||||||
getCurrentProvisioningState,
|
getCurrentProvisioningState,
|
||||||
|
getPriceMap,
|
||||||
|
getReadRegions,
|
||||||
refreshDedicatedGatewayProvisioning,
|
refreshDedicatedGatewayProvisioning,
|
||||||
updateDedicatedGatewayResource,
|
updateDedicatedGatewayResource,
|
||||||
} from "./SqlX.rp";
|
} from "./SqlX.rp";
|
||||||
|
|
||||||
const costPerHourValue: Description = {
|
const costPerHourDefaultValue: Description = {
|
||||||
textTKey: "CostText",
|
textTKey: "CostText",
|
||||||
type: DescriptionType.Text,
|
type: DescriptionType.Text,
|
||||||
link: {
|
link: {
|
||||||
@ -53,7 +55,10 @@ const CosmosD16s = "Cosmos.D16s";
|
|||||||
|
|
||||||
const onSKUChange = (newValue: InputType, currentValues: Map<string, SmartUiInput>): Map<string, SmartUiInput> => {
|
const onSKUChange = (newValue: InputType, currentValues: Map<string, SmartUiInput>): Map<string, SmartUiInput> => {
|
||||||
currentValues.set("sku", { value: newValue });
|
currentValues.set("sku", { value: newValue });
|
||||||
currentValues.set("costPerHour", { value: costPerHourValue });
|
currentValues.set("costPerHour", {
|
||||||
|
value: calculateCost(newValue as string, currentValues.get("instances").value as number),
|
||||||
|
});
|
||||||
|
|
||||||
return currentValues;
|
return currentValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,6 +84,11 @@ const onNumberOfInstancesChange = (
|
|||||||
} else {
|
} else {
|
||||||
currentValues.set("warningBanner", undefined);
|
currentValues.set("warningBanner", undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentValues.set("costPerHour", {
|
||||||
|
value: calculateCost(currentValues.get("sku").value as string, newValue as number),
|
||||||
|
});
|
||||||
|
|
||||||
return currentValues;
|
return currentValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,6 +121,11 @@ const onEnableDedicatedGatewayChange = (
|
|||||||
} as Description,
|
} as Description,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currentValues.set("costPerHour", {
|
||||||
|
value: calculateCost(baselineValues.get("sku").value as string, baselineValues.get("instances").value as number),
|
||||||
|
hidden: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
currentValues.set("warningBanner", {
|
currentValues.set("warningBanner", {
|
||||||
value: {
|
value: {
|
||||||
@ -122,6 +137,8 @@ const onEnableDedicatedGatewayChange = (
|
|||||||
} as Description,
|
} as Description,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currentValues.set("costPerHour", { value: costPerHourDefaultValue, hidden: true });
|
||||||
}
|
}
|
||||||
const sku = currentValues.get("sku");
|
const sku = currentValues.get("sku");
|
||||||
const instances = currentValues.get("instances");
|
const instances = currentValues.get("instances");
|
||||||
@ -137,7 +154,6 @@ const onEnableDedicatedGatewayChange = (
|
|||||||
disabled: dedicatedGatewayOriginallyEnabled,
|
disabled: dedicatedGatewayOriginallyEnabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
currentValues.set("costPerHour", { value: costPerHourValue, hidden: hideAttributes });
|
|
||||||
currentValues.set("connectionString", {
|
currentValues.set("connectionString", {
|
||||||
value: connectionStringValue,
|
value: connectionStringValue,
|
||||||
hidden: !newValue || !dedicatedGatewayOriginallyEnabled,
|
hidden: !newValue || !dedicatedGatewayOriginallyEnabled,
|
||||||
@ -177,6 +193,40 @@ const NumberOfInstancesDropdownInfo: Info = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ApproximateCostDropDownInfo: Info = {
|
||||||
|
messageTKey: "CostText",
|
||||||
|
link: {
|
||||||
|
href: "https://aka.ms/cosmos-db-dedicated-gateway-pricing",
|
||||||
|
textTKey: "DedicatedGatewayPricing",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let priceMap: Map<string, Map<string, number>>;
|
||||||
|
let regions: Array<string>;
|
||||||
|
|
||||||
|
const calculateCost = (skuName: string, instanceCount: number): Description => {
|
||||||
|
try {
|
||||||
|
let costPerHour = 0;
|
||||||
|
for (const region of regions) {
|
||||||
|
const incrementalCost = priceMap.get(region).get(skuName.replace("Cosmos.", ""));
|
||||||
|
if (incrementalCost === undefined) {
|
||||||
|
throw new Error("Value not found in map.");
|
||||||
|
}
|
||||||
|
costPerHour += incrementalCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
costPerHour *= instanceCount;
|
||||||
|
costPerHour = Math.round(costPerHour * 100) / 100;
|
||||||
|
|
||||||
|
return {
|
||||||
|
textTKey: `${costPerHour} USD`,
|
||||||
|
type: DescriptionType.Text,
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return costPerHourDefaultValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@IsDisplayable()
|
@IsDisplayable()
|
||||||
@RefreshOptions({ retryIntervalInMs: 20000 })
|
@RefreshOptions({ retryIntervalInMs: 20000 })
|
||||||
export default class SqlX extends SelfServeBaseClass {
|
export default class SqlX extends SelfServeBaseClass {
|
||||||
@ -274,12 +324,15 @@ export default class SqlX extends SelfServeBaseClass {
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
regions = await getReadRegions();
|
||||||
|
priceMap = await getPriceMap(regions);
|
||||||
|
|
||||||
const response = await getCurrentProvisioningState();
|
const response = await getCurrentProvisioningState();
|
||||||
if (response.status && response.status !== "Deleting") {
|
if (response.status && response.status !== "Deleting") {
|
||||||
defaults.set("enableDedicatedGateway", { value: true });
|
defaults.set("enableDedicatedGateway", { value: true });
|
||||||
defaults.set("sku", { value: response.sku, disabled: true });
|
defaults.set("sku", { value: response.sku, disabled: true });
|
||||||
defaults.set("instances", { value: response.instances, disabled: false });
|
defaults.set("instances", { value: response.instances, disabled: false });
|
||||||
defaults.set("costPerHour", { value: costPerHourValue });
|
defaults.set("costPerHour", { value: calculateCost(response.sku, response.instances) });
|
||||||
defaults.set("connectionString", {
|
defaults.set("connectionString", {
|
||||||
value: connectionStringValue,
|
value: connectionStringValue,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
@ -338,8 +391,9 @@ export default class SqlX extends SelfServeBaseClass {
|
|||||||
})
|
})
|
||||||
instances: number;
|
instances: number;
|
||||||
|
|
||||||
|
@PropertyInfo(ApproximateCostDropDownInfo)
|
||||||
@Values({
|
@Values({
|
||||||
labelTKey: "Cost",
|
labelTKey: "ApproximateCost",
|
||||||
isDynamicDescription: true,
|
isDynamicDescription: true,
|
||||||
})
|
})
|
||||||
costPerHour: string;
|
costPerHour: string;
|
||||||
|
@ -29,3 +29,23 @@ export type UpdateDedicatedGatewayRequestProperties = {
|
|||||||
instanceCount: number;
|
instanceCount: number;
|
||||||
serviceType: string;
|
serviceType: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type FetchPricesResponse = {
|
||||||
|
Items: Array<PriceItem>;
|
||||||
|
NextPageLink: string | undefined;
|
||||||
|
Count: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PriceItem = {
|
||||||
|
retailPrice: number;
|
||||||
|
skuName: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RegionsResponse = {
|
||||||
|
locations: Array<RegionItem>;
|
||||||
|
location: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RegionItem = {
|
||||||
|
locationName: string;
|
||||||
|
};
|
||||||
|
@ -8,54 +8,7 @@
|
|||||||
|
|
||||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header class="header HeaderBg">
|
<div id="root"></div>
|
||||||
<div class="items">
|
|
||||||
<img class="DocDBicon" src="/CosmosDB_20170829.svg" alt="Azure Cosmos DB" />
|
|
||||||
<a class="createdocdbacnt" href="https://aka.ms/documentdbcreate" target="_blank">
|
|
||||||
Create an Azure Cosmos DB account <img class="rightarrowimg" src="/Arrow.svg" alt="" />
|
|
||||||
</a>
|
|
||||||
<span class="title">Azure Cosmos DB Emulator</span>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<nav class="fixedleftpane">
|
|
||||||
<div
|
|
||||||
id="Quickstart"
|
|
||||||
data-bind="click: quickstart_click, css:{ topSelected: navigationSelection() === 'quickstart' }"
|
|
||||||
>
|
|
||||||
<img id="imgiconwidth1" src="/Quickstart.svg" alt="Open Quick Start" />
|
|
||||||
<span class="menuQuickStart">Quickstart</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="Explorer" data-bind="click: explorer_click, css:{ topSelected: navigationSelection() === 'explorer' }">
|
|
||||||
<img id="imgiconwidth1" src="/Explorer.svg" alt="Open Data Explorer" />
|
|
||||||
<span class="menuExplorer">Explorer</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<a class="feedbackstyle" href="https://aka.ms/cosmosdbfeedback?subject=Cosmos%20DB%20Emulator%20Feedback">
|
|
||||||
<img id="imgiconwidth1" src="/Feedback.svg" alt="Report Issue" />
|
|
||||||
<span class="menuExplorer">Report Issue</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<iframe
|
|
||||||
name="quickstart"
|
|
||||||
class="iframe"
|
|
||||||
src="quickstart.html"
|
|
||||||
data-bind="visible: navigationSelection() === 'quickstart'"
|
|
||||||
>
|
|
||||||
</iframe>
|
|
||||||
|
|
||||||
<iframe
|
|
||||||
name="explorer"
|
|
||||||
class="iframe"
|
|
||||||
src="explorer.html?platform=Emulator"
|
|
||||||
data-bind="visible: navigationSelection() === 'explorer'"
|
|
||||||
>
|
|
||||||
</iframe>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateUniqueName } from "../utils/shared";
|
import { generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(120000);
|
jest.setTimeout(120000);
|
||||||
|
|
||||||
test("Cassandra keyspace and table CRUD", async () => {
|
test("Cassandra keyspace and table CRUD", async () => {
|
||||||
const keyspaceId = generateUniqueName("keyspace");
|
const keyspaceId = generateUniqueName("keyspace");
|
||||||
const tableId = generateUniqueName("table");
|
const tableId = generateUniqueName("table");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-cassandra-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-cassandra-runner");
|
||||||
await page.waitForSelector("iframe");
|
await page.waitForSelector("iframe");
|
||||||
const explorer = page.frame({
|
const explorer = await waitForExplorer();
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
await explorer.click('[data-test="New Table"]');
|
await explorer.click('[data-test="New Table"]');
|
||||||
await explorer.click('[aria-label="Keyspace id"]');
|
await explorer.click('[aria-label="Keyspace id"]');
|
||||||
@ -19,7 +19,7 @@ test("Cassandra keyspace and table CRUD", async () => {
|
|||||||
await explorer.click('[aria-label="addCollection-tableId"]');
|
await explorer.click('[aria-label="addCollection-tableId"]');
|
||||||
await explorer.fill('[aria-label="addCollection-tableId"]', tableId);
|
await explorer.fill('[aria-label="addCollection-tableId"]', tableId);
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
await explorer.click(`.nodeItem >> text=${keyspaceId}`, { timeout: 50000 });
|
await explorer.click(`.nodeItem >> text=${keyspaceId}`);
|
||||||
await explorer.click(`[data-test="${tableId}"] [aria-label="More"]`);
|
await explorer.click(`[data-test="${tableId}"] [aria-label="More"]`);
|
||||||
await explorer.click('button[role="menuitem"]:has-text("Delete Table")');
|
await explorer.click('button[role="menuitem"]:has-text("Delete Table")');
|
||||||
await explorer.fill('text=* Confirm by typing the table id >> input[type="text"]', tableId);
|
await explorer.fill('text=* Confirm by typing the table id >> input[type="text"]', tableId);
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(240000);
|
jest.setTimeout(240000);
|
||||||
|
|
||||||
test("Graph CRUD", async () => {
|
test("Graph CRUD", async () => {
|
||||||
const databaseId = generateDatabaseNameWithTimestamp();
|
const databaseId = generateDatabaseNameWithTimestamp();
|
||||||
const containerId = generateUniqueName("container");
|
const containerId = generateUniqueName("container");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-gremlin-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-gremlin-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create new database and graph
|
// Create new database and graph
|
||||||
await explorer.click('[data-test="New Graph"]');
|
await explorer.click('[data-test="New Graph"]');
|
||||||
@ -19,7 +18,7 @@ test("Graph CRUD", async () => {
|
|||||||
await explorer.fill('[aria-label="Graph id"]', containerId);
|
await explorer.fill('[aria-label="Graph id"]', containerId);
|
||||||
await explorer.fill('[aria-label="Partition key"]', "/pk");
|
await explorer.fill('[aria-label="Partition key"]', "/pk");
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
await explorer.click(`.nodeItem >> text=${databaseId}`, { timeout: 50000 });
|
await explorer.click(`.nodeItem >> text=${databaseId}`);
|
||||||
await explorer.click(`.nodeItem >> text=${containerId}`);
|
await explorer.click(`.nodeItem >> text=${containerId}`);
|
||||||
// Delete database and graph
|
// Delete database and graph
|
||||||
await explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
await explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(240000);
|
jest.setTimeout(240000);
|
||||||
|
|
||||||
test("Mongo CRUD", async () => {
|
test("Mongo CRUD", async () => {
|
||||||
const databaseId = generateDatabaseNameWithTimestamp();
|
const databaseId = generateDatabaseNameWithTimestamp();
|
||||||
const containerId = generateUniqueName("container");
|
const containerId = generateUniqueName("container");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create new database and collection
|
// Create new database and collection
|
||||||
await explorer.click('[data-test="New Collection"]');
|
await explorer.click('[data-test="New Collection"]');
|
||||||
@ -19,7 +18,7 @@ test("Mongo CRUD", async () => {
|
|||||||
await explorer.fill('[aria-label="Collection id"]', containerId);
|
await explorer.fill('[aria-label="Collection id"]', containerId);
|
||||||
await explorer.fill('[aria-label="Shard key"]', "/pk");
|
await explorer.fill('[aria-label="Shard key"]', "/pk");
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
await explorer.click(`.nodeItem >> text=${databaseId}`, { timeout: 50000 });
|
await explorer.click(`.nodeItem >> text=${databaseId}`);
|
||||||
await explorer.click(`.nodeItem >> text=${containerId}`);
|
await explorer.click(`.nodeItem >> text=${containerId}`);
|
||||||
// Create indexing policy
|
// Create indexing policy
|
||||||
await explorer.click(".nodeItem >> text=Settings");
|
await explorer.click(".nodeItem >> text=Settings");
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
import { generateDatabaseNameWithTimestamp, generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(240000);
|
jest.setTimeout(240000);
|
||||||
|
|
||||||
test("Mongo CRUD", async () => {
|
test("Mongo CRUD", async () => {
|
||||||
const databaseId = generateDatabaseNameWithTimestamp();
|
const databaseId = generateDatabaseNameWithTimestamp();
|
||||||
const containerId = generateUniqueName("container");
|
const containerId = generateUniqueName("container");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo32-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo32-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create new database and collection
|
// Create new database and collection
|
||||||
await explorer.click('[data-test="New Collection"]');
|
await explorer.click('[data-test="New Collection"]');
|
||||||
@ -19,7 +18,7 @@ test("Mongo CRUD", async () => {
|
|||||||
await explorer.fill('[aria-label="Collection id"]', containerId);
|
await explorer.fill('[aria-label="Collection id"]', containerId);
|
||||||
await explorer.fill('[aria-label="Shard key"]', "pk");
|
await explorer.fill('[aria-label="Shard key"]', "pk");
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
explorer.click(`.nodeItem >> text=${databaseId}`, { timeout: 50000 });
|
explorer.click(`.nodeItem >> text=${databaseId}`);
|
||||||
explorer.click(`.nodeItem >> text=${containerId}`);
|
explorer.click(`.nodeItem >> text=${containerId}`);
|
||||||
// Delete database and collection
|
// Delete database and collection
|
||||||
explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
||||||
|
@ -2,6 +2,7 @@ import { jest } from "@jest/globals";
|
|||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(240000);
|
jest.setTimeout(240000);
|
||||||
|
|
||||||
const filename = "GettingStarted.ipynb";
|
const filename = "GettingStarted.ipynb";
|
||||||
@ -11,10 +12,7 @@ fs.copyFileSync(path.join(__dirname, filename), path.join(__dirname, fileToUploa
|
|||||||
|
|
||||||
test("Notebooks", async () => {
|
test("Notebooks", async () => {
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-sql-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-sql-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
// Upload and Delete Notebook
|
// Upload and Delete Notebook
|
||||||
await explorer.click('[data-test="My Notebooks"] [aria-label="More"]');
|
await explorer.click('[data-test="My Notebooks"] [aria-label="More"]');
|
||||||
await explorer.click('button[role="menuitem"]:has-text("Upload File")');
|
await explorer.click('button[role="menuitem"]:has-text("Upload File")');
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateUniqueName } from "../utils/shared";
|
import { generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
jest.setTimeout(120000);
|
jest.setTimeout(120000);
|
||||||
|
|
||||||
test("SQL CRUD", async () => {
|
test("SQL CRUD", async () => {
|
||||||
const databaseId = generateUniqueName("db");
|
const databaseId = generateUniqueName("db");
|
||||||
const containerId = generateUniqueName("container");
|
const containerId = generateUniqueName("container");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-sql-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-sql-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
await explorer.click('[data-test="New Container"]');
|
await explorer.click('[data-test="New Container"]');
|
||||||
await explorer.fill('[aria-label="New database id"]', databaseId);
|
await explorer.fill('[aria-label="New database id"]', databaseId);
|
||||||
await explorer.fill('[aria-label="Container id"]', containerId);
|
await explorer.fill('[aria-label="Container id"]', containerId);
|
||||||
await explorer.fill('[aria-label="Partition key"]', "/pk");
|
await explorer.fill('[aria-label="Partition key"]', "/pk");
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
await explorer.click(`.nodeItem >> text=${databaseId}`, { timeout: 50000 });
|
await explorer.click(`.nodeItem >> text=${databaseId}`);
|
||||||
await explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
await explorer.click(`[data-test="${containerId}"] [aria-label="More"]`);
|
||||||
await explorer.click('button[role="menuitem"]:has-text("Delete Container")');
|
await explorer.click('button[role="menuitem"]:has-text("Delete Container")');
|
||||||
await explorer.fill('text=* Confirm by typing the container id >> input[type="text"]', containerId);
|
await explorer.fill('text=* Confirm by typing the container id >> input[type="text"]', containerId);
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
import "expect-playwright";
|
import "expect-playwright";
|
||||||
import { generateUniqueName } from "../utils/shared";
|
import { generateUniqueName } from "../utils/shared";
|
||||||
|
import { waitForExplorer } from "../utils/waitForExplorer";
|
||||||
|
|
||||||
jest.setTimeout(120000);
|
jest.setTimeout(120000);
|
||||||
|
|
||||||
test("Tables CRUD", async () => {
|
test("Tables CRUD", async () => {
|
||||||
const tableId = generateUniqueName("table");
|
const tableId = generateUniqueName("table");
|
||||||
|
page.setDefaultTimeout(50000);
|
||||||
|
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-tables-runner");
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-tables-runner");
|
||||||
await page.waitForSelector("iframe");
|
const explorer = await waitForExplorer();
|
||||||
const explorer = page.frame({
|
|
||||||
name: "explorer",
|
|
||||||
});
|
|
||||||
|
|
||||||
|
await page.waitForSelector('text="Querying databases"', { state: "detached" });
|
||||||
await explorer.click('[data-test="New Table"]');
|
await explorer.click('[data-test="New Table"]');
|
||||||
await explorer.fill('[aria-label="Table id"]', tableId);
|
await explorer.fill('[aria-label="Table id"]', tableId);
|
||||||
await explorer.click("#sidePanelOkButton");
|
await explorer.click("#sidePanelOkButton");
|
||||||
await explorer.click(`[data-test="TablesDB"]`, { timeout: 50000 });
|
await explorer.click(`[data-test="TablesDB"]`);
|
||||||
await explorer.click(`[data-test="${tableId}"] [aria-label="More"]`);
|
await explorer.click(`[data-test="${tableId}"] [aria-label="More"]`);
|
||||||
await explorer.click('button[role="menuitem"]:has-text("Delete Table")');
|
await explorer.click('button[role="menuitem"]:has-text("Delete Table")');
|
||||||
await explorer.fill('text=* Confirm by typing the table id >> input[type="text"]', tableId);
|
await explorer.fill('text=* Confirm by typing the table id >> input[type="text"]', tableId);
|
||||||
|
9
test/utils/waitForExplorer.ts
Normal file
9
test/utils/waitForExplorer.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Frame } from "playwright";
|
||||||
|
|
||||||
|
export const waitForExplorer = async (): Promise<Frame> => {
|
||||||
|
await page.waitForSelector("iframe");
|
||||||
|
await page.waitForTimeout(5000);
|
||||||
|
return page.frame({
|
||||||
|
name: "explorer",
|
||||||
|
});
|
||||||
|
};
|
@ -83,7 +83,6 @@
|
|||||||
"./src/Explorer/Tree/AccessibleVerticalList.ts",
|
"./src/Explorer/Tree/AccessibleVerticalList.ts",
|
||||||
"./src/GitHub/GitHubConnector.ts",
|
"./src/GitHub/GitHubConnector.ts",
|
||||||
"./src/HostedExplorerChildFrame.ts",
|
"./src/HostedExplorerChildFrame.ts",
|
||||||
"./src/Index.ts",
|
|
||||||
"./src/Platform/Hosted/Authorization.ts",
|
"./src/Platform/Hosted/Authorization.ts",
|
||||||
"./src/Platform/Hosted/Components/MeControl.test.tsx",
|
"./src/Platform/Hosted/Components/MeControl.test.tsx",
|
||||||
"./src/Platform/Hosted/Components/MeControl.tsx",
|
"./src/Platform/Hosted/Components/MeControl.tsx",
|
||||||
|
@ -198,7 +198,7 @@ module.exports = function (_env = {}, argv = {}) {
|
|||||||
mode: mode,
|
mode: mode,
|
||||||
entry: {
|
entry: {
|
||||||
main: "./src/Main.tsx",
|
main: "./src/Main.tsx",
|
||||||
index: "./src/Index.ts",
|
index: "./src/Index.tsx",
|
||||||
quickstart: "./src/quickstart.ts",
|
quickstart: "./src/quickstart.ts",
|
||||||
hostedExplorer: "./src/HostedExplorer.tsx",
|
hostedExplorer: "./src/HostedExplorer.tsx",
|
||||||
testExplorer: "./test/testExplorer/TestExplorer.ts",
|
testExplorer: "./test/testExplorer/TestExplorer.ts",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user