mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 19:01:28 +00:00
Compare commits
4 Commits
languy-com
...
eslit/fixe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efe458da3d | ||
|
|
702116dca1 | ||
|
|
651fe4344d | ||
|
|
7bc4894382 |
@@ -14,6 +14,8 @@ src/Common/DataAccessUtilityBase.ts
|
|||||||
src/Common/EditableUtility.ts
|
src/Common/EditableUtility.ts
|
||||||
src/Common/HashMap.test.ts
|
src/Common/HashMap.test.ts
|
||||||
src/Common/HashMap.ts
|
src/Common/HashMap.ts
|
||||||
|
src/Common/IteratorUtilities.test.ts
|
||||||
|
src/Common/IteratorUtilities.ts
|
||||||
src/Common/Logger.test.ts
|
src/Common/Logger.test.ts
|
||||||
src/Common/MessageHandler.test.ts
|
src/Common/MessageHandler.test.ts
|
||||||
src/Common/MessageHandler.ts
|
src/Common/MessageHandler.ts
|
||||||
@@ -99,6 +101,7 @@ src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts
|
|||||||
src/Explorer/Menus/ContextMenu.ts
|
src/Explorer/Menus/ContextMenu.ts
|
||||||
src/Explorer/MostRecentActivity/MostRecentActivity.ts
|
src/Explorer/MostRecentActivity/MostRecentActivity.ts
|
||||||
src/Explorer/Notebook/FileSystemUtil.ts
|
src/Explorer/Notebook/FileSystemUtil.ts
|
||||||
|
src/Explorer/Notebook/NTeractUtil.ts
|
||||||
src/Explorer/Notebook/NotebookClientV2.ts
|
src/Explorer/Notebook/NotebookClientV2.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts
|
src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts
|
src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts
|
||||||
@@ -112,7 +115,6 @@ src/Explorer/Notebook/NotebookComponent/types.ts
|
|||||||
src/Explorer/Notebook/NotebookContainerClient.ts
|
src/Explorer/Notebook/NotebookContainerClient.ts
|
||||||
src/Explorer/Notebook/NotebookContentClient.ts
|
src/Explorer/Notebook/NotebookContentClient.ts
|
||||||
src/Explorer/Notebook/NotebookContentItem.ts
|
src/Explorer/Notebook/NotebookContentItem.ts
|
||||||
src/Explorer/Notebook/NotebookUtil.ts
|
|
||||||
src/Explorer/OpenActions.test.ts
|
src/Explorer/OpenActions.test.ts
|
||||||
src/Explorer/OpenActions.ts
|
src/Explorer/OpenActions.ts
|
||||||
src/Explorer/OpenActionsStubs.ts
|
src/Explorer/OpenActionsStubs.ts
|
||||||
@@ -248,6 +250,8 @@ src/Shared/ExplorerSettings.ts
|
|||||||
src/Shared/PriceEstimateCalculator.ts
|
src/Shared/PriceEstimateCalculator.ts
|
||||||
src/Shared/StorageUtility.test.ts
|
src/Shared/StorageUtility.test.ts
|
||||||
src/Shared/StorageUtility.ts
|
src/Shared/StorageUtility.ts
|
||||||
|
src/Shared/StringUtility.test.ts
|
||||||
|
src/Shared/StringUtility.ts
|
||||||
src/Shared/appInsights.ts
|
src/Shared/appInsights.ts
|
||||||
src/SparkClusterManager/ArcadiaResourceManager.ts
|
src/SparkClusterManager/ArcadiaResourceManager.ts
|
||||||
src/SparkClusterManager/SparkClusterManager.ts
|
src/SparkClusterManager/SparkClusterManager.ts
|
||||||
@@ -258,6 +262,7 @@ src/TokenProviders/PortalTokenProvider.ts
|
|||||||
src/TokenProviders/TokenProviderFactory.ts
|
src/TokenProviders/TokenProviderFactory.ts
|
||||||
src/Utils/DatabaseAccountUtils.test.ts
|
src/Utils/DatabaseAccountUtils.test.ts
|
||||||
src/Utils/DatabaseAccountUtils.ts
|
src/Utils/DatabaseAccountUtils.ts
|
||||||
|
src/Utils/NotebookConfigurationUtils.ts
|
||||||
src/Utils/PricingUtils.test.ts
|
src/Utils/PricingUtils.test.ts
|
||||||
src/Utils/QueryUtils.test.ts
|
src/Utils/QueryUtils.test.ts
|
||||||
src/Utils/QueryUtils.ts
|
src/Utils/QueryUtils.ts
|
||||||
@@ -310,7 +315,15 @@ src/Explorer/Graph/GraphExplorerComponent/QueryContainerComponent.tsx
|
|||||||
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNeighborsComponent.tsx
|
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNeighborsComponent.tsx
|
||||||
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.test.tsx
|
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.test.tsx
|
||||||
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.tsx
|
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.tsx
|
||||||
|
src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx
|
||||||
|
src/Explorer/Menus/CommandBar/CommandBarUtil.test.tsx
|
||||||
src/Explorer/Menus/CommandBar/CommandBarUtil.tsx
|
src/Explorer/Menus/CommandBar/CommandBarUtil.tsx
|
||||||
|
src/Explorer/Menus/CommandBar/MemoryTrackerComponent.tsx
|
||||||
|
src/Explorer/Menus/NavBar/ControlBarComponent.tsx
|
||||||
|
src/Explorer/Menus/NavBar/ControlBarComponentAdapter.tsx
|
||||||
|
src/Explorer/Menus/NavBar/MeControlComponent.test.tsx
|
||||||
|
src/Explorer/Menus/NavBar/MeControlComponent.tsx
|
||||||
|
src/Explorer/Menus/NavBar/MeControlComponentAdapter.tsx
|
||||||
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponent.test.tsx
|
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponent.test.tsx
|
||||||
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponent.tsx
|
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponent.tsx
|
||||||
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponentAdapter.tsx
|
src/Explorer/Menus/NotificationConsole/NotificationConsoleComponentAdapter.tsx
|
||||||
|
|||||||
35
.github/workflows/ci.yml
vendored
35
.github/workflows/ci.yml
vendored
@@ -15,10 +15,10 @@ jobs:
|
|||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: node utils/codeMetrics.js
|
- run: node utils/codeMetrics.js
|
||||||
env:
|
env:
|
||||||
@@ -28,10 +28,10 @@ jobs:
|
|||||||
name: "Compile TypeScript"
|
name: "Compile TypeScript"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run compile
|
- run: npm run compile
|
||||||
- run: npm run compile:strict
|
- run: npm run compile:strict
|
||||||
@@ -40,10 +40,10 @@ jobs:
|
|||||||
name: "Check Format"
|
name: "Check Format"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run format:check
|
- run: npm run format:check
|
||||||
lint:
|
lint:
|
||||||
@@ -51,10 +51,10 @@ jobs:
|
|||||||
name: "Lint"
|
name: "Lint"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
unittest:
|
unittest:
|
||||||
@@ -62,10 +62,10 @@ jobs:
|
|||||||
name: "Unit Tests"
|
name: "Unit Tests"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
build:
|
build:
|
||||||
@@ -74,10 +74,10 @@ jobs:
|
|||||||
name: "Build"
|
name: "Build"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build:contracts
|
- run: npm run build:contracts
|
||||||
- name: Restore Build Cache
|
- name: Restore Build Cache
|
||||||
@@ -94,14 +94,14 @@ jobs:
|
|||||||
path: dist/
|
path: dist/
|
||||||
endtoendemulator:
|
endtoendemulator:
|
||||||
name: "End To End Emulator Tests"
|
name: "End To End Emulator Tests"
|
||||||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
needs: [lint, format, compile, unittest]
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- uses: southpolesteve/cosmos-emulator-github-action@v1
|
- uses: southpolesteve/cosmos-emulator-github-action@v1
|
||||||
- name: End to End Tests
|
- name: End to End Tests
|
||||||
run: |
|
run: |
|
||||||
@@ -125,10 +125,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js 14.x
|
- name: Use Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 12.x
|
||||||
- name: Accessibility Check
|
- name: Accessibility Check
|
||||||
run: |
|
run: |
|
||||||
# Ubuntu gets mad when webpack runs too many files watchers
|
# Ubuntu gets mad when webpack runs too many files watchers
|
||||||
@@ -163,7 +163,6 @@ jobs:
|
|||||||
TABLES_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_TABLE }}
|
TABLES_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_TABLE }}
|
||||||
DATA_EXPLORER_ENDPOINT: "https://localhost:1234/hostedExplorer.html"
|
DATA_EXPLORER_ENDPOINT: "https://localhost:1234/hostedExplorer.html"
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
test-file:
|
test-file:
|
||||||
- ./test/cassandra/container.spec.ts
|
- ./test/cassandra/container.spec.ts
|
||||||
|
|||||||
43
.vscode/settings.json
vendored
43
.vscode/settings.json
vendored
@@ -1,26 +1,21 @@
|
|||||||
// Place your settings in this file to overwrite default and user settings.
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
{
|
{
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
".vs": true,
|
".vs": true,
|
||||||
".vscode/**": true,
|
".vscode/**": true,
|
||||||
"*.trx": true,
|
"*.trx": true,
|
||||||
"**/.DS_Store": true,
|
"**/.DS_Store": true,
|
||||||
"**/.git": true,
|
"**/.git": true,
|
||||||
"**/.hg": true,
|
"**/.hg": true,
|
||||||
"**/.svn": true,
|
"**/.svn": true,
|
||||||
"built/**": true,
|
"built/**": true,
|
||||||
"coverage/**": true,
|
"coverage/**": true,
|
||||||
"libs/**": true,
|
"libs/**": true,
|
||||||
"node_modules/**": true,
|
"node_modules/**": true,
|
||||||
"package-lock.json": true,
|
"package-lock.json": true,
|
||||||
"quickstart/**": true,
|
"quickstart/**": true,
|
||||||
"test/out/**": true,
|
"test/out/**": true,
|
||||||
"workers/libs/**": true
|
"workers/libs/**": true
|
||||||
},
|
},
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
"editor.formatOnSave": true,
|
}
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll.eslint": true,
|
|
||||||
"source.organizeImports": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"GITHUB_CLIENT_ID": "167ea4b09801db1de03d",
|
|
||||||
"GITHUB_CLIENT_SECRET": "e7bb10a3a8da428815805c6fc483560a035a73c1"
|
|
||||||
}
|
|
||||||
26411
package-lock.json
generated
26411
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
|||||||
import * as Cosmos from "@azure/cosmos";
|
import * as Cosmos from "@azure/cosmos";
|
||||||
import { RequestInfo, setAuthorizationTokenHeaderUsingMasterKey } from "@azure/cosmos";
|
import { RequestInfo, setAuthorizationTokenHeaderUsingMasterKey } from "@azure/cosmos";
|
||||||
import { configContext, Platform } from "../ConfigContext";
|
import { configContext, Platform } from "../ConfigContext";
|
||||||
import { userContext } from "../UserContext";
|
import { getErrorMessage } from "./ErrorHandlingUtils";
|
||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||||
import { getErrorMessage } from "./ErrorHandlingUtils";
|
import { userContext } from "../UserContext";
|
||||||
|
|
||||||
const _global = typeof self === "undefined" ? window : self;
|
const _global = typeof self === "undefined" ? window : self;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
import { ARMError } from "../Utils/arm/request";
|
||||||
|
import { HttpStatusCodes } from "./Constants";
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
||||||
import { userContext } from "../UserContext";
|
|
||||||
import { ARMError } from "../Utils/arm/request";
|
|
||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import { HttpStatusCodes } from "./Constants";
|
|
||||||
import { logError } from "./Logger";
|
import { logError } from "./Logger";
|
||||||
import { sendMessage } from "./MessageHandler";
|
import { sendMessage } from "./MessageHandler";
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ const sendNotificationForError = (errorMessage: string, errorCode: number | stri
|
|||||||
|
|
||||||
const replaceKnownError = (errorMessage: string): string => {
|
const replaceKnownError = (errorMessage: string): string => {
|
||||||
if (
|
if (
|
||||||
userContext.subscriptionType === SubscriptionType.Internal &&
|
window.dataExplorer?.subscriptionType() === SubscriptionType.Internal &&
|
||||||
errorMessage?.indexOf("SharedOffer is Disabled for your account") >= 0
|
errorMessage?.indexOf("SharedOffer is Disabled for your account") >= 0
|
||||||
) {
|
) {
|
||||||
return "Database throughput is not supported for internal subscriptions.";
|
return "Database throughput is not supported for internal subscriptions.";
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { QueryResults } from "../Contracts/ViewModels";
|
import { QueryResults } from "../Contracts/ViewModels";
|
||||||
|
|
||||||
interface QueryResponse {
|
interface QueryResponse {
|
||||||
// [Todo] remove any
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
resources: any[];
|
resources: any[];
|
||||||
hasMoreResults: boolean;
|
hasMoreResults: boolean;
|
||||||
activityId: string;
|
activityId: string;
|
||||||
@@ -18,7 +16,6 @@ export interface MinimalQueryIterator {
|
|||||||
export function nextPage(documentsIterator: MinimalQueryIterator, firstItemIndex: number): Promise<QueryResults> {
|
export function nextPage(documentsIterator: MinimalQueryIterator, firstItemIndex: number): Promise<QueryResults> {
|
||||||
return documentsIterator.fetchNext().then((response) => {
|
return documentsIterator.fetchNext().then((response) => {
|
||||||
const documents = response.resources;
|
const documents = response.resources;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const headers = (response as any).headers || {}; // TODO this is a private key. Remove any
|
const headers = (response as any).headers || {}; // TODO this is a private key. Remove any
|
||||||
const itemCount = (documents && documents.length) || 0;
|
const itemCount = (documents && documents.length) || 0;
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export interface DatabaseAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DatabaseAccountExtendedProperties {
|
export interface DatabaseAccountExtendedProperties {
|
||||||
documentEndpoint?: string;
|
documentEndpoint: string;
|
||||||
tableEndpoint?: string;
|
tableEndpoint: string;
|
||||||
gremlinEndpoint?: string;
|
gremlinEndpoint: string;
|
||||||
cassandraEndpoint?: string;
|
cassandraEndpoint: string;
|
||||||
configurationOverrides?: ConfigurationOverrides;
|
configurationOverrides?: ConfigurationOverrides;
|
||||||
capabilities?: Capability[];
|
capabilities?: Capability[];
|
||||||
enableMultipleWriteLocations?: boolean;
|
enableMultipleWriteLocations?: boolean;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* Messaging types used with SelfServe Component <-> Portal communication
|
|
||||||
* and Hosted <-> SelfServe Component communication
|
|
||||||
*/
|
|
||||||
|
|
||||||
export enum SelfServeMessageTypes {
|
|
||||||
TelemetryInfo = "TelemetryInfo",
|
|
||||||
Notification = "Notification",
|
|
||||||
}
|
|
||||||
@@ -393,16 +393,7 @@ export interface DataExplorerInputsFrame {
|
|||||||
isAuthWithresourceToken?: boolean;
|
isAuthWithresourceToken?: boolean;
|
||||||
defaultCollectionThroughput?: CollectionCreationDefaults;
|
defaultCollectionThroughput?: CollectionCreationDefaults;
|
||||||
flights?: readonly string[];
|
flights?: readonly string[];
|
||||||
}
|
selfServeType?: SelfServeType;
|
||||||
|
|
||||||
export interface SelfServeFrameInputs {
|
|
||||||
selfServeType: SelfServeType;
|
|
||||||
databaseAccount: any;
|
|
||||||
subscriptionId: string;
|
|
||||||
resourceGroup: string;
|
|
||||||
authorizationToken: string;
|
|
||||||
csmEndpoint: string;
|
|
||||||
flights?: readonly string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CollectionCreationDefaults {
|
export interface CollectionCreationDefaults {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
.publicGalleryTabContainer {
|
.publicGalleryTabContainer {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.publicGalleryTabOverlayContent {
|
.publicGalleryTabOverlayContent {
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
private createSearchBarHeader(content: JSX.Element): JSX.Element {
|
private createSearchBarHeader(content: JSX.Element): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Stack tokens={{ childrenGap: 10 }}>
|
<Stack tokens={{ childrenGap: 10 }}>
|
||||||
<Stack horizontal wrap tokens={{ childrenGap: 20, padding: 10 }}>
|
<Stack horizontal tokens={{ childrenGap: 20, padding: 10 }}>
|
||||||
<Stack.Item grow>
|
<Stack.Item grow>
|
||||||
<SearchBox value={this.state.searchText} placeholder="Search" onChange={this.onSearchBoxChange} />
|
<SearchBox value={this.state.searchText} placeholder="Search" onChange={this.onSearchBoxChange} />
|
||||||
</Stack.Item>
|
</Stack.Item>
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ exports[`GalleryViewerComponent renders 1`] = `
|
|||||||
"padding": 10,
|
"padding": 10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrap={true}
|
|
||||||
>
|
>
|
||||||
<StackItem
|
<StackItem
|
||||||
grow={true}
|
grow={true}
|
||||||
@@ -122,7 +121,6 @@ exports[`GalleryViewerComponent renders 1`] = `
|
|||||||
"padding": 10,
|
"padding": 10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrap={true}
|
|
||||||
>
|
>
|
||||||
<StackItem
|
<StackItem
|
||||||
grow={true}
|
grow={true}
|
||||||
|
|||||||
@@ -1060,6 +1060,14 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
},
|
},
|
||||||
"selectedDatabaseId": [Function],
|
"selectedDatabaseId": [Function],
|
||||||
"selectedNode": [Function],
|
"selectedNode": [Function],
|
||||||
|
"selfServeComponentAdapter": SelfServeComponentAdapter {
|
||||||
|
"container": [Circular],
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeLoadingComponentAdapter": SelfServeLoadingComponentAdapter {
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeType": [Function],
|
||||||
"serverId": [Function],
|
"serverId": [Function],
|
||||||
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
||||||
"setIsNotificationConsoleExpanded": undefined,
|
"setIsNotificationConsoleExpanded": undefined,
|
||||||
@@ -2261,6 +2269,14 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
},
|
},
|
||||||
"selectedDatabaseId": [Function],
|
"selectedDatabaseId": [Function],
|
||||||
"selectedNode": [Function],
|
"selectedNode": [Function],
|
||||||
|
"selfServeComponentAdapter": SelfServeComponentAdapter {
|
||||||
|
"container": [Circular],
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeLoadingComponentAdapter": SelfServeLoadingComponentAdapter {
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeType": [Function],
|
||||||
"serverId": [Function],
|
"serverId": [Function],
|
||||||
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
||||||
"setIsNotificationConsoleExpanded": undefined,
|
"setIsNotificationConsoleExpanded": undefined,
|
||||||
@@ -3475,6 +3491,14 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
},
|
},
|
||||||
"selectedDatabaseId": [Function],
|
"selectedDatabaseId": [Function],
|
||||||
"selectedNode": [Function],
|
"selectedNode": [Function],
|
||||||
|
"selfServeComponentAdapter": SelfServeComponentAdapter {
|
||||||
|
"container": [Circular],
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeLoadingComponentAdapter": SelfServeLoadingComponentAdapter {
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeType": [Function],
|
||||||
"serverId": [Function],
|
"serverId": [Function],
|
||||||
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
||||||
"setIsNotificationConsoleExpanded": undefined,
|
"setIsNotificationConsoleExpanded": undefined,
|
||||||
@@ -4676,6 +4700,14 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
},
|
},
|
||||||
"selectedDatabaseId": [Function],
|
"selectedDatabaseId": [Function],
|
||||||
"selectedNode": [Function],
|
"selectedNode": [Function],
|
||||||
|
"selfServeComponentAdapter": SelfServeComponentAdapter {
|
||||||
|
"container": [Circular],
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeLoadingComponentAdapter": SelfServeLoadingComponentAdapter {
|
||||||
|
"parameters": [Function],
|
||||||
|
},
|
||||||
|
"selfServeType": [Function],
|
||||||
"serverId": [Function],
|
"serverId": [Function],
|
||||||
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
"setInProgressConsoleDataIdToBeDeleted": undefined,
|
||||||
"setIsNotificationConsoleExpanded": undefined,
|
"setIsNotificationConsoleExpanded": undefined,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import { SmartUiComponent, SmartUiDescriptor } from "./SmartUiComponent";
|
import { SmartUiComponent, SmartUiDescriptor } from "./SmartUiComponent";
|
||||||
import { NumberUiType, SmartUiInput, DescriptionType } from "../../../SelfServe/SelfServeTypes";
|
import { NumberUiType, SmartUiInput } from "../../../SelfServe/SelfServeTypes";
|
||||||
|
|
||||||
describe("SmartUiComponent", () => {
|
describe("SmartUiComponent", () => {
|
||||||
const exampleData: SmartUiDescriptor = {
|
const exampleData: SmartUiDescriptor = {
|
||||||
@@ -18,12 +18,10 @@ describe("SmartUiComponent", () => {
|
|||||||
{
|
{
|
||||||
id: "description",
|
id: "description",
|
||||||
input: {
|
input: {
|
||||||
labelTKey: undefined,
|
|
||||||
dataFieldName: "description",
|
dataFieldName: "description",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: {
|
description: {
|
||||||
textTKey: "this is an example description text.",
|
textTKey: "this is an example description text.",
|
||||||
type: DescriptionType.Text,
|
|
||||||
link: {
|
link: {
|
||||||
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
||||||
textTKey: "Click here for more information.",
|
textTKey: "Click here for more information.",
|
||||||
|
|||||||
@@ -6,13 +6,12 @@ import { Dropdown, IDropdownOption } from "office-ui-fabric-react/lib/Dropdown";
|
|||||||
import { TextField } from "office-ui-fabric-react/lib/TextField";
|
import { TextField } from "office-ui-fabric-react/lib/TextField";
|
||||||
import { Text } from "office-ui-fabric-react/lib/Text";
|
import { Text } from "office-ui-fabric-react/lib/Text";
|
||||||
import { Stack, IStackTokens } from "office-ui-fabric-react/lib/Stack";
|
import { Stack, IStackTokens } from "office-ui-fabric-react/lib/Stack";
|
||||||
import { Label, Link, MessageBar, MessageBarType, Toggle } from "office-ui-fabric-react";
|
import { Link, MessageBar, MessageBarType, Toggle } from "office-ui-fabric-react";
|
||||||
import * as InputUtils from "./InputUtils";
|
import * as InputUtils from "./InputUtils";
|
||||||
import "./SmartUiComponent.less";
|
import "./SmartUiComponent.less";
|
||||||
import {
|
import {
|
||||||
ChoiceItem,
|
ChoiceItem,
|
||||||
Description,
|
Description,
|
||||||
DescriptionType,
|
|
||||||
Info,
|
Info,
|
||||||
InputType,
|
InputType,
|
||||||
InputTypeValue,
|
InputTypeValue,
|
||||||
@@ -20,7 +19,6 @@ import {
|
|||||||
SmartUiInput,
|
SmartUiInput,
|
||||||
} from "../../../SelfServe/SelfServeTypes";
|
} from "../../../SelfServe/SelfServeTypes";
|
||||||
import { TFunction } from "i18next";
|
import { TFunction } from "i18next";
|
||||||
import { ToolTipLabelComponent } from "../Settings/SettingsSubComponents/ToolTipLabelComponent";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic UX renderer
|
* Generic UX renderer
|
||||||
@@ -31,14 +29,15 @@ import { ToolTipLabelComponent } from "../Settings/SettingsSubComponents/ToolTip
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
interface BaseDisplay {
|
interface BaseDisplay {
|
||||||
labelTKey: string;
|
|
||||||
dataFieldName: string;
|
dataFieldName: string;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
type: InputTypeValue;
|
type: InputTypeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BaseInput extends BaseDisplay {
|
interface BaseInput extends BaseDisplay {
|
||||||
|
labelTKey: string;
|
||||||
placeholderTKey?: string;
|
placeholderTKey?: string;
|
||||||
|
errorMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,8 +67,7 @@ interface ChoiceInput extends BaseInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface DescriptionDisplay extends BaseDisplay {
|
interface DescriptionDisplay extends BaseDisplay {
|
||||||
description?: Description;
|
description: Description;
|
||||||
isDynamicDescription?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AnyDisplay = NumberInput | BooleanInput | StringInput | ChoiceInput | DescriptionDisplay;
|
type AnyDisplay = NumberInput | BooleanInput | StringInput | ChoiceInput | DescriptionDisplay;
|
||||||
@@ -125,27 +123,25 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
|
|
||||||
private renderInfo(info: Info): JSX.Element {
|
private renderInfo(info: Info): JSX.Element {
|
||||||
return (
|
return (
|
||||||
info && (
|
<MessageBar styles={{ root: { width: 400 } }}>
|
||||||
<Text>
|
{this.props.getTranslation(info.messageTKey)}
|
||||||
{this.props.getTranslation(info.messageTKey)}{" "}
|
{info.link && (
|
||||||
{info.link && (
|
<Link href={info.link.href} target="_blank">
|
||||||
<Link href={info.link.href} target="_blank">
|
{this.props.getTranslation(info.link.textTKey)}
|
||||||
{this.props.getTranslation(info.link.textTKey)}
|
</Link>
|
||||||
</Link>
|
)}
|
||||||
)}
|
</MessageBar>
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderTextInput(input: StringInput, labelId: string): JSX.Element {
|
private renderTextInput(input: StringInput): JSX.Element {
|
||||||
const value = this.props.currentValues.get(input.dataFieldName)?.value as string;
|
const value = this.props.currentValues.get(input.dataFieldName)?.value as string;
|
||||||
const disabled = this.props.disabled || this.props.currentValues.get(input.dataFieldName)?.disabled;
|
const disabled = this.props.disabled || this.props.currentValues.get(input.dataFieldName)?.disabled;
|
||||||
return (
|
return (
|
||||||
<div className="stringInputContainer">
|
<div className="stringInputContainer">
|
||||||
<TextField
|
<TextField
|
||||||
id={`${input.dataFieldName}-textField-input`}
|
id={`${input.dataFieldName}-textField-input`}
|
||||||
aria-labelledby={labelId}
|
label={this.props.getTranslation(input.labelTKey)}
|
||||||
type="text"
|
type="text"
|
||||||
value={value || ""}
|
value={value || ""}
|
||||||
placeholder={this.props.getTranslation(input.placeholderTKey)}
|
placeholder={this.props.getTranslation(input.placeholderTKey)}
|
||||||
@@ -153,35 +149,32 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
onChange={(_, newValue) => this.props.onInputChange(input, newValue)}
|
onChange={(_, newValue) => this.props.onInputChange(input, newValue)}
|
||||||
styles={{
|
styles={{
|
||||||
root: { width: 400 },
|
root: { width: 400 },
|
||||||
|
subComponentStyles: {
|
||||||
|
label: {
|
||||||
|
root: {
|
||||||
|
...SmartUiComponent.labelStyle,
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderDescription(input: DescriptionDisplay, labelId: string): JSX.Element {
|
private renderDescription(input: DescriptionDisplay): JSX.Element {
|
||||||
const dataFieldName = input.dataFieldName;
|
const description = input.description;
|
||||||
const description = input.description || (this.props.currentValues.get(dataFieldName)?.value as Description);
|
return (
|
||||||
if (!description) {
|
<Text id={`${input.dataFieldName}-text-display`}>
|
||||||
return this.renderError("Description is not provided.");
|
{this.props.getTranslation(input.description.textTKey)}{" "}
|
||||||
}
|
|
||||||
const descriptionElement = (
|
|
||||||
<Text id={`${dataFieldName}-text-display`} aria-labelledby={labelId}>
|
|
||||||
{this.props.getTranslation(description.textTKey)}{" "}
|
|
||||||
{description.link && (
|
{description.link && (
|
||||||
<Link target="_blank" href={description.link.href}>
|
<Link target="_blank" href={input.description.link.href}>
|
||||||
{this.props.getTranslation(description.link.textTKey)}
|
{this.props.getTranslation(input.description.link.textTKey)}
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (description.type === DescriptionType.Text) {
|
|
||||||
return descriptionElement;
|
|
||||||
}
|
|
||||||
const messageBarType =
|
|
||||||
description.type === DescriptionType.InfoMessageBar ? MessageBarType.info : MessageBarType.warning;
|
|
||||||
return <MessageBar messageBarType={messageBarType}>{descriptionElement}</MessageBar>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearError(dataFieldName: string): void {
|
private clearError(dataFieldName: string): void {
|
||||||
@@ -227,12 +220,13 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderNumberInput(input: NumberInput, labelId: string): JSX.Element {
|
private renderNumberInput(input: NumberInput): JSX.Element {
|
||||||
const { labelTKey, min, max, dataFieldName, step } = input;
|
const { labelTKey, min, max, dataFieldName, step } = input;
|
||||||
const props = {
|
const props = {
|
||||||
|
label: this.props.getTranslation(labelTKey),
|
||||||
min: min,
|
min: min,
|
||||||
max: max,
|
max: max,
|
||||||
ariaLabel: this.props.getTranslation(labelTKey),
|
ariaLabel: labelTKey,
|
||||||
step: step,
|
step: step,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -249,8 +243,13 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
onIncrement={(newValue) => this.onIncrement(input, newValue, props.step, props.max)}
|
onIncrement={(newValue) => this.onIncrement(input, newValue, props.step, props.max)}
|
||||||
onDecrement={(newValue) => this.onDecrement(input, newValue, props.step, props.min)}
|
onDecrement={(newValue) => this.onDecrement(input, newValue, props.step, props.min)}
|
||||||
labelPosition={Position.top}
|
labelPosition={Position.top}
|
||||||
aria-labelledby={labelId}
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
styles={{
|
||||||
|
label: {
|
||||||
|
...SmartUiComponent.labelStyle,
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{this.state.errors.has(dataFieldName) && (
|
{this.state.errors.has(dataFieldName) && (
|
||||||
<MessageBar messageBarType={MessageBarType.error}>Error: {this.state.errors.get(dataFieldName)}</MessageBar>
|
<MessageBar messageBarType={MessageBarType.error}>Error: {this.state.errors.get(dataFieldName)}</MessageBar>
|
||||||
@@ -267,6 +266,10 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
onChange={(newValue) => this.props.onInputChange(input, newValue)}
|
onChange={(newValue) => this.props.onInputChange(input, newValue)}
|
||||||
styles={{
|
styles={{
|
||||||
root: { width: 400 },
|
root: { width: 400 },
|
||||||
|
titleLabel: {
|
||||||
|
...SmartUiComponent.labelStyle,
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
valueLabel: SmartUiComponent.labelStyle,
|
valueLabel: SmartUiComponent.labelStyle,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -277,13 +280,13 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderBooleanInput(input: BooleanInput, labelId: string): JSX.Element {
|
private renderBooleanInput(input: BooleanInput): JSX.Element {
|
||||||
const value = this.props.currentValues.get(input.dataFieldName)?.value as boolean;
|
const value = this.props.currentValues.get(input.dataFieldName)?.value as boolean;
|
||||||
const disabled = this.props.disabled || this.props.currentValues.get(input.dataFieldName)?.disabled;
|
const disabled = this.props.disabled || this.props.currentValues.get(input.dataFieldName)?.disabled;
|
||||||
return (
|
return (
|
||||||
<Toggle
|
<Toggle
|
||||||
id={`${input.dataFieldName}-toggle-input`}
|
id={`${input.dataFieldName}-toggle-input`}
|
||||||
aria-labelledby={labelId}
|
label={this.props.getTranslation(input.labelTKey)}
|
||||||
checked={value || false}
|
checked={value || false}
|
||||||
onText={this.props.getTranslation(input.trueLabelTKey)}
|
onText={this.props.getTranslation(input.trueLabelTKey)}
|
||||||
offText={this.props.getTranslation(input.falseLabelTKey)}
|
offText={this.props.getTranslation(input.falseLabelTKey)}
|
||||||
@@ -294,8 +297,8 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderChoiceInput(input: ChoiceInput, labelId: string): JSX.Element {
|
private renderChoiceInput(input: ChoiceInput): JSX.Element {
|
||||||
const { defaultKey, dataFieldName, choices, placeholderTKey } = input;
|
const { labelTKey, defaultKey, dataFieldName, choices, placeholderTKey } = input;
|
||||||
const value = this.props.currentValues.get(dataFieldName)?.value as string;
|
const value = this.props.currentValues.get(dataFieldName)?.value as string;
|
||||||
const disabled = this.props.disabled || this.props.currentValues.get(dataFieldName)?.disabled;
|
const disabled = this.props.disabled || this.props.currentValues.get(dataFieldName)?.disabled;
|
||||||
let selectedKey = value ? value : defaultKey;
|
let selectedKey = value ? value : defaultKey;
|
||||||
@@ -305,7 +308,7 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
id={`${input.dataFieldName}-dropdown-input`}
|
id={`${input.dataFieldName}-dropdown-input`}
|
||||||
aria-labelledby={labelId}
|
label={this.props.getTranslation(labelTKey)}
|
||||||
selectedKey={selectedKey}
|
selectedKey={selectedKey}
|
||||||
onChange={(_, item: IDropdownOption) => this.props.onInputChange(input, item.key.toString())}
|
onChange={(_, item: IDropdownOption) => this.props.onInputChange(input, item.key.toString())}
|
||||||
placeholder={this.props.getTranslation(placeholderTKey)}
|
placeholder={this.props.getTranslation(placeholderTKey)}
|
||||||
@@ -316,53 +319,40 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
}))}
|
}))}
|
||||||
styles={{
|
styles={{
|
||||||
root: { width: 400 },
|
root: { width: 400 },
|
||||||
|
label: {
|
||||||
|
...SmartUiComponent.labelStyle,
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
dropdown: SmartUiComponent.labelStyle,
|
dropdown: SmartUiComponent.labelStyle,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderError(errorMessage: string): JSX.Element {
|
private renderError(input: AnyDisplay): JSX.Element {
|
||||||
return <MessageBar messageBarType={MessageBarType.error}>Error: {errorMessage}</MessageBar>;
|
return <MessageBar messageBarType={MessageBarType.error}>Error: {input.errorMessage}</MessageBar>;
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderDisplayWithInfoBubble(input: AnyDisplay, info: Info): JSX.Element {
|
private renderDisplay(input: AnyDisplay): JSX.Element {
|
||||||
if (input.errorMessage) {
|
if (input.errorMessage) {
|
||||||
return this.renderError(input.errorMessage);
|
return this.renderError(input);
|
||||||
}
|
}
|
||||||
const inputHidden = this.props.currentValues.get(input.dataFieldName)?.hidden;
|
const inputHidden = this.props.currentValues.get(input.dataFieldName)?.hidden;
|
||||||
if (inputHidden) {
|
if (inputHidden) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
const labelId = `${input.dataFieldName}-label`;
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
{input.labelTKey && (
|
|
||||||
<Label id={labelId}>
|
|
||||||
<ToolTipLabelComponent
|
|
||||||
label={this.props.getTranslation(input.labelTKey)}
|
|
||||||
toolTipElement={this.renderInfo(info)}
|
|
||||||
/>
|
|
||||||
</Label>
|
|
||||||
)}
|
|
||||||
{this.renderDisplay(input, labelId)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private renderDisplay(input: AnyDisplay, labelId: string): JSX.Element {
|
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
case "string":
|
case "string":
|
||||||
if ("description" in input || "isDynamicDescription" in input) {
|
if ("description" in input) {
|
||||||
return this.renderDescription(input as DescriptionDisplay, labelId);
|
return this.renderDescription(input as DescriptionDisplay);
|
||||||
}
|
}
|
||||||
return this.renderTextInput(input as StringInput, labelId);
|
return this.renderTextInput(input as StringInput);
|
||||||
case "number":
|
case "number":
|
||||||
return this.renderNumberInput(input as NumberInput, labelId);
|
return this.renderNumberInput(input as NumberInput);
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return this.renderBooleanInput(input as BooleanInput, labelId);
|
return this.renderBooleanInput(input as BooleanInput);
|
||||||
case "object":
|
case "object":
|
||||||
return this.renderChoiceInput(input as ChoiceInput, labelId);
|
return this.renderChoiceInput(input as ChoiceInput);
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown input type: ${input.type}`);
|
throw new Error(`Unknown input type: ${input.type}`);
|
||||||
}
|
}
|
||||||
@@ -373,7 +363,10 @@ export class SmartUiComponent extends React.Component<SmartUiComponentProps, Sma
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack tokens={containerStackTokens} className="widgetRendererContainer">
|
<Stack tokens={containerStackTokens} className="widgetRendererContainer">
|
||||||
<Stack.Item>{node.input && this.renderDisplayWithInfoBubble(node.input, node.info as Info)}</Stack.Item>
|
<Stack.Item>
|
||||||
|
{node.info && this.renderInfo(node.info as Info)}
|
||||||
|
{node.input && this.renderDisplay(node.input)}
|
||||||
|
</Stack.Item>
|
||||||
{node.children && node.children.map((child) => <div key={child.id}>{this.renderNode(child)}</div>)}
|
{node.children && node.children.map((child) => <div key={child.id}>{this.renderNode(child)}</div>)}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,25 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem />
|
<StackItem>
|
||||||
|
<StyledMessageBarBase
|
||||||
|
styles={
|
||||||
|
Object {
|
||||||
|
"root": Object {
|
||||||
|
"width": 400,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Start at $24/mo per database
|
||||||
|
<StyledLinkBase
|
||||||
|
href="https://aka.ms/azure-cosmos-db-pricing"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
More Details
|
||||||
|
</StyledLinkBase>
|
||||||
|
</StyledMessageBarBase>
|
||||||
|
</StackItem>
|
||||||
<div
|
<div
|
||||||
key="description"
|
key="description"
|
||||||
>
|
>
|
||||||
@@ -22,21 +40,18 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<Text
|
||||||
<Text
|
id="description-text-display"
|
||||||
aria-labelledby="description-label"
|
>
|
||||||
id="description-text-display"
|
this is an example description text.
|
||||||
|
|
||||||
|
<StyledLinkBase
|
||||||
|
href="https://docs.microsoft.com/en-us/azure/cosmos-db/introduction"
|
||||||
|
target="_blank"
|
||||||
>
|
>
|
||||||
this is an example description text.
|
Click here for more information.
|
||||||
|
</StyledLinkBase>
|
||||||
<StyledLinkBase
|
</Text>
|
||||||
href="https://docs.microsoft.com/en-us/azure/cosmos-db/introduction"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
Click here for more information.
|
|
||||||
</StyledLinkBase>
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,53 +67,53 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<Stack
|
||||||
<StyledLabelBase
|
styles={
|
||||||
id="throughput-label"
|
Object {
|
||||||
>
|
"root": Object {
|
||||||
<ToolTipLabelComponent
|
"width": 400,
|
||||||
label="Throughput (input)"
|
},
|
||||||
/>
|
}
|
||||||
</StyledLabelBase>
|
}
|
||||||
<Stack
|
tokens={
|
||||||
|
Object {
|
||||||
|
"childrenGap": 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<CustomizedSpinButton
|
||||||
|
ariaLabel="Throughput (input)"
|
||||||
|
decrementButtonIcon={
|
||||||
|
Object {
|
||||||
|
"iconName": "ChevronDownSmall",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disabled={true}
|
||||||
|
id="throughput-spinner-input"
|
||||||
|
incrementButtonIcon={
|
||||||
|
Object {
|
||||||
|
"iconName": "ChevronUpSmall",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label="Throughput (input)"
|
||||||
|
labelPosition={0}
|
||||||
|
max={500}
|
||||||
|
min={400}
|
||||||
|
onDecrement={[Function]}
|
||||||
|
onIncrement={[Function]}
|
||||||
|
onValidate={[Function]}
|
||||||
|
step={10}
|
||||||
styles={
|
styles={
|
||||||
Object {
|
Object {
|
||||||
"root": Object {
|
"label": Object {
|
||||||
"width": 400,
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
"fontWeight": 600,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tokens={
|
/>
|
||||||
Object {
|
|
||||||
"childrenGap": 2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<CustomizedSpinButton
|
|
||||||
aria-labelledby="throughput-label"
|
|
||||||
ariaLabel="Throughput (input)"
|
|
||||||
decrementButtonIcon={
|
|
||||||
Object {
|
|
||||||
"iconName": "ChevronDownSmall",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
disabled={true}
|
|
||||||
id="throughput-spinner-input"
|
|
||||||
incrementButtonIcon={
|
|
||||||
Object {
|
|
||||||
"iconName": "ChevronUpSmall",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
label=""
|
|
||||||
labelPosition={0}
|
|
||||||
max={500}
|
|
||||||
min={400}
|
|
||||||
onDecrement={[Function]}
|
|
||||||
onIncrement={[Function]}
|
|
||||||
onValidate={[Function]}
|
|
||||||
step={10}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -115,39 +130,37 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<div
|
||||||
<StyledLabelBase
|
id="throughput2-slider-input"
|
||||||
id="throughput2-label"
|
>
|
||||||
>
|
<StyledSliderBase
|
||||||
<ToolTipLabelComponent
|
ariaLabel="Throughput (Slider)"
|
||||||
label="Throughput (Slider)"
|
disabled={true}
|
||||||
/>
|
label="Throughput (Slider)"
|
||||||
</StyledLabelBase>
|
max={500}
|
||||||
<div
|
min={400}
|
||||||
id="throughput2-slider-input"
|
onChange={[Function]}
|
||||||
>
|
step={10}
|
||||||
<StyledSliderBase
|
styles={
|
||||||
ariaLabel="Throughput (Slider)"
|
Object {
|
||||||
disabled={true}
|
"root": Object {
|
||||||
max={500}
|
"width": 400,
|
||||||
min={400}
|
},
|
||||||
onChange={[Function]}
|
"titleLabel": Object {
|
||||||
step={10}
|
"color": "#393939",
|
||||||
styles={
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
Object {
|
"fontSize": 12,
|
||||||
"root": Object {
|
"fontWeight": 600,
|
||||||
"width": 400,
|
},
|
||||||
},
|
"valueLabel": Object {
|
||||||
"valueLabel": Object {
|
"color": "#393939",
|
||||||
"color": "#393939",
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
"fontSize": 12,
|
||||||
"fontSize": 12,
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</div>
|
/>
|
||||||
</Stack>
|
</div>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -184,34 +197,35 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<div
|
||||||
<StyledLabelBase
|
className="stringInputContainer"
|
||||||
id="containerId-label"
|
>
|
||||||
>
|
<StyledTextFieldBase
|
||||||
<ToolTipLabelComponent
|
disabled={true}
|
||||||
label="Container id"
|
id="containerId-textField-input"
|
||||||
/>
|
label="Container id"
|
||||||
</StyledLabelBase>
|
onChange={[Function]}
|
||||||
<div
|
styles={
|
||||||
className="stringInputContainer"
|
Object {
|
||||||
>
|
"root": Object {
|
||||||
<StyledTextFieldBase
|
"width": 400,
|
||||||
aria-labelledby="containerId-label"
|
},
|
||||||
disabled={true}
|
"subComponentStyles": Object {
|
||||||
id="containerId-textField-input"
|
"label": Object {
|
||||||
onChange={[Function]}
|
"root": Object {
|
||||||
styles={
|
"color": "#393939",
|
||||||
Object {
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
"root": Object {
|
"fontSize": 12,
|
||||||
"width": 400,
|
"fontWeight": 600,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
type="text"
|
}
|
||||||
value=""
|
type="text"
|
||||||
/>
|
value=""
|
||||||
</div>
|
/>
|
||||||
</Stack>
|
</div>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -227,31 +241,22 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<StyledToggleBase
|
||||||
<StyledLabelBase
|
checked={false}
|
||||||
id="analyticalStore-label"
|
disabled={true}
|
||||||
>
|
id="analyticalStore-toggle-input"
|
||||||
<ToolTipLabelComponent
|
label="Analytical Store"
|
||||||
label="Analytical Store"
|
offText="Disabled"
|
||||||
/>
|
onChange={[Function]}
|
||||||
</StyledLabelBase>
|
onText="Enabled"
|
||||||
<StyledToggleBase
|
styles={
|
||||||
aria-labelledby="analyticalStore-label"
|
Object {
|
||||||
checked={false}
|
"root": Object {
|
||||||
disabled={true}
|
"width": 400,
|
||||||
id="analyticalStore-toggle-input"
|
},
|
||||||
offText="Disabled"
|
|
||||||
onChange={[Function]}
|
|
||||||
onText="Enabled"
|
|
||||||
styles={
|
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"width": 400,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</Stack>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -267,50 +272,47 @@ exports[`SmartUiComponent disable all inputs 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<StyledWithResponsiveMode
|
||||||
<StyledLabelBase
|
disabled={true}
|
||||||
id="database-label"
|
id="database-dropdown-input"
|
||||||
>
|
label="Database"
|
||||||
<ToolTipLabelComponent
|
onChange={[Function]}
|
||||||
label="Database"
|
options={
|
||||||
/>
|
Array [
|
||||||
</StyledLabelBase>
|
|
||||||
<StyledWithResponsiveMode
|
|
||||||
aria-labelledby="database-label"
|
|
||||||
disabled={true}
|
|
||||||
id="database-dropdown-input"
|
|
||||||
onChange={[Function]}
|
|
||||||
options={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"key": "db1",
|
|
||||||
"text": "Database 1",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "db2",
|
|
||||||
"text": "Database 2",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "db3",
|
|
||||||
"text": "Database 3",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
selectedKey="db2"
|
|
||||||
styles={
|
|
||||||
Object {
|
Object {
|
||||||
"dropdown": Object {
|
"key": "db1",
|
||||||
"color": "#393939",
|
"text": "Database 1",
|
||||||
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
},
|
||||||
"fontSize": 12,
|
Object {
|
||||||
},
|
"key": "db2",
|
||||||
"root": Object {
|
"text": "Database 2",
|
||||||
"width": 400,
|
},
|
||||||
},
|
Object {
|
||||||
}
|
"key": "db3",
|
||||||
|
"text": "Database 3",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
selectedKey="db2"
|
||||||
|
styles={
|
||||||
|
Object {
|
||||||
|
"dropdown": Object {
|
||||||
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
},
|
||||||
|
"label": Object {
|
||||||
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
"fontWeight": 600,
|
||||||
|
},
|
||||||
|
"root": Object {
|
||||||
|
"width": 400,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</Stack>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -326,7 +328,25 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem />
|
<StackItem>
|
||||||
|
<StyledMessageBarBase
|
||||||
|
styles={
|
||||||
|
Object {
|
||||||
|
"root": Object {
|
||||||
|
"width": 400,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Start at $24/mo per database
|
||||||
|
<StyledLinkBase
|
||||||
|
href="https://aka.ms/azure-cosmos-db-pricing"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
More Details
|
||||||
|
</StyledLinkBase>
|
||||||
|
</StyledMessageBarBase>
|
||||||
|
</StackItem>
|
||||||
<div
|
<div
|
||||||
key="description"
|
key="description"
|
||||||
>
|
>
|
||||||
@@ -339,21 +359,18 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<Text
|
||||||
<Text
|
id="description-text-display"
|
||||||
aria-labelledby="description-label"
|
>
|
||||||
id="description-text-display"
|
this is an example description text.
|
||||||
|
|
||||||
|
<StyledLinkBase
|
||||||
|
href="https://docs.microsoft.com/en-us/azure/cosmos-db/introduction"
|
||||||
|
target="_blank"
|
||||||
>
|
>
|
||||||
this is an example description text.
|
Click here for more information.
|
||||||
|
</StyledLinkBase>
|
||||||
<StyledLinkBase
|
</Text>
|
||||||
href="https://docs.microsoft.com/en-us/azure/cosmos-db/introduction"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
Click here for more information.
|
|
||||||
</StyledLinkBase>
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -369,53 +386,53 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<Stack
|
||||||
<StyledLabelBase
|
styles={
|
||||||
id="throughput-label"
|
Object {
|
||||||
>
|
"root": Object {
|
||||||
<ToolTipLabelComponent
|
"width": 400,
|
||||||
label="Throughput (input)"
|
},
|
||||||
/>
|
}
|
||||||
</StyledLabelBase>
|
}
|
||||||
<Stack
|
tokens={
|
||||||
|
Object {
|
||||||
|
"childrenGap": 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<CustomizedSpinButton
|
||||||
|
ariaLabel="Throughput (input)"
|
||||||
|
decrementButtonIcon={
|
||||||
|
Object {
|
||||||
|
"iconName": "ChevronDownSmall",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disabled={false}
|
||||||
|
id="throughput-spinner-input"
|
||||||
|
incrementButtonIcon={
|
||||||
|
Object {
|
||||||
|
"iconName": "ChevronUpSmall",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label="Throughput (input)"
|
||||||
|
labelPosition={0}
|
||||||
|
max={500}
|
||||||
|
min={400}
|
||||||
|
onDecrement={[Function]}
|
||||||
|
onIncrement={[Function]}
|
||||||
|
onValidate={[Function]}
|
||||||
|
step={10}
|
||||||
styles={
|
styles={
|
||||||
Object {
|
Object {
|
||||||
"root": Object {
|
"label": Object {
|
||||||
"width": 400,
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
"fontWeight": 600,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tokens={
|
/>
|
||||||
Object {
|
|
||||||
"childrenGap": 2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<CustomizedSpinButton
|
|
||||||
aria-labelledby="throughput-label"
|
|
||||||
ariaLabel="Throughput (input)"
|
|
||||||
decrementButtonIcon={
|
|
||||||
Object {
|
|
||||||
"iconName": "ChevronDownSmall",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
disabled={false}
|
|
||||||
id="throughput-spinner-input"
|
|
||||||
incrementButtonIcon={
|
|
||||||
Object {
|
|
||||||
"iconName": "ChevronUpSmall",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
label=""
|
|
||||||
labelPosition={0}
|
|
||||||
max={500}
|
|
||||||
min={400}
|
|
||||||
onDecrement={[Function]}
|
|
||||||
onIncrement={[Function]}
|
|
||||||
onValidate={[Function]}
|
|
||||||
step={10}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -432,38 +449,36 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<div
|
||||||
<StyledLabelBase
|
id="throughput2-slider-input"
|
||||||
id="throughput2-label"
|
>
|
||||||
>
|
<StyledSliderBase
|
||||||
<ToolTipLabelComponent
|
ariaLabel="Throughput (Slider)"
|
||||||
label="Throughput (Slider)"
|
label="Throughput (Slider)"
|
||||||
/>
|
max={500}
|
||||||
</StyledLabelBase>
|
min={400}
|
||||||
<div
|
onChange={[Function]}
|
||||||
id="throughput2-slider-input"
|
step={10}
|
||||||
>
|
styles={
|
||||||
<StyledSliderBase
|
Object {
|
||||||
ariaLabel="Throughput (Slider)"
|
"root": Object {
|
||||||
max={500}
|
"width": 400,
|
||||||
min={400}
|
},
|
||||||
onChange={[Function]}
|
"titleLabel": Object {
|
||||||
step={10}
|
"color": "#393939",
|
||||||
styles={
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
Object {
|
"fontSize": 12,
|
||||||
"root": Object {
|
"fontWeight": 600,
|
||||||
"width": 400,
|
},
|
||||||
},
|
"valueLabel": Object {
|
||||||
"valueLabel": Object {
|
"color": "#393939",
|
||||||
"color": "#393939",
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
"fontSize": 12,
|
||||||
"fontSize": 12,
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</div>
|
/>
|
||||||
</Stack>
|
</div>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -500,33 +515,34 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<div
|
||||||
<StyledLabelBase
|
className="stringInputContainer"
|
||||||
id="containerId-label"
|
>
|
||||||
>
|
<StyledTextFieldBase
|
||||||
<ToolTipLabelComponent
|
id="containerId-textField-input"
|
||||||
label="Container id"
|
label="Container id"
|
||||||
/>
|
onChange={[Function]}
|
||||||
</StyledLabelBase>
|
styles={
|
||||||
<div
|
Object {
|
||||||
className="stringInputContainer"
|
"root": Object {
|
||||||
>
|
"width": 400,
|
||||||
<StyledTextFieldBase
|
},
|
||||||
aria-labelledby="containerId-label"
|
"subComponentStyles": Object {
|
||||||
id="containerId-textField-input"
|
"label": Object {
|
||||||
onChange={[Function]}
|
"root": Object {
|
||||||
styles={
|
"color": "#393939",
|
||||||
Object {
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
"root": Object {
|
"fontSize": 12,
|
||||||
"width": 400,
|
"fontWeight": 600,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
type="text"
|
}
|
||||||
value=""
|
type="text"
|
||||||
/>
|
value=""
|
||||||
</div>
|
/>
|
||||||
</Stack>
|
</div>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -542,30 +558,21 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<StyledToggleBase
|
||||||
<StyledLabelBase
|
checked={false}
|
||||||
id="analyticalStore-label"
|
id="analyticalStore-toggle-input"
|
||||||
>
|
label="Analytical Store"
|
||||||
<ToolTipLabelComponent
|
offText="Disabled"
|
||||||
label="Analytical Store"
|
onChange={[Function]}
|
||||||
/>
|
onText="Enabled"
|
||||||
</StyledLabelBase>
|
styles={
|
||||||
<StyledToggleBase
|
Object {
|
||||||
aria-labelledby="analyticalStore-label"
|
"root": Object {
|
||||||
checked={false}
|
"width": 400,
|
||||||
id="analyticalStore-toggle-input"
|
},
|
||||||
offText="Disabled"
|
|
||||||
onChange={[Function]}
|
|
||||||
onText="Enabled"
|
|
||||||
styles={
|
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"width": 400,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</Stack>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -581,49 +588,46 @@ exports[`SmartUiComponent should render and honor input's hidden, disabled state
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<Stack>
|
<StyledWithResponsiveMode
|
||||||
<StyledLabelBase
|
id="database-dropdown-input"
|
||||||
id="database-label"
|
label="Database"
|
||||||
>
|
onChange={[Function]}
|
||||||
<ToolTipLabelComponent
|
options={
|
||||||
label="Database"
|
Array [
|
||||||
/>
|
|
||||||
</StyledLabelBase>
|
|
||||||
<StyledWithResponsiveMode
|
|
||||||
aria-labelledby="database-label"
|
|
||||||
id="database-dropdown-input"
|
|
||||||
onChange={[Function]}
|
|
||||||
options={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"key": "db1",
|
|
||||||
"text": "Database 1",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "db2",
|
|
||||||
"text": "Database 2",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "db3",
|
|
||||||
"text": "Database 3",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
selectedKey="db2"
|
|
||||||
styles={
|
|
||||||
Object {
|
Object {
|
||||||
"dropdown": Object {
|
"key": "db1",
|
||||||
"color": "#393939",
|
"text": "Database 1",
|
||||||
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
},
|
||||||
"fontSize": 12,
|
Object {
|
||||||
},
|
"key": "db2",
|
||||||
"root": Object {
|
"text": "Database 2",
|
||||||
"width": 400,
|
},
|
||||||
},
|
Object {
|
||||||
}
|
"key": "db3",
|
||||||
|
"text": "Database 3",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
selectedKey="db2"
|
||||||
|
styles={
|
||||||
|
Object {
|
||||||
|
"dropdown": Object {
|
||||||
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
},
|
||||||
|
"label": Object {
|
||||||
|
"color": "#393939",
|
||||||
|
"fontFamily": "wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif",
|
||||||
|
"fontSize": 12,
|
||||||
|
"fontWeight": 600,
|
||||||
|
},
|
||||||
|
"root": Object {
|
||||||
|
"width": 400,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
/>
|
}
|
||||||
</Stack>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ export interface ThroughputInputParams {
|
|||||||
throughputModeRadioName: string;
|
throughputModeRadioName: string;
|
||||||
maxAutoPilotThroughputSet: ViewModels.Editable<number>;
|
maxAutoPilotThroughputSet: ViewModels.Editable<number>;
|
||||||
autoPilotUsageCost: ko.Computed<string>;
|
autoPilotUsageCost: ko.Computed<string>;
|
||||||
|
showAutoPilot?: ko.Observable<boolean>;
|
||||||
overrideWithAutoPilotSettings: ko.Observable<boolean>;
|
overrideWithAutoPilotSettings: ko.Observable<boolean>;
|
||||||
overrideWithProvisionedThroughputSettings: ko.Observable<boolean>;
|
overrideWithProvisionedThroughputSettings: ko.Observable<boolean>;
|
||||||
freeTierExceedThroughputTooltip?: ko.Observable<string>;
|
freeTierExceedThroughputTooltip?: ko.Observable<string>;
|
||||||
@@ -157,6 +158,7 @@ export class ThroughputInputViewModel extends WaitsForTemplateViewModel {
|
|||||||
public infoBubbleText: string | ko.Observable<string>;
|
public infoBubbleText: string | ko.Observable<string>;
|
||||||
public label: ko.Observable<string>;
|
public label: ko.Observable<string>;
|
||||||
public isFixed: boolean;
|
public isFixed: boolean;
|
||||||
|
public showAutoPilot: ko.Observable<boolean>;
|
||||||
public isAutoPilotSelected: ko.Observable<boolean>;
|
public isAutoPilotSelected: ko.Observable<boolean>;
|
||||||
public throughputAutoPilotRadioId: string;
|
public throughputAutoPilotRadioId: string;
|
||||||
public throughputProvisionedRadioId: string;
|
public throughputProvisionedRadioId: string;
|
||||||
@@ -200,6 +202,7 @@ export class ThroughputInputViewModel extends WaitsForTemplateViewModel {
|
|||||||
this.isFixed = !!options.isFixed;
|
this.isFixed = !!options.isFixed;
|
||||||
this.infoBubbleText = options.infoBubbleText || ko.observable<string>();
|
this.infoBubbleText = options.infoBubbleText || ko.observable<string>();
|
||||||
this.label = options.label || ko.observable<string>();
|
this.label = options.label || ko.observable<string>();
|
||||||
|
this.showAutoPilot = options.showAutoPilot !== undefined ? options.showAutoPilot : ko.observable<boolean>(true);
|
||||||
this.isAutoPilotSelected = options.isAutoPilotSelected || ko.observable<boolean>(false);
|
this.isAutoPilotSelected = options.isAutoPilotSelected || ko.observable<boolean>(false);
|
||||||
this.isAutoPilotSelected.subscribe((value) => {
|
this.isAutoPilotSelected.subscribe((value) => {
|
||||||
TelemetryProcessor.trace(Action.ToggleAutoscaleSetting, ActionModifiers.Mark, {
|
TelemetryProcessor.trace(Action.ToggleAutoscaleSetting, ActionModifiers.Mark, {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ko if: !isFixed -->
|
<!-- ko if: !isFixed -->
|
||||||
<div class="throughputModeContainer">
|
<div data-bind="visible: showAutoPilot" class="throughputModeContainer">
|
||||||
<input
|
<input
|
||||||
class="throughputModeRadio"
|
class="throughputModeRadio"
|
||||||
aria-label="Autopilot mode"
|
aria-label="Autopilot mode"
|
||||||
|
|||||||
@@ -1,87 +1,93 @@
|
|||||||
import * as ko from "knockout";
|
|
||||||
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
|
||||||
import * as path from "path";
|
|
||||||
import Q from "q";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import _ from "underscore";
|
|
||||||
import { AuthType } from "../AuthType";
|
|
||||||
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
|
||||||
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
|
||||||
import * as Constants from "../Common/Constants";
|
|
||||||
import { ExplorerMetrics } from "../Common/Constants";
|
|
||||||
import { readCollection } from "../Common/dataAccess/readCollection";
|
|
||||||
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
|
||||||
import { getErrorMessage, getErrorStack, handleError } from "../Common/ErrorHandlingUtils";
|
|
||||||
import * as Logger from "../Common/Logger";
|
|
||||||
import { sendCachedDataMessage, sendMessage } from "../Common/MessageHandler";
|
|
||||||
import { QueriesClient } from "../Common/QueriesClient";
|
|
||||||
import { Splitter, SplitterBounds, SplitterDirection } from "../Common/Splitter";
|
|
||||||
import { configContext, Platform } from "../ConfigContext";
|
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
|
||||||
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
|
||||||
import { IGalleryItem } from "../Juno/JunoClient";
|
|
||||||
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
|
||||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
|
||||||
import { RouteHandler } from "../RouteHandlers/RouteHandler";
|
|
||||||
import { appInsights } from "../Shared/appInsights";
|
|
||||||
import * as SharedConstants from "../Shared/Constants";
|
|
||||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
|
||||||
import { ExplorerSettings } from "../Shared/ExplorerSettings";
|
|
||||||
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
|
||||||
import { ArcadiaResourceManager } from "../SparkClusterManager/ArcadiaResourceManager";
|
|
||||||
import { updateUserContext, userContext } from "../UserContext";
|
|
||||||
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
|
||||||
import { stringToBlob } from "../Utils/BlobUtils";
|
|
||||||
import { fromContentUri, toRawContentUri } from "../Utils/GitHubUtils";
|
|
||||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
|
||||||
import * as ComponentRegisterer from "./ComponentRegisterer";
|
import * as ComponentRegisterer from "./ComponentRegisterer";
|
||||||
import { ArcadiaWorkspaceItem } from "./Controls/Arcadia/ArcadiaMenuPicker";
|
import * as Constants from "../Common/Constants";
|
||||||
import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { DialogProps, TextFieldProps } from "./Controls/Dialog";
|
import * as ko from "knockout";
|
||||||
import { GalleryTab } from "./Controls/NotebookGallery/GalleryViewerComponent";
|
import * as path from "path";
|
||||||
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
import * as SharedConstants from "../Shared/Constants";
|
||||||
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import { FileSystemUtil } from "./Notebook/FileSystemUtil";
|
import _ from "underscore";
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
|
||||||
import { NotebookUtil } from "./Notebook/NotebookUtil";
|
|
||||||
import AddCollectionPane from "./Panes/AddCollectionPane";
|
import AddCollectionPane from "./Panes/AddCollectionPane";
|
||||||
import AddDatabasePane from "./Panes/AddDatabasePane";
|
import AddDatabasePane from "./Panes/AddDatabasePane";
|
||||||
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
import AddTableEntityPane from "./Panes/Tables/AddTableEntityPane";
|
||||||
|
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||||
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
|
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
|
||||||
import { ContextualPaneBase } from "./Panes/ContextualPaneBase";
|
import Database from "./Tree/Database";
|
||||||
import DeleteCollectionConfirmationPane from "./Panes/DeleteCollectionConfirmationPane";
|
import DeleteCollectionConfirmationPane from "./Panes/DeleteCollectionConfirmationPane";
|
||||||
import { DeleteCollectionConfirmationPanel } from "./Panes/DeleteCollectionConfirmationPanel";
|
|
||||||
import DeleteDatabaseConfirmationPane from "./Panes/DeleteDatabaseConfirmationPane";
|
import DeleteDatabaseConfirmationPane from "./Panes/DeleteDatabaseConfirmationPane";
|
||||||
import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane";
|
import { readCollection } from "../Common/dataAccess/readCollection";
|
||||||
|
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
||||||
|
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
||||||
|
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
||||||
import GraphStylingPane from "./Panes/GraphStylingPane";
|
import GraphStylingPane from "./Panes/GraphStylingPane";
|
||||||
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
|
||||||
import NewVertexPane from "./Panes/NewVertexPane";
|
import NewVertexPane from "./Panes/NewVertexPane";
|
||||||
|
import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab";
|
||||||
|
import Q from "q";
|
||||||
|
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
||||||
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import TerminalTab from "./Tabs/TerminalTab";
|
||||||
|
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
|
import { ArcadiaResourceManager } from "../SparkClusterManager/ArcadiaResourceManager";
|
||||||
|
import { ArcadiaWorkspaceItem } from "./Controls/Arcadia/ArcadiaMenuPicker";
|
||||||
|
import { AuthType } from "../AuthType";
|
||||||
|
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
||||||
|
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
||||||
|
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
||||||
|
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
||||||
|
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
||||||
|
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
|
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||||
|
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||||
|
import { DialogProps, TextFieldProps } from "./Controls/Dialog";
|
||||||
|
import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane";
|
||||||
|
import { ExplorerMetrics } from "../Common/Constants";
|
||||||
|
import { ExplorerSettings } from "../Shared/ExplorerSettings";
|
||||||
|
import { FileSystemUtil } from "./Notebook/FileSystemUtil";
|
||||||
|
import { IGalleryItem } from "../Juno/JunoClient";
|
||||||
|
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
||||||
|
import * as Logger from "../Common/Logger";
|
||||||
|
import { sendMessage, sendCachedDataMessage } from "../Common/MessageHandler";
|
||||||
|
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
||||||
|
import * as NotebookUtil from "./Notebook/NotebookUtil";
|
||||||
|
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
||||||
|
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||||
|
import { QueriesClient } from "../Common/QueriesClient";
|
||||||
|
import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane";
|
||||||
|
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||||
|
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
||||||
|
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
||||||
|
import { RouteHandler } from "../RouteHandlers/RouteHandler";
|
||||||
import { SaveQueryPane } from "./Panes/SaveQueryPane";
|
import { SaveQueryPane } from "./Panes/SaveQueryPane";
|
||||||
import { SettingsPane } from "./Panes/SettingsPane";
|
import { SettingsPane } from "./Panes/SettingsPane";
|
||||||
import { SetupNotebooksPane } from "./Panes/SetupNotebooksPane";
|
import { SetupNotebooksPane } from "./Panes/SetupNotebooksPane";
|
||||||
|
import { SplashScreen } from "./SplashScreen/SplashScreen";
|
||||||
|
import { Splitter, SplitterBounds, SplitterDirection } from "../Common/Splitter";
|
||||||
import { StringInputPane } from "./Panes/StringInputPane";
|
import { StringInputPane } from "./Panes/StringInputPane";
|
||||||
import AddTableEntityPane from "./Panes/Tables/AddTableEntityPane";
|
|
||||||
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
|
||||||
import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane";
|
|
||||||
import { TableColumnOptionsPane } from "./Panes/Tables/TableColumnOptionsPane";
|
import { TableColumnOptionsPane } from "./Panes/Tables/TableColumnOptionsPane";
|
||||||
|
import { TabsManager } from "./Tabs/TabsManager";
|
||||||
import { UploadFilePane } from "./Panes/UploadFilePane";
|
import { UploadFilePane } from "./Panes/UploadFilePane";
|
||||||
import { UploadItemsPane } from "./Panes/UploadItemsPane";
|
import { UploadItemsPane } from "./Panes/UploadItemsPane";
|
||||||
import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter";
|
import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter";
|
||||||
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab";
|
import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils";
|
||||||
import TabsBase from "./Tabs/TabsBase";
|
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
||||||
import { TabsManager } from "./Tabs/TabsManager";
|
|
||||||
import TerminalTab from "./Tabs/TerminalTab";
|
|
||||||
import Database from "./Tree/Database";
|
|
||||||
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
|
||||||
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
|
||||||
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
|
||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import Trigger from "./Tree/Trigger";
|
import Trigger from "./Tree/Trigger";
|
||||||
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
import { ContextualPaneBase } from "./Panes/ContextualPaneBase";
|
||||||
|
import TabsBase from "./Tabs/TabsBase";
|
||||||
|
import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import { updateUserContext, userContext } from "../UserContext";
|
||||||
|
import { stringToBlob } from "../Utils/BlobUtils";
|
||||||
|
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
||||||
|
import { getErrorMessage, handleError, getErrorStack } from "../Common/ErrorHandlingUtils";
|
||||||
|
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
||||||
|
import { appInsights } from "../Shared/appInsights";
|
||||||
|
import { SelfServeLoadingComponentAdapter } from "../SelfServe/SelfServeLoadingComponentAdapter";
|
||||||
|
import { SelfServeType } from "../SelfServe/SelfServeUtils";
|
||||||
|
import { SelfServeComponentAdapter } from "../SelfServe/SelfServeComponentAdapter";
|
||||||
|
import { GalleryTab } from "./Controls/NotebookGallery/GalleryViewerComponent";
|
||||||
|
import { DeleteCollectionConfirmationPanel } from "./Panes/DeleteCollectionConfirmationPanel";
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||||
@@ -112,55 +118,20 @@ export default class Explorer {
|
|||||||
public hasWriteAccess: ko.Observable<boolean>;
|
public hasWriteAccess: ko.Observable<boolean>;
|
||||||
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
|
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Use userContext.databaseAccount instead
|
|
||||||
* */
|
|
||||||
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
||||||
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Use userContext.subscriptionType instead
|
|
||||||
* */
|
|
||||||
public subscriptionType: ko.Observable<SubscriptionType>;
|
public subscriptionType: ko.Observable<SubscriptionType>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Use userContext.apiType instead
|
|
||||||
* */
|
|
||||||
public defaultExperience: ko.Observable<string>;
|
public defaultExperience: ko.Observable<string>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "SQL"
|
|
||||||
* */
|
|
||||||
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Cassandra"
|
|
||||||
* */
|
|
||||||
public isPreferredApiCassandra: ko.Computed<boolean>;
|
public isPreferredApiCassandra: ko.Computed<boolean>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
|
||||||
* */
|
|
||||||
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Gremlin"
|
|
||||||
* */
|
|
||||||
public isPreferredApiGraph: ko.Computed<boolean>;
|
public isPreferredApiGraph: ko.Computed<boolean>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Tables"
|
|
||||||
* */
|
|
||||||
public isPreferredApiTable: ko.Computed<boolean>;
|
public isPreferredApiTable: ko.Computed<boolean>;
|
||||||
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
|
||||||
* */
|
|
||||||
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
||||||
public isServerlessEnabled: ko.Computed<boolean>;
|
public isServerlessEnabled: ko.Computed<boolean>;
|
||||||
public isAccountReady: ko.Observable<boolean>;
|
public isAccountReady: ko.Observable<boolean>;
|
||||||
|
public selfServeType: ko.Observable<SelfServeType>;
|
||||||
public canSaveQueries: ko.Computed<boolean>;
|
public canSaveQueries: ko.Computed<boolean>;
|
||||||
public features: ko.Observable<any>;
|
public features: ko.Observable<any>;
|
||||||
public serverId: ko.Observable<string>;
|
public serverId: ko.Observable<string>;
|
||||||
@@ -186,12 +157,9 @@ export default class Explorer {
|
|||||||
public selectedCollectionId: ko.Computed<string>;
|
public selectedCollectionId: ko.Computed<string>;
|
||||||
public isLeftPaneExpanded: ko.Observable<boolean>;
|
public isLeftPaneExpanded: ko.Observable<boolean>;
|
||||||
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Use a local loading state and spinner instead. Using a global isRefreshing state causes problems.
|
|
||||||
* */
|
|
||||||
public isRefreshingExplorer: ko.Observable<boolean>;
|
public isRefreshingExplorer: ko.Observable<boolean>;
|
||||||
private resourceTree: ResourceTreeAdapter;
|
private resourceTree: ResourceTreeAdapter;
|
||||||
|
private selfServeComponentAdapter: SelfServeComponentAdapter;
|
||||||
|
|
||||||
// Resource Token
|
// Resource Token
|
||||||
public resourceTokenDatabaseId: ko.Observable<string>;
|
public resourceTokenDatabaseId: ko.Observable<string>;
|
||||||
@@ -275,6 +243,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
// React adapters
|
// React adapters
|
||||||
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
||||||
|
private selfServeLoadingComponentAdapter: SelfServeLoadingComponentAdapter;
|
||||||
|
|
||||||
private static readonly MaxNbDatabasesToAutoExpand = 5;
|
private static readonly MaxNbDatabasesToAutoExpand = 5;
|
||||||
|
|
||||||
@@ -318,6 +287,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.isAccountReady = ko.observable<boolean>(false);
|
this.isAccountReady = ko.observable<boolean>(false);
|
||||||
|
this.selfServeType = ko.observable<SelfServeType>(undefined);
|
||||||
this._isInitializingNotebooks = false;
|
this._isInitializingNotebooks = false;
|
||||||
this.arcadiaToken = ko.observable<string>();
|
this.arcadiaToken = ko.observable<string>();
|
||||||
this.arcadiaToken.subscribe((token: string) => {
|
this.arcadiaToken.subscribe((token: string) => {
|
||||||
@@ -469,7 +439,6 @@ export default class Explorer {
|
|||||||
databaseAccount
|
databaseAccount
|
||||||
);
|
);
|
||||||
this.defaultExperience(defaultExperience);
|
this.defaultExperience(defaultExperience);
|
||||||
// TODO. Remove this entirely
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
defaultExperience: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
|
defaultExperience: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
|
||||||
});
|
});
|
||||||
@@ -693,6 +662,7 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.uploadItemsPaneAdapter = new UploadItemsPaneAdapter(this);
|
this.uploadItemsPaneAdapter = new UploadItemsPaneAdapter(this);
|
||||||
|
this.selfServeComponentAdapter = new SelfServeComponentAdapter(this);
|
||||||
|
|
||||||
this.loadQueryPane = new LoadQueryPane({
|
this.loadQueryPane = new LoadQueryPane({
|
||||||
id: "loadquerypane",
|
id: "loadquerypane",
|
||||||
@@ -775,90 +745,99 @@ export default class Explorer {
|
|||||||
$(document.body).click(() => $(".commandDropdownContainer").hide());
|
$(document.body).click(() => $(".commandDropdownContainer").hide());
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (userContext.apiType) {
|
// TODO move this to API customization class
|
||||||
case "SQL":
|
this.defaultExperience.subscribe((defaultExperience) => {
|
||||||
this.addCollectionText("New Container");
|
const defaultExperienceNormalizedString = (
|
||||||
this.addDatabaseText("New Database");
|
defaultExperience || Constants.DefaultAccountExperience.Default
|
||||||
this.collectionTitle("SQL API");
|
).toLowerCase();
|
||||||
this.collectionTreeNodeAltText("Container");
|
|
||||||
this.deleteCollectionText("Delete Container");
|
switch (defaultExperienceNormalizedString) {
|
||||||
this.deleteDatabaseText("Delete Database");
|
case Constants.DefaultAccountExperience.DocumentDB.toLowerCase():
|
||||||
this.addCollectionPane.title("Add Container");
|
this.addCollectionText("New Container");
|
||||||
this.addCollectionPane.collectionIdTitle("Container id");
|
this.addDatabaseText("New Database");
|
||||||
this.addCollectionPane.collectionWithThroughputInSharedTitle(
|
this.collectionTitle("SQL API");
|
||||||
"Provision dedicated throughput for this container"
|
this.collectionTreeNodeAltText("Container");
|
||||||
);
|
this.deleteCollectionText("Delete Container");
|
||||||
this.deleteCollectionConfirmationPane.title("Delete Container");
|
this.deleteDatabaseText("Delete Database");
|
||||||
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the container id");
|
this.addCollectionPane.title("Add Container");
|
||||||
this.refreshTreeTitle("Refresh containers");
|
this.addCollectionPane.collectionIdTitle("Container id");
|
||||||
break;
|
this.addCollectionPane.collectionWithThroughputInSharedTitle(
|
||||||
case "Mongo":
|
"Provision dedicated throughput for this container"
|
||||||
this.addCollectionText("New Collection");
|
);
|
||||||
this.addDatabaseText("New Database");
|
this.deleteCollectionConfirmationPane.title("Delete Container");
|
||||||
this.collectionTitle("Collections");
|
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the container id");
|
||||||
this.collectionTreeNodeAltText("Collection");
|
this.refreshTreeTitle("Refresh containers");
|
||||||
this.deleteCollectionText("Delete Collection");
|
break;
|
||||||
this.deleteDatabaseText("Delete Database");
|
case Constants.DefaultAccountExperience.MongoDB.toLowerCase():
|
||||||
this.addCollectionPane.title("Add Collection");
|
case Constants.DefaultAccountExperience.ApiForMongoDB.toLowerCase():
|
||||||
this.addCollectionPane.collectionIdTitle("Collection id");
|
this.addCollectionText("New Collection");
|
||||||
this.addCollectionPane.collectionWithThroughputInSharedTitle(
|
this.addDatabaseText("New Database");
|
||||||
"Provision dedicated throughput for this collection"
|
this.collectionTitle("Collections");
|
||||||
);
|
this.collectionTreeNodeAltText("Collection");
|
||||||
this.refreshTreeTitle("Refresh collections");
|
this.deleteCollectionText("Delete Collection");
|
||||||
break;
|
this.deleteDatabaseText("Delete Database");
|
||||||
case "Gremlin":
|
this.addCollectionPane.title("Add Collection");
|
||||||
this.addCollectionText("New Graph");
|
this.addCollectionPane.collectionIdTitle("Collection id");
|
||||||
this.addDatabaseText("New Database");
|
this.addCollectionPane.collectionWithThroughputInSharedTitle(
|
||||||
this.deleteCollectionText("Delete Graph");
|
"Provision dedicated throughput for this collection"
|
||||||
this.deleteDatabaseText("Delete Database");
|
);
|
||||||
this.collectionTitle("Gremlin API");
|
this.refreshTreeTitle("Refresh collections");
|
||||||
this.collectionTreeNodeAltText("Graph");
|
break;
|
||||||
this.addCollectionPane.title("Add Graph");
|
case Constants.DefaultAccountExperience.Graph.toLowerCase():
|
||||||
this.addCollectionPane.collectionIdTitle("Graph id");
|
this.addCollectionText("New Graph");
|
||||||
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this graph");
|
this.addDatabaseText("New Database");
|
||||||
this.deleteCollectionConfirmationPane.title("Delete Graph");
|
this.deleteCollectionText("Delete Graph");
|
||||||
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the graph id");
|
this.deleteDatabaseText("Delete Database");
|
||||||
this.refreshTreeTitle("Refresh graphs");
|
this.collectionTitle("Gremlin API");
|
||||||
break;
|
this.collectionTreeNodeAltText("Graph");
|
||||||
case "Tables":
|
this.addCollectionPane.title("Add Graph");
|
||||||
this.addCollectionText("New Table");
|
this.addCollectionPane.collectionIdTitle("Graph id");
|
||||||
this.addDatabaseText("New Database");
|
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this graph");
|
||||||
this.deleteCollectionText("Delete Table");
|
this.deleteCollectionConfirmationPane.title("Delete Graph");
|
||||||
this.deleteDatabaseText("Delete Database");
|
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the graph id");
|
||||||
this.collectionTitle("Azure Table API");
|
this.refreshTreeTitle("Refresh graphs");
|
||||||
this.collectionTreeNodeAltText("Table");
|
break;
|
||||||
this.addCollectionPane.title("Add Table");
|
case Constants.DefaultAccountExperience.Table.toLowerCase():
|
||||||
this.addCollectionPane.collectionIdTitle("Table id");
|
this.addCollectionText("New Table");
|
||||||
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this table");
|
this.addDatabaseText("New Database");
|
||||||
this.refreshTreeTitle("Refresh tables");
|
this.deleteCollectionText("Delete Table");
|
||||||
this.addTableEntityPane.title("Add Table Entity");
|
this.deleteDatabaseText("Delete Database");
|
||||||
this.editTableEntityPane.title("Edit Table Entity");
|
this.collectionTitle("Azure Table API");
|
||||||
this.deleteCollectionConfirmationPane.title("Delete Table");
|
this.collectionTreeNodeAltText("Table");
|
||||||
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the table id");
|
this.addCollectionPane.title("Add Table");
|
||||||
this.tableDataClient = new TablesAPIDataClient();
|
this.addCollectionPane.collectionIdTitle("Table id");
|
||||||
break;
|
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this table");
|
||||||
case "Cassandra":
|
this.refreshTreeTitle("Refresh tables");
|
||||||
this.addCollectionText("New Table");
|
this.addTableEntityPane.title("Add Table Entity");
|
||||||
this.addDatabaseText("New Keyspace");
|
this.editTableEntityPane.title("Edit Table Entity");
|
||||||
this.deleteCollectionText("Delete Table");
|
this.deleteCollectionConfirmationPane.title("Delete Table");
|
||||||
this.deleteDatabaseText("Delete Keyspace");
|
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the table id");
|
||||||
this.collectionTitle("Cassandra API");
|
this.tableDataClient = new TablesAPIDataClient();
|
||||||
this.collectionTreeNodeAltText("Table");
|
break;
|
||||||
this.addCollectionPane.title("Add Table");
|
case Constants.DefaultAccountExperience.Cassandra.toLowerCase():
|
||||||
this.addCollectionPane.collectionIdTitle("Table id");
|
this.addCollectionText("New Table");
|
||||||
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this table");
|
this.addDatabaseText("New Keyspace");
|
||||||
this.refreshTreeTitle("Refresh tables");
|
this.deleteCollectionText("Delete Table");
|
||||||
this.addTableEntityPane.title("Add Table Row");
|
this.deleteDatabaseText("Delete Keyspace");
|
||||||
this.editTableEntityPane.title("Edit Table Row");
|
this.collectionTitle("Cassandra API");
|
||||||
this.deleteCollectionConfirmationPane.title("Delete Table");
|
this.collectionTreeNodeAltText("Table");
|
||||||
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the table id");
|
this.addCollectionPane.title("Add Table");
|
||||||
this.deleteDatabaseConfirmationPane.title("Delete Keyspace");
|
this.addCollectionPane.collectionIdTitle("Table id");
|
||||||
this.deleteDatabaseConfirmationPane.databaseIdConfirmationText("Confirm by typing the keyspace id");
|
this.addCollectionPane.collectionWithThroughputInSharedTitle("Provision dedicated throughput for this table");
|
||||||
this.tableDataClient = new CassandraAPIDataClient();
|
this.refreshTreeTitle("Refresh tables");
|
||||||
break;
|
this.addTableEntityPane.title("Add Table Row");
|
||||||
}
|
this.editTableEntityPane.title("Edit Table Row");
|
||||||
|
this.deleteCollectionConfirmationPane.title("Delete Table");
|
||||||
|
this.deleteCollectionConfirmationPane.collectionIdConfirmationText("Confirm by typing the table id");
|
||||||
|
this.deleteDatabaseConfirmationPane.title("Delete Keyspace");
|
||||||
|
this.deleteDatabaseConfirmationPane.databaseIdConfirmationText("Confirm by typing the keyspace id");
|
||||||
|
this.tableDataClient = new CassandraAPIDataClient();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.commandBarComponentAdapter = new CommandBarComponentAdapter(this);
|
this.commandBarComponentAdapter = new CommandBarComponentAdapter(this);
|
||||||
|
this.selfServeLoadingComponentAdapter = new SelfServeLoadingComponentAdapter();
|
||||||
|
|
||||||
this._initSettings();
|
this._initSettings();
|
||||||
|
|
||||||
@@ -1428,6 +1407,20 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setSelfServeType(inputs: ViewModels.DataExplorerInputsFrame): void {
|
||||||
|
const selfServeFeature = inputs.features[Constants.Features.selfServeType];
|
||||||
|
if (selfServeFeature) {
|
||||||
|
// self serve type received from query string
|
||||||
|
const selfServeType = SelfServeType[selfServeFeature?.toLowerCase() as keyof typeof SelfServeType];
|
||||||
|
this.selfServeType(selfServeType ? selfServeType : SelfServeType.invalid);
|
||||||
|
} else if (inputs.selfServeType) {
|
||||||
|
// self serve type received from portal
|
||||||
|
this.selfServeType(inputs.selfServeType);
|
||||||
|
} else {
|
||||||
|
this.selfServeType(SelfServeType.none);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public configure(inputs: ViewModels.DataExplorerInputsFrame): void {
|
public configure(inputs: ViewModels.DataExplorerInputsFrame): void {
|
||||||
if (inputs != null) {
|
if (inputs != null) {
|
||||||
// In development mode, save the iframe message from the portal in session storage.
|
// In development mode, save the iframe message from the portal in session storage.
|
||||||
@@ -1436,6 +1429,8 @@ export default class Explorer {
|
|||||||
sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs));
|
sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
|
const masterKey = inputs.masterKey || "";
|
||||||
const databaseAccount = inputs.databaseAccount || null;
|
const databaseAccount = inputs.databaseAccount || null;
|
||||||
if (inputs.defaultCollectionThroughput) {
|
if (inputs.defaultCollectionThroughput) {
|
||||||
this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
|
this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
|
||||||
@@ -1451,6 +1446,22 @@ export default class Explorer {
|
|||||||
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription ?? false);
|
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription ?? false);
|
||||||
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken ?? false);
|
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken ?? false);
|
||||||
this.setFeatureFlagsFromFlights(inputs.flights);
|
this.setFeatureFlagsFromFlights(inputs.flights);
|
||||||
|
this.setSelfServeType(inputs);
|
||||||
|
|
||||||
|
updateConfigContext({
|
||||||
|
BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT,
|
||||||
|
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
||||||
|
});
|
||||||
|
|
||||||
|
updateUserContext({
|
||||||
|
authorizationToken,
|
||||||
|
masterKey,
|
||||||
|
databaseAccount,
|
||||||
|
resourceGroup: inputs.resourceGroup,
|
||||||
|
subscriptionId: inputs.subscriptionId,
|
||||||
|
subscriptionType: inputs.subscriptionType,
|
||||||
|
quotaId: inputs.quotaId,
|
||||||
|
});
|
||||||
TelemetryProcessor.traceSuccess(
|
TelemetryProcessor.traceSuccess(
|
||||||
Action.LoadDatabaseAccount,
|
Action.LoadDatabaseAccount,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
/**
|
|
||||||
* This adapter is responsible to render the React component
|
|
||||||
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
|
||||||
* and update any knockout observables passed from the parent.
|
|
||||||
*/
|
|
||||||
import * as ko from "knockout";
|
|
||||||
import { CommandBar, ICommandBarItemProps } from "office-ui-fabric-react/lib/CommandBar";
|
|
||||||
import * as React from "react";
|
|
||||||
import { StyleConstants } from "../../../Common/Constants";
|
|
||||||
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
|
||||||
import * as CommandBarComponentButtonFactory from "./CommandBarComponentButtonFactory";
|
|
||||||
import * as CommandBarUtil from "./CommandBarUtil";
|
|
||||||
|
|
||||||
export interface CommandBarComponentProps {
|
|
||||||
isNotebookTabActive: boolean;
|
|
||||||
tabsButtons: CommandButtonComponentProps[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CommandBarComponent: React.FunctionComponent = ({ isNotebookTabActive, tabsButtons }: CommandBarComponentProps) {
|
|
||||||
|
|
||||||
constructor(props: CommandBarComponentProps) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isNotebookTabActive: false
|
|
||||||
}
|
|
||||||
|
|
||||||
this.container = container;
|
|
||||||
this.tabsButtons = [];
|
|
||||||
// this.isNotebookTabActive = ko.computed(() =>
|
|
||||||
// container.tabsManager.isTabActive(ViewModels.CollectionTabKind.NotebookV2)
|
|
||||||
// );
|
|
||||||
|
|
||||||
// These are the parameters watched by the react binding that will trigger a renderComponent() if one of the ko mutates
|
|
||||||
const toWatch = [
|
|
||||||
container.isPreferredApiTable,
|
|
||||||
container.isPreferredApiMongoDB,
|
|
||||||
container.isPreferredApiDocumentDB,
|
|
||||||
container.isPreferredApiCassandra,
|
|
||||||
container.isPreferredApiGraph,
|
|
||||||
container.deleteCollectionText,
|
|
||||||
container.deleteDatabaseText,
|
|
||||||
container.addCollectionText,
|
|
||||||
container.addDatabaseText,
|
|
||||||
container.isDatabaseNodeOrNoneSelected,
|
|
||||||
container.isDatabaseNodeSelected,
|
|
||||||
container.isNoneSelected,
|
|
||||||
container.isResourceTokenCollectionNodeSelected,
|
|
||||||
container.isHostedDataExplorerEnabled,
|
|
||||||
container.isSynapseLinkUpdating,
|
|
||||||
container.databaseAccount,
|
|
||||||
this.isNotebookTabActive,
|
|
||||||
container.isServerlessEnabled,
|
|
||||||
];
|
|
||||||
|
|
||||||
ko.computed(() => ko.toJSON(toWatch)).subscribe(() => this.triggerRender());
|
|
||||||
this.parameters = ko.observable(Date.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
public onUpdateTabsButtons(buttons: CommandButtonComponentProps[]): void {
|
|
||||||
this.tabsButtons = buttons;
|
|
||||||
this.triggerRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
const backgroundColor = StyleConstants.BaseLight;
|
|
||||||
|
|
||||||
const staticButtons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(this.container);
|
|
||||||
const contextButtons = (this.tabsButtons || []).concat(
|
|
||||||
CommandBarComponentButtonFactory.createContextCommandBarButtons(this.container)
|
|
||||||
);
|
|
||||||
const controlButtons = CommandBarComponentButtonFactory.createControlCommandBarButtons(this.container);
|
|
||||||
|
|
||||||
const uiFabricStaticButtons = CommandBarUtil.convertButton(staticButtons, backgroundColor);
|
|
||||||
if (this.tabsButtons && this.tabsButtons.length > 0) {
|
|
||||||
uiFabricStaticButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
|
||||||
}
|
|
||||||
|
|
||||||
const uiFabricTabsButtons: ICommandBarItemProps[] = CommandBarUtil.convertButton(contextButtons, backgroundColor);
|
|
||||||
|
|
||||||
if (uiFabricTabsButtons.length > 0) {
|
|
||||||
uiFabricStaticButtons.push(CommandBarUtil.createDivider("commandBarDivider"));
|
|
||||||
}
|
|
||||||
|
|
||||||
const uiFabricControlButtons = CommandBarUtil.convertButton(controlButtons, backgroundColor);
|
|
||||||
uiFabricControlButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
|
||||||
|
|
||||||
if (props.isNotebookTabActive) {
|
|
||||||
uiFabricControlButtons.unshift(
|
|
||||||
CommandBarUtil.createMemoryTracker("memoryTracker", this.container.memoryUsageInfo)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<div className="commandBarContainer">
|
|
||||||
<CommandBar
|
|
||||||
ariaLabel="Use left and right arrow keys to navigate between commands"
|
|
||||||
items={uiFabricStaticButtons.concat(uiFabricTabsButtons)}
|
|
||||||
farItems={uiFabricControlButtons}
|
|
||||||
styles={{
|
|
||||||
root: { backgroundColor: backgroundColor },
|
|
||||||
}}
|
|
||||||
overflowButtonProps={{ ariaLabel: "More commands" }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
110
src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx
Normal file
110
src/Explorer/Menus/CommandBar/CommandBarComponentAdapter.tsx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* This adapter is responsible to render the React component
|
||||||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||||||
|
* and update any knockout observables passed from the parent.
|
||||||
|
*/
|
||||||
|
import * as ko from "knockout";
|
||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
||||||
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
|
import * as CommandBarComponentButtonFactory from "./CommandBarComponentButtonFactory";
|
||||||
|
import { CommandBar, ICommandBarItemProps } from "office-ui-fabric-react/lib/CommandBar";
|
||||||
|
import { StyleConstants } from "../../../Common/Constants";
|
||||||
|
import * as CommandBarUtil from "./CommandBarUtil";
|
||||||
|
import Explorer from "../../Explorer";
|
||||||
|
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
|
||||||
|
export class CommandBarComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<number>;
|
||||||
|
public container: Explorer;
|
||||||
|
private tabsButtons: CommandButtonComponentProps[];
|
||||||
|
private isNotebookTabActive: ko.Computed<boolean>;
|
||||||
|
|
||||||
|
constructor(container: Explorer) {
|
||||||
|
this.container = container;
|
||||||
|
this.tabsButtons = [];
|
||||||
|
this.isNotebookTabActive = ko.computed(() =>
|
||||||
|
container.tabsManager.isTabActive(ViewModels.CollectionTabKind.NotebookV2)
|
||||||
|
);
|
||||||
|
|
||||||
|
// These are the parameters watched by the react binding that will trigger a renderComponent() if one of the ko mutates
|
||||||
|
const toWatch = [
|
||||||
|
container.isPreferredApiTable,
|
||||||
|
container.isPreferredApiMongoDB,
|
||||||
|
container.isPreferredApiDocumentDB,
|
||||||
|
container.isPreferredApiCassandra,
|
||||||
|
container.isPreferredApiGraph,
|
||||||
|
container.deleteCollectionText,
|
||||||
|
container.deleteDatabaseText,
|
||||||
|
container.addCollectionText,
|
||||||
|
container.addDatabaseText,
|
||||||
|
container.isDatabaseNodeOrNoneSelected,
|
||||||
|
container.isDatabaseNodeSelected,
|
||||||
|
container.isNoneSelected,
|
||||||
|
container.isResourceTokenCollectionNodeSelected,
|
||||||
|
container.isHostedDataExplorerEnabled,
|
||||||
|
container.isSynapseLinkUpdating,
|
||||||
|
container.databaseAccount,
|
||||||
|
this.isNotebookTabActive,
|
||||||
|
container.isServerlessEnabled,
|
||||||
|
];
|
||||||
|
|
||||||
|
ko.computed(() => ko.toJSON(toWatch)).subscribe(() => this.triggerRender());
|
||||||
|
this.parameters = ko.observable(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
public onUpdateTabsButtons(buttons: CommandButtonComponentProps[]): void {
|
||||||
|
this.tabsButtons = buttons;
|
||||||
|
this.triggerRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
const backgroundColor = StyleConstants.BaseLight;
|
||||||
|
|
||||||
|
const staticButtons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(this.container);
|
||||||
|
const contextButtons = (this.tabsButtons || []).concat(
|
||||||
|
CommandBarComponentButtonFactory.createContextCommandBarButtons(this.container)
|
||||||
|
);
|
||||||
|
const controlButtons = CommandBarComponentButtonFactory.createControlCommandBarButtons(this.container);
|
||||||
|
|
||||||
|
const uiFabricStaticButtons = CommandBarUtil.convertButton(staticButtons, backgroundColor);
|
||||||
|
if (this.tabsButtons && this.tabsButtons.length > 0) {
|
||||||
|
uiFabricStaticButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
||||||
|
}
|
||||||
|
|
||||||
|
const uiFabricTabsButtons: ICommandBarItemProps[] = CommandBarUtil.convertButton(contextButtons, backgroundColor);
|
||||||
|
|
||||||
|
if (uiFabricTabsButtons.length > 0) {
|
||||||
|
uiFabricStaticButtons.push(CommandBarUtil.createDivider("commandBarDivider"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const uiFabricControlButtons = CommandBarUtil.convertButton(controlButtons, backgroundColor);
|
||||||
|
uiFabricControlButtons.forEach((btn: ICommandBarItemProps) => (btn.iconOnly = true));
|
||||||
|
|
||||||
|
if (this.isNotebookTabActive()) {
|
||||||
|
uiFabricControlButtons.unshift(
|
||||||
|
CommandBarUtil.createMemoryTracker("memoryTracker", this.container.memoryUsageInfo)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="commandBarContainer">
|
||||||
|
<CommandBar
|
||||||
|
ariaLabel="Use left and right arrow keys to navigate between commands"
|
||||||
|
items={uiFabricStaticButtons.concat(uiFabricTabsButtons)}
|
||||||
|
farItems={uiFabricControlButtons}
|
||||||
|
styles={{
|
||||||
|
root: { backgroundColor: backgroundColor },
|
||||||
|
}}
|
||||||
|
overflowButtonProps={{ ariaLabel: "More commands" }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private triggerRender() {
|
||||||
|
window.requestAnimationFrame(() => this.parameters(Date.now()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as CommandBarUtil from "./CommandBarUtil";
|
import * as CommandBarUtil from "./CommandBarUtil";
|
||||||
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { ICommandBarItemProps } from "office-ui-fabric-react/lib/CommandBar";
|
import { ICommandBarItemProps } from "office-ui-fabric-react/lib/CommandBar";
|
||||||
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ describe("CommandBarUtil tests", () => {
|
|||||||
const converteds = CommandBarUtil.convertButton([btn], backgroundColor);
|
const converteds = CommandBarUtil.convertButton([btn], backgroundColor);
|
||||||
expect(converteds.length).toBe(1);
|
expect(converteds.length).toBe(1);
|
||||||
const converted = converteds[0];
|
const converted = converteds[0];
|
||||||
expect(converted.split).toBe(undefined);
|
expect(!converted.split);
|
||||||
expect(converted.iconProps.imageProps.src).toEqual(btn.iconSrc);
|
expect(converted.iconProps.imageProps.src).toEqual(btn.iconSrc);
|
||||||
expect(converted.iconProps.imageProps.alt).toEqual(btn.iconAlt);
|
expect(converted.iconProps.imageProps.alt).toEqual(btn.iconAlt);
|
||||||
expect(converted.text).toEqual(btn.commandButtonLabel);
|
expect(converted.text).toEqual(btn.commandButtonLabel);
|
||||||
@@ -49,7 +50,7 @@ describe("CommandBarUtil tests", () => {
|
|||||||
const converteds = CommandBarUtil.convertButton([btn], "backgroundColor");
|
const converteds = CommandBarUtil.convertButton([btn], "backgroundColor");
|
||||||
expect(converteds.length).toBe(1);
|
expect(converteds.length).toBe(1);
|
||||||
const converted = converteds[0];
|
const converted = converteds[0];
|
||||||
expect(converted.split).toBe(true);
|
expect(converted.split);
|
||||||
expect(converted.subMenuProps.items.length).toBe(btn.children.length);
|
expect(converted.subMenuProps.items.length).toBe(btn.children.length);
|
||||||
for (let i = 0; i < converted.subMenuProps.items.length; i++) {
|
for (let i = 0; i < converted.subMenuProps.items.length; i++) {
|
||||||
expect(converted.subMenuProps.items[i].text).toEqual(btn.children[i].commandButtonLabel);
|
expect(converted.subMenuProps.items[i].text).toEqual(btn.children[i].commandButtonLabel);
|
||||||
@@ -63,6 +64,7 @@ describe("CommandBarUtil tests", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const converteds = CommandBarUtil.convertButton(btns, "backgroundColor");
|
const converteds = CommandBarUtil.convertButton(btns, "backgroundColor");
|
||||||
|
const keys = converteds.map((btn: ICommandBarItemProps) => btn.key);
|
||||||
const uniqueKeys = converteds
|
const uniqueKeys = converteds
|
||||||
.map((btn: ICommandBarItemProps) => btn.key)
|
.map((btn: ICommandBarItemProps) => btn.key)
|
||||||
.filter((value: string, index: number, self: string[]) => self.indexOf(value) === index);
|
.filter((value: string, index: number, self: string[]) => self.indexOf(value) === index);
|
||||||
@@ -73,7 +75,7 @@ describe("CommandBarUtil tests", () => {
|
|||||||
const btn = createButton();
|
const btn = createButton();
|
||||||
const backgroundColor = "backgroundColor";
|
const backgroundColor = "backgroundColor";
|
||||||
|
|
||||||
btn.commandButtonLabel = undefined;
|
btn.commandButtonLabel = null;
|
||||||
let converted = CommandBarUtil.convertButton([btn], backgroundColor)[0];
|
let converted = CommandBarUtil.convertButton([btn], backgroundColor)[0];
|
||||||
expect(converted.text).toEqual(btn.tooltipText);
|
expect(converted.text).toEqual(btn.tooltipText);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class ControlBarComponent extends React.Component<ControlBarComponentProp
|
|||||||
return commandButtonOptions.map(
|
return commandButtonOptions.map(
|
||||||
(btn: CommandButtonComponentProps, index: number): JSX.Element => {
|
(btn: CommandButtonComponentProps, index: number): JSX.Element => {
|
||||||
// Remove label
|
// Remove label
|
||||||
btn.commandButtonLabel = undefined;
|
btn.commandButtonLabel = null;
|
||||||
return CommandButtonComponent.renderButton(btn, `${index}`);
|
return CommandButtonComponent.renderButton(btn, `${index}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
import { observable } from "knockout";
|
|
||||||
import { mostRecentActivity } from "./MostRecentActivity";
|
|
||||||
|
|
||||||
describe("MostRecentActivity", () => {
|
|
||||||
const accountId = "some account";
|
|
||||||
|
|
||||||
beforeEach(() => mostRecentActivity.clear(accountId));
|
|
||||||
|
|
||||||
it("Has no items at first", () => {
|
|
||||||
expect(mostRecentActivity.getItems(accountId)).toStrictEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Can record collections being opened", () => {
|
|
||||||
const collectionId = "some collection";
|
|
||||||
const databaseId = "some database";
|
|
||||||
const collection = {
|
|
||||||
id: observable(collectionId),
|
|
||||||
databaseId,
|
|
||||||
};
|
|
||||||
|
|
||||||
mostRecentActivity.collectionWasOpened(accountId, collection);
|
|
||||||
|
|
||||||
const activity = mostRecentActivity.getItems(accountId);
|
|
||||||
expect(activity).toEqual([
|
|
||||||
expect.objectContaining({
|
|
||||||
collectionId,
|
|
||||||
databaseId,
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Can record notebooks being opened", () => {
|
|
||||||
const name = "some notebook";
|
|
||||||
const path = "some path";
|
|
||||||
const notebook = { name, path };
|
|
||||||
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, notebook);
|
|
||||||
|
|
||||||
const activity = mostRecentActivity.getItems(accountId);
|
|
||||||
expect(activity).toEqual([expect.objectContaining(notebook)]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Filters out duplicates", () => {
|
|
||||||
const name = "some notebook";
|
|
||||||
const path = "some path";
|
|
||||||
const notebook = { name, path };
|
|
||||||
const sameNotebook = { name, path };
|
|
||||||
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, notebook);
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, sameNotebook);
|
|
||||||
|
|
||||||
const activity = mostRecentActivity.getItems(accountId);
|
|
||||||
expect(activity.length).toEqual(1);
|
|
||||||
expect(activity).toEqual([expect.objectContaining(notebook)]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Allows for multiple accounts", () => {
|
|
||||||
const name = "some notebook";
|
|
||||||
const path = "some path";
|
|
||||||
const notebook = { name, path };
|
|
||||||
|
|
||||||
const anotherNotebook = { name: "Another " + name, path };
|
|
||||||
const anotherAccountId = "Another " + accountId;
|
|
||||||
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, notebook);
|
|
||||||
mostRecentActivity.notebookWasItemOpened(anotherAccountId, anotherNotebook);
|
|
||||||
|
|
||||||
expect(mostRecentActivity.getItems(accountId)).toEqual([expect.objectContaining(notebook)]);
|
|
||||||
expect(mostRecentActivity.getItems(anotherAccountId)).toEqual([expect.objectContaining(anotherNotebook)]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Can store multiple distinct elements, in FIFO order", () => {
|
|
||||||
const name = "some notebook";
|
|
||||||
const path = "some path";
|
|
||||||
const first = { name, path };
|
|
||||||
const second = { name: "Another " + name, path };
|
|
||||||
const third = { name, path: "Another " + path };
|
|
||||||
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, first);
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, second);
|
|
||||||
mostRecentActivity.notebookWasItemOpened(accountId, third);
|
|
||||||
|
|
||||||
const activity = mostRecentActivity.getItems(accountId);
|
|
||||||
expect(activity).toEqual([third, second, first].map(expect.objectContaining));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { StorageKey, LocalStorageUtility } from "../../Shared/StorageUtility";
|
import { StorageKey, LocalStorageUtility } from "../../Shared/StorageUtility";
|
||||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
|
||||||
|
|
||||||
export enum Type {
|
export enum Type {
|
||||||
OpenCollection,
|
OpenCollection,
|
||||||
@@ -8,18 +6,21 @@ export enum Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenNotebookItem {
|
export interface OpenNotebookItem {
|
||||||
type: Type.OpenNotebook;
|
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenCollectionItem {
|
export interface OpenCollectionItem {
|
||||||
type: Type.OpenCollection;
|
|
||||||
databaseId: string;
|
databaseId: string;
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Item = OpenNotebookItem | OpenCollectionItem;
|
export interface Item {
|
||||||
|
type: Type;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
data: OpenNotebookItem | OpenCollectionItem;
|
||||||
|
}
|
||||||
|
|
||||||
// Update schemaVersion if you are going to change this interface
|
// Update schemaVersion if you are going to change this interface
|
||||||
interface StoredData {
|
interface StoredData {
|
||||||
@@ -31,7 +32,7 @@ interface StoredData {
|
|||||||
* Stores most recent activity
|
* Stores most recent activity
|
||||||
*/
|
*/
|
||||||
class MostRecentActivity {
|
class MostRecentActivity {
|
||||||
private static readonly schemaVersion: string = "2";
|
private static readonly schemaVersion: string = "1";
|
||||||
private static itemsMaxNumber: number = 5;
|
private static itemsMaxNumber: number = 5;
|
||||||
private storedData: StoredData;
|
private storedData: StoredData;
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -91,7 +92,7 @@ class MostRecentActivity {
|
|||||||
LocalStorageUtility.setEntryString(StorageKey.MostRecentActivity, JSON.stringify(this.storedData));
|
LocalStorageUtility.setEntryString(StorageKey.MostRecentActivity, JSON.stringify(this.storedData));
|
||||||
}
|
}
|
||||||
|
|
||||||
private addItem(accountId: string, newItem: Item): void {
|
public addItem(accountId: string, newItem: Item): void {
|
||||||
// When debugging, accountId is "undefined": most recent activity cannot be saved by account. Uncomment to disable.
|
// When debugging, accountId is "undefined": most recent activity cannot be saved by account. Uncomment to disable.
|
||||||
// if (!accountId) {
|
// if (!accountId) {
|
||||||
// return;
|
// return;
|
||||||
@@ -110,23 +111,6 @@ class MostRecentActivity {
|
|||||||
return this.storedData.itemsMap[accountId] || [];
|
return this.storedData.itemsMap[accountId] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public collectionWasOpened(accountId: string, { id, databaseId }: Pick<CollectionBase, "id" | "databaseId">) {
|
|
||||||
const collectionId = id();
|
|
||||||
this.addItem(accountId, {
|
|
||||||
type: Type.OpenCollection,
|
|
||||||
databaseId,
|
|
||||||
collectionId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public notebookWasItemOpened(accountId: string, { name, path }: Pick<NotebookContentItem, "name" | "path">) {
|
|
||||||
this.addItem(accountId, {
|
|
||||||
type: Type.OpenNotebook,
|
|
||||||
name,
|
|
||||||
path,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public clear(accountId: string): void {
|
public clear(accountId: string): void {
|
||||||
delete this.storedData.itemsMap[accountId];
|
delete this.storedData.itemsMap[accountId];
|
||||||
this.saveToLocalStorage();
|
this.saveToLocalStorage();
|
||||||
@@ -144,7 +128,11 @@ class MostRecentActivity {
|
|||||||
let index = -1;
|
let index = -1;
|
||||||
for (let i = 0; i < itemsArray.length; i++) {
|
for (let i = 0; i < itemsArray.length; i++) {
|
||||||
const currentItem = itemsArray[i];
|
const currentItem = itemsArray[i];
|
||||||
if (JSON.stringify(currentItem) === JSON.stringify(item)) {
|
if (
|
||||||
|
currentItem.title === item.title &&
|
||||||
|
currentItem.description === item.description &&
|
||||||
|
JSON.stringify(currentItem.data) === JSON.stringify(item.data)
|
||||||
|
) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,20 @@ import { NotebookContentRecordProps, selectors } from "@nteract/core";
|
|||||||
/**
|
/**
|
||||||
* A bunch of utilities to interact with nteract
|
* A bunch of utilities to interact with nteract
|
||||||
*/
|
*/
|
||||||
export function getCurrentCellType(content: NotebookContentRecordProps): "markdown" | "code" | "raw" | undefined {
|
export default class NTeractUtil {
|
||||||
if (!content) {
|
public static getCurrentCellType(content: NotebookContentRecordProps): "markdown" | "code" | "raw" | undefined {
|
||||||
|
if (!content) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cellFocusedId = selectors.notebook.cellFocused(content.model);
|
||||||
|
if (cellFocusedId) {
|
||||||
|
const cell = selectors.notebook.cellById(content.model, { id: cellFocusedId });
|
||||||
|
if (cell) {
|
||||||
|
return cell.cell_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cellFocusedId = selectors.notebook.cellFocused(content.model);
|
|
||||||
if (cellFocusedId) {
|
|
||||||
const cell = selectors.notebook.cellById(content.model, { id: cellFocusedId });
|
|
||||||
if (cell) {
|
|
||||||
return cell.cell_type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as React from "react";
|
|||||||
|
|
||||||
import { NotebookComponent } from "./NotebookComponent";
|
import { NotebookComponent } from "./NotebookComponent";
|
||||||
import { NotebookClientV2 } from "../NotebookClientV2";
|
import { NotebookClientV2 } from "../NotebookClientV2";
|
||||||
import { NotebookUtil } from "../NotebookUtil";
|
import * as NotebookUtil from "../NotebookUtil";
|
||||||
|
|
||||||
// Vendor modules
|
// Vendor modules
|
||||||
import {
|
import {
|
||||||
@@ -29,7 +29,7 @@ import "@nteract/styles/global-variables.css";
|
|||||||
import "react-table/react-table.css";
|
import "react-table/react-table.css";
|
||||||
|
|
||||||
import * as CdbActions from "./actions";
|
import * as CdbActions from "./actions";
|
||||||
import * as NteractUtil from "../NTeractUtil";
|
import NteractUtil from "../NTeractUtil";
|
||||||
|
|
||||||
export interface NotebookComponentBootstrapperOptions {
|
export interface NotebookComponentBootstrapperOptions {
|
||||||
notebookClient: NotebookClientV2;
|
notebookClient: NotebookClientV2;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { AppState, ContentRef, selectors } from "@nteract/core";
|
import { AppState, ContentRef, selectors } from "@nteract/core";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import * as NteractUtil from "../NTeractUtil";
|
import NteractUtil from "../NTeractUtil";
|
||||||
|
|
||||||
interface VirtualCommandBarComponentProps {
|
interface VirtualCommandBarComponentProps {
|
||||||
kernelSpecName: string;
|
kernelSpecName: string;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import * as sinon from "sinon";
|
|||||||
|
|
||||||
import { CdbAppState, makeCdbRecord } from "./types";
|
import { CdbAppState, makeCdbRecord } from "./types";
|
||||||
import { launchWebSocketKernelEpic } from "./epics";
|
import { launchWebSocketKernelEpic } from "./epics";
|
||||||
import { NotebookUtil } from "../NotebookUtil";
|
import * as NotebookUtil from "../NotebookUtil";
|
||||||
|
|
||||||
import { sessions } from "rx-jupyter";
|
import { sessions } from "rx-jupyter";
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import { Action as TelemetryAction, ActionModifiers } from "../../../Shared/Tele
|
|||||||
import { CdbAppState } from "./types";
|
import { CdbAppState } from "./types";
|
||||||
import { decryptJWTToken } from "../../../Utils/AuthorizationUtils";
|
import { decryptJWTToken } from "../../../Utils/AuthorizationUtils";
|
||||||
import * as TextFile from "./contents/file/text-file";
|
import * as TextFile from "./contents/file/text-file";
|
||||||
import { NotebookUtil } from "../NotebookUtil";
|
import * as NotebookUtil from "../NotebookUtil";
|
||||||
import { FileSystemUtil } from "../FileSystemUtil";
|
import { FileSystemUtil } from "../FileSystemUtil";
|
||||||
import * as cdbActions from "../NotebookComponent/actions";
|
import * as cdbActions from "../NotebookComponent/actions";
|
||||||
import { Areas } from "../../../Common/Constants";
|
import { Areas } from "../../../Common/Constants";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as DataModels from "../../Contracts/DataModels";
|
|||||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||||
import * as StringUtils from "../../Utils/StringUtils";
|
import * as StringUtils from "../../Utils/StringUtils";
|
||||||
import { FileSystemUtil } from "./FileSystemUtil";
|
import { FileSystemUtil } from "./FileSystemUtil";
|
||||||
import { NotebookUtil } from "./NotebookUtil";
|
import * as NotebookUtil from "./NotebookUtil";
|
||||||
|
|
||||||
import { ServerConfig, IContent, IContentProvider, FileType, IEmptyContent } from "@nteract/core";
|
import { ServerConfig, IContent, IContentProvider, FileType, IEmptyContent } from "@nteract/core";
|
||||||
import { AjaxResponse } from "rxjs/ajax";
|
import { AjaxResponse } from "rxjs/ajax";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { NotebookUtil } from "./NotebookUtil";
|
import * as NotebookUtil from "./NotebookUtil";
|
||||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||||
import {
|
import {
|
||||||
ImmutableNotebook,
|
ImmutableNotebook,
|
||||||
|
|||||||
@@ -7,157 +7,155 @@ import * as GitHubUtils from "../../Utils/GitHubUtils";
|
|||||||
// Must match rx-jupyter' FileType
|
// Must match rx-jupyter' FileType
|
||||||
export type FileType = "directory" | "file" | "notebook";
|
export type FileType = "directory" | "file" | "notebook";
|
||||||
// Utilities for notebooks
|
// Utilities for notebooks
|
||||||
export class NotebookUtil {
|
/**
|
||||||
/**
|
* It's a notebook file if the filename ends with .ipynb.
|
||||||
* It's a notebook file if the filename ends with .ipynb.
|
*/
|
||||||
*/
|
export function isNotebookFile(notebookPath: string): boolean {
|
||||||
public static isNotebookFile(notebookPath: string): boolean {
|
const fileName = getName(notebookPath);
|
||||||
const fileName = NotebookUtil.getName(notebookPath);
|
return !!fileName && StringUtils.endsWith(fileName, ".ipynb");
|
||||||
return !!fileName && StringUtils.endsWith(fileName, ".ipynb");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: this does not connect the item to a parent in a tree.
|
* Note: this does not connect the item to a parent in a tree.
|
||||||
* @param name
|
* @param name
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
public static createNotebookContentItem(name: string, path: string, type: FileType): NotebookContentItem {
|
export function createNotebookContentItem(name: string, path: string, type: FileType): NotebookContentItem {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
type: NotebookUtil.getType(type),
|
type: getType(type),
|
||||||
timestamp: NotebookUtil.getCurrentTimestamp(),
|
timestamp: getCurrentTimestamp(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert rx-jupyter type to our type
|
* Convert rx-jupyter type to our type
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public static getType(type: FileType): NotebookContentItemType {
|
export function getType(type: FileType): NotebookContentItemType {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "directory":
|
case "directory":
|
||||||
return NotebookContentItemType.Directory;
|
return NotebookContentItemType.Directory;
|
||||||
case "notebook":
|
case "notebook":
|
||||||
return NotebookContentItemType.Notebook;
|
return NotebookContentItemType.Notebook;
|
||||||
case "file":
|
case "file":
|
||||||
return NotebookContentItemType.File;
|
return NotebookContentItemType.File;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown file type: ${type}`);
|
throw new Error(`Unknown file type: ${type}`);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getCurrentTimestamp(): number {
|
|
||||||
return new Date().getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override from kernel-lifecycle.ts to improve kernel selection:
|
|
||||||
* Only return the kernel name persisted in the notebook
|
|
||||||
*
|
|
||||||
* @param filepath
|
|
||||||
* @param notebook
|
|
||||||
*/
|
|
||||||
public static extractNewKernel(filepath: string | null, notebook: ImmutableNotebook) {
|
|
||||||
const cwd = (filepath && path.dirname(filepath)) || "/";
|
|
||||||
|
|
||||||
const kernelSpecName =
|
|
||||||
notebook.getIn(["metadata", "kernelspec", "name"]) || notebook.getIn(["metadata", "language_info", "name"]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
cwd,
|
|
||||||
kernelSpecName,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getFilePath(path: string, fileName: string): string {
|
|
||||||
const contentInfo = GitHubUtils.fromContentUri(path);
|
|
||||||
if (contentInfo) {
|
|
||||||
let path = fileName;
|
|
||||||
if (contentInfo.path) {
|
|
||||||
path = `${contentInfo.path}/${path}`;
|
|
||||||
}
|
|
||||||
return GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${path}/${fileName}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getParentPath(filepath: string): undefined | string {
|
|
||||||
const basename = NotebookUtil.getName(filepath);
|
|
||||||
if (basename) {
|
|
||||||
const contentInfo = GitHubUtils.fromContentUri(filepath);
|
|
||||||
if (contentInfo) {
|
|
||||||
const parentPath = contentInfo.path.split(basename).shift();
|
|
||||||
if (parentPath === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GitHubUtils.toContentUri(
|
|
||||||
contentInfo.owner,
|
|
||||||
contentInfo.repo,
|
|
||||||
contentInfo.branch,
|
|
||||||
parentPath.replace(/\/$/, "") // no trailling slash
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const parentPath = filepath.split(basename).shift();
|
|
||||||
if (parentPath) {
|
|
||||||
return parentPath.replace(/\/$/, ""); // no trailling slash
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getName(path: string): undefined | string {
|
|
||||||
let relativePath: string = path;
|
|
||||||
const contentInfo = GitHubUtils.fromContentUri(path);
|
|
||||||
if (contentInfo) {
|
|
||||||
relativePath = contentInfo.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return relativePath.split("/").pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static replaceName(path: string, newName: string): string {
|
|
||||||
const contentInfo = GitHubUtils.fromContentUri(path);
|
|
||||||
if (contentInfo) {
|
|
||||||
const contentName = contentInfo.path.split("/").pop();
|
|
||||||
if (!contentName) {
|
|
||||||
throw new Error(`Failed to extract name from github path ${contentInfo.path}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const basePath = contentInfo.path.split(contentName).shift();
|
|
||||||
return GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, `${basePath}${newName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const contentName = path.split("/").pop();
|
|
||||||
if (!contentName) {
|
|
||||||
throw new Error(`Failed to extract name from path ${path}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const basePath = path.split(contentName).shift();
|
|
||||||
return `${basePath}${newName}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static findFirstCodeCellWithDisplay(notebookObject: ImmutableNotebook): number {
|
|
||||||
let codeCellIndex = 0;
|
|
||||||
for (let i = 0; i < notebookObject.cellOrder.size; i++) {
|
|
||||||
const cellId = notebookObject.cellOrder.get(i);
|
|
||||||
if (cellId) {
|
|
||||||
const cell = notebookObject.cellMap.get(cellId);
|
|
||||||
if (cell?.cell_type === "code") {
|
|
||||||
const displayOutput = (cell as ImmutableCodeCell)?.outputs?.find(
|
|
||||||
(output) => output.output_type === "display_data" || output.output_type === "execute_result"
|
|
||||||
);
|
|
||||||
if (displayOutput) {
|
|
||||||
return codeCellIndex;
|
|
||||||
}
|
|
||||||
codeCellIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error("Output does not exist for any of the cells.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCurrentTimestamp(): number {
|
||||||
|
return new Date().getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override from kernel-lifecycle.ts to improve kernel selection:
|
||||||
|
* Only return the kernel name persisted in the notebook
|
||||||
|
*
|
||||||
|
* @param filepath
|
||||||
|
* @param notebook
|
||||||
|
*/
|
||||||
|
export function extractNewKernel(filepath: string | null, notebook: ImmutableNotebook) {
|
||||||
|
const cwd = (filepath && path.dirname(filepath)) || "/";
|
||||||
|
|
||||||
|
const kernelSpecName =
|
||||||
|
notebook.getIn(["metadata", "kernelspec", "name"]) || notebook.getIn(["metadata", "language_info", "name"]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
cwd,
|
||||||
|
kernelSpecName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFilePath(path: string, fileName: string): string {
|
||||||
|
const contentInfo = GitHubUtils.fromContentUri(path);
|
||||||
|
if (contentInfo) {
|
||||||
|
let path = fileName;
|
||||||
|
if (contentInfo.path) {
|
||||||
|
path = `${contentInfo.path}/${path}`;
|
||||||
|
}
|
||||||
|
return GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${path}/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getParentPath(filepath: string): undefined | string {
|
||||||
|
const basename = getName(filepath);
|
||||||
|
if (basename) {
|
||||||
|
const contentInfo = GitHubUtils.fromContentUri(filepath);
|
||||||
|
if (contentInfo) {
|
||||||
|
const parentPath = contentInfo.path.split(basename).shift();
|
||||||
|
if (parentPath === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GitHubUtils.toContentUri(
|
||||||
|
contentInfo.owner,
|
||||||
|
contentInfo.repo,
|
||||||
|
contentInfo.branch,
|
||||||
|
parentPath.replace(/\/$/, "") // no trailling slash
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parentPath = filepath.split(basename).shift();
|
||||||
|
if (parentPath) {
|
||||||
|
return parentPath.replace(/\/$/, ""); // no trailling slash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getName(path: string): undefined | string {
|
||||||
|
let relativePath: string = path;
|
||||||
|
const contentInfo = GitHubUtils.fromContentUri(path);
|
||||||
|
if (contentInfo) {
|
||||||
|
relativePath = contentInfo.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return relativePath.split("/").pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function replaceName(path: string, newName: string): string {
|
||||||
|
const contentInfo = GitHubUtils.fromContentUri(path);
|
||||||
|
if (contentInfo) {
|
||||||
|
const contentName = contentInfo.path.split("/").pop();
|
||||||
|
if (!contentName) {
|
||||||
|
throw new Error(`Failed to extract name from github path ${contentInfo.path}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const basePath = contentInfo.path.split(contentName).shift();
|
||||||
|
return GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, `${basePath}${newName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentName = path.split("/").pop();
|
||||||
|
if (!contentName) {
|
||||||
|
throw new Error(`Failed to extract name from path ${path}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const basePath = path.split(contentName).shift();
|
||||||
|
return `${basePath}${newName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findFirstCodeCellWithDisplay(notebookObject: ImmutableNotebook): number {
|
||||||
|
let codeCellIndex = 0;
|
||||||
|
for (let i = 0; i < notebookObject.cellOrder.size; i++) {
|
||||||
|
const cellId = notebookObject.cellOrder.get(i);
|
||||||
|
if (cellId) {
|
||||||
|
const cell = notebookObject.cellMap.get(cellId);
|
||||||
|
if (cell?.cell_type === "code") {
|
||||||
|
const displayOutput = (cell as ImmutableCodeCell)?.outputs?.find(
|
||||||
|
(output) => output.output_type === "display_data" || output.output_type === "execute_result"
|
||||||
|
);
|
||||||
|
if (displayOutput) {
|
||||||
|
return codeCellIndex;
|
||||||
|
}
|
||||||
|
codeCellIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Output does not exist for any of the cells.");
|
||||||
|
}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@
|
|||||||
maxAutoPilotThroughputSet: sharedAutoPilotThroughput,
|
maxAutoPilotThroughputSet: sharedAutoPilotThroughput,
|
||||||
autoPilotUsageCost: autoPilotUsageCost,
|
autoPilotUsageCost: autoPilotUsageCost,
|
||||||
canExceedMaximumValue: canExceedMaximumValue,
|
canExceedMaximumValue: canExceedMaximumValue,
|
||||||
|
showAutoPilot: !isFreeTierAccount(),
|
||||||
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
@@ -434,6 +435,7 @@
|
|||||||
maxAutoPilotThroughputSet: autoPilotThroughput,
|
maxAutoPilotThroughputSet: autoPilotThroughput,
|
||||||
autoPilotUsageCost: autoPilotUsageCost,
|
autoPilotUsageCost: autoPilotUsageCost,
|
||||||
canExceedMaximumValue: canExceedMaximumValue,
|
canExceedMaximumValue: canExceedMaximumValue,
|
||||||
|
showAutoPilot: !isFixedStorageSelected(),
|
||||||
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -749,16 +749,12 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return undefined if autopilot is selected for the new database/collection
|
if (this.isAutoPilotSelected()) {
|
||||||
if (this.databaseCreateNew()) {
|
return undefined;
|
||||||
// database is shared and autopilot is sleected for the database
|
}
|
||||||
if (this.databaseCreateNewShared() && this.isSharedAutoPilotSelected()) {
|
|
||||||
return undefined;
|
if (this.databaseCreateNewShared() && this.isSharedAutoPilotSelected()) {
|
||||||
}
|
return undefined;
|
||||||
// database is not shared and autopilot is selected for the collection
|
|
||||||
if (!this.databaseCreateNewShared() && this.isAutoPilotSelected()) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._getThroughput();
|
return this._getThroughput();
|
||||||
|
|||||||
@@ -149,6 +149,7 @@
|
|||||||
maxAutoPilotThroughputSet: maxAutoPilotThroughputSet,
|
maxAutoPilotThroughputSet: maxAutoPilotThroughputSet,
|
||||||
autoPilotUsageCost: autoPilotUsageCost,
|
autoPilotUsageCost: autoPilotUsageCost,
|
||||||
canExceedMaximumValue: canExceedMaximumValue,
|
canExceedMaximumValue: canExceedMaximumValue,
|
||||||
|
showAutoPilot: !isFreeTierAccount(),
|
||||||
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
freeTierExceedThroughputTooltip: freeTierExceedThroughputTooltip
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -166,6 +166,7 @@
|
|||||||
autoPilotUsageCost: autoPilotUsageCost,
|
autoPilotUsageCost: autoPilotUsageCost,
|
||||||
canExceedMaximumValue: canExceedMaximumValue,
|
canExceedMaximumValue: canExceedMaximumValue,
|
||||||
costsVisible: costsVisible,
|
costsVisible: costsVisible,
|
||||||
|
showAutoPilot: !isFreeTierAccount()
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
</throughput-input-autopilot-v3>
|
</throughput-input-autopilot-v3>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { FileSystemUtil } from "../Notebook/FileSystemUtil";
|
|||||||
import "./PublishNotebookPaneComponent.less";
|
import "./PublishNotebookPaneComponent.less";
|
||||||
import Html2Canvas from "html2canvas";
|
import Html2Canvas from "html2canvas";
|
||||||
import { ImmutableNotebook } from "@nteract/commutable/src";
|
import { ImmutableNotebook } from "@nteract/commutable/src";
|
||||||
import { NotebookUtil } from "../Notebook/NotebookUtil";
|
import * as NotebookUtil from "../Notebook/NotebookUtil";
|
||||||
|
|
||||||
export interface PublishNotebookPaneProps {
|
export interface PublishNotebookPaneProps {
|
||||||
notebookName: string;
|
notebookName: string;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsol
|
|||||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
||||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||||
import * as StringUtility from "../../Shared/StringUtility";
|
import { StringUtility } from "../../Shared/StringUtility";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
|
|
||||||
export class SettingsPane extends ContextualPaneBase {
|
export class SettingsPane extends ContextualPaneBase {
|
||||||
|
|||||||
@@ -217,6 +217,42 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
return heroes;
|
return heroes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItemIcon(item: MostRecentActivity.Item): string {
|
||||||
|
switch (item.type) {
|
||||||
|
case MostRecentActivity.Type.OpenCollection:
|
||||||
|
return CollectionIcon;
|
||||||
|
case MostRecentActivity.Type.OpenNotebook:
|
||||||
|
return NotebookIcon;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onItemClicked(item: MostRecentActivity.Item) {
|
||||||
|
switch (item.type) {
|
||||||
|
case MostRecentActivity.Type.OpenCollection: {
|
||||||
|
const openCollectionitem = item.data as MostRecentActivity.OpenCollectionItem;
|
||||||
|
const collection = this.container.findCollection(
|
||||||
|
openCollectionitem.databaseId,
|
||||||
|
openCollectionitem.collectionId
|
||||||
|
);
|
||||||
|
if (collection) {
|
||||||
|
collection.openTab();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MostRecentActivity.Type.OpenNotebook: {
|
||||||
|
const openNotebookItem = item.data as MostRecentActivity.OpenNotebookItem;
|
||||||
|
const notebookItem = this.container.createNotebookContentItemFile(openNotebookItem.name, openNotebookItem.path);
|
||||||
|
notebookItem && this.container.openNotebook(notebookItem);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
console.error("Unknown item type", item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private createCommonTaskItems(): SplashScreenItem[] {
|
private createCommonTaskItems(): SplashScreenItem[] {
|
||||||
const items: SplashScreenItem[] = [];
|
const items: SplashScreenItem[] = [];
|
||||||
|
|
||||||
@@ -297,45 +333,23 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private decorateOpenCollectionActivity({ databaseId, collectionId }: MostRecentActivity.OpenCollectionItem) {
|
private static getInfo(item: MostRecentActivity.Item): string {
|
||||||
return {
|
if (item.type === MostRecentActivity.Type.OpenNotebook) {
|
||||||
iconSrc: NotebookIcon,
|
const data = item.data as MostRecentActivity.OpenNotebookItem;
|
||||||
title: collectionId,
|
return data.path;
|
||||||
description: "Data",
|
} else {
|
||||||
onClick: () => {
|
return undefined;
|
||||||
const collection = this.container.findCollection(databaseId, collectionId);
|
}
|
||||||
collection && collection.openTab();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private decorateOpenNotebookActivity({ name, path }: MostRecentActivity.OpenNotebookItem) {
|
|
||||||
return {
|
|
||||||
info: path,
|
|
||||||
iconSrc: CollectionIcon,
|
|
||||||
title: name,
|
|
||||||
description: "Notebook",
|
|
||||||
onClick: () => {
|
|
||||||
const notebookItem = this.container.createNotebookContentItemFile(name, path);
|
|
||||||
notebookItem && this.container.openNotebook(notebookItem);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private createRecentItems(): SplashScreenItem[] {
|
private createRecentItems(): SplashScreenItem[] {
|
||||||
return MostRecentActivity.mostRecentActivity.getItems(userContext.databaseAccount?.id).map((activity) => {
|
return MostRecentActivity.mostRecentActivity.getItems(userContext.databaseAccount?.id).map((item) => ({
|
||||||
switch (activity.type) {
|
iconSrc: this.getItemIcon(item),
|
||||||
default: {
|
title: item.title,
|
||||||
const unknownActivity: never = activity;
|
description: item.description,
|
||||||
throw new Error(`Unknown activity: ${unknownActivity}`);
|
info: SplashScreen.getInfo(item),
|
||||||
}
|
onClick: () => this.onItemClicked(item),
|
||||||
case MostRecentActivity.Type.OpenNotebook:
|
}));
|
||||||
return this.decorateOpenNotebookActivity(activity);
|
|
||||||
|
|
||||||
case MostRecentActivity.Type.OpenCollection:
|
|
||||||
return this.decorateOpenCollectionActivity(activity);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private createTipsItems(): SplashScreenItem[] {
|
private createTipsItems(): SplashScreenItem[] {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
throughputAutoPilotRadioId: throughputAutoPilotRadioId,
|
throughputAutoPilotRadioId: throughputAutoPilotRadioId,
|
||||||
throughputProvisionedRadioId: throughputProvisionedRadioId,
|
throughputProvisionedRadioId: throughputProvisionedRadioId,
|
||||||
throughputModeRadioName: throughputModeRadioName,
|
throughputModeRadioName: throughputModeRadioName,
|
||||||
|
showAutoPilot: userCanChangeProvisioningTypes,
|
||||||
isAutoPilotSelected: isAutoPilotSelected,
|
isAutoPilotSelected: isAutoPilotSelected,
|
||||||
maxAutoPilotThroughputSet: autoPilotThroughput,
|
maxAutoPilotThroughputSet: autoPilotThroughput,
|
||||||
autoPilotUsageCost: autoPilotUsageCost,
|
autoPilotUsageCost: autoPilotUsageCost,
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import * as ko from "knockout";
|
|
||||||
import Q from "q";
|
|
||||||
import DiscardIcon from "../../../images/discard.svg";
|
|
||||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
|
||||||
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
|
||||||
import editable from "../../Common/EditableUtility";
|
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
|
||||||
import { configContext, Platform } from "../../ConfigContext";
|
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
|
||||||
import * as SharedConstants from "../../Shared/Constants";
|
|
||||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
|
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
|
||||||
|
import * as Constants from "../../Common/Constants";
|
||||||
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
|
import * as ko from "knockout";
|
||||||
import * as PricingUtils from "../../Utils/PricingUtils";
|
import * as PricingUtils from "../../Utils/PricingUtils";
|
||||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
import * as SharedConstants from "../../Shared/Constants";
|
||||||
import Explorer from "../Explorer";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
|
import DiscardIcon from "../../../images/discard.svg";
|
||||||
|
import editable from "../../Common/EditableUtility";
|
||||||
|
import Q from "q";
|
||||||
|
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
|
import Explorer from "../Explorer";
|
||||||
|
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
||||||
|
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import { configContext, Platform } from "../../ConfigContext";
|
||||||
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
|
|
||||||
const updateThroughputBeyondLimitWarningMessage: string = `
|
const updateThroughputBeyondLimitWarningMessage: string = `
|
||||||
You are about to request an increase in throughput beyond the pre-allocated capacity.
|
You are about to request an increase in throughput beyond the pre-allocated capacity.
|
||||||
@@ -73,6 +73,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
public shouldShowStatusBar: ko.Computed<boolean>;
|
public shouldShowStatusBar: ko.Computed<boolean>;
|
||||||
public throughputTitle: ko.PureComputed<string>;
|
public throughputTitle: ko.PureComputed<string>;
|
||||||
public throughputAriaLabel: ko.PureComputed<string>;
|
public throughputAriaLabel: ko.PureComputed<string>;
|
||||||
|
public userCanChangeProvisioningTypes: ko.Observable<boolean>;
|
||||||
public autoPilotUsageCost: ko.PureComputed<string>;
|
public autoPilotUsageCost: ko.PureComputed<string>;
|
||||||
public warningMessage: ko.Computed<string>;
|
public warningMessage: ko.Computed<string>;
|
||||||
public canExceedMaximumValue: ko.PureComputed<boolean>;
|
public canExceedMaximumValue: ko.PureComputed<boolean>;
|
||||||
@@ -105,6 +106,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
this._wasAutopilotOriginallySet = ko.observable(false);
|
this._wasAutopilotOriginallySet = ko.observable(false);
|
||||||
this.isAutoPilotSelected = editable.observable(false);
|
this.isAutoPilotSelected = editable.observable(false);
|
||||||
this.autoPilotThroughput = editable.observable<number>();
|
this.autoPilotThroughput = editable.observable<number>();
|
||||||
|
this.userCanChangeProvisioningTypes = ko.observable(true);
|
||||||
|
|
||||||
const autoscaleMaxThroughput = this.database?.offer()?.autoscaleMaxThroughput;
|
const autoscaleMaxThroughput = this.database?.offer()?.autoscaleMaxThroughput;
|
||||||
if (autoscaleMaxThroughput) {
|
if (autoscaleMaxThroughput) {
|
||||||
@@ -116,6 +118,9 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._hasProvisioningTypeChanged = ko.pureComputed<boolean>(() => {
|
this._hasProvisioningTypeChanged = ko.pureComputed<boolean>(() => {
|
||||||
|
if (!this.userCanChangeProvisioningTypes()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this._wasAutopilotOriginallySet() !== this.isAutoPilotSelected()) {
|
if (this._wasAutopilotOriginallySet() !== this.isAutoPilotSelected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -131,7 +136,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.requestUnitsUsageCost = ko.pureComputed(() => {
|
this.requestUnitsUsageCost = ko.pureComputed(() => {
|
||||||
const account = userContext.databaseAccount;
|
const account = this.container.databaseAccount();
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -357,7 +362,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
this.isTemplateReady = ko.observable<boolean>(false);
|
this.isTemplateReady = ko.observable<boolean>(false);
|
||||||
|
|
||||||
this.isFreeTierAccount = ko.computed<boolean>(() => {
|
this.isFreeTierAccount = ko.computed<boolean>(() => {
|
||||||
const databaseAccount = userContext.databaseAccount;
|
const databaseAccount = this.container?.databaseAccount();
|
||||||
return databaseAccount?.properties?.enableFreeTier;
|
return databaseAccount?.properties?.enableFreeTier;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -443,6 +448,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
this.isAutoPilotSelected.setBaseline(AutoPilotUtils.isValidAutoPilotThroughput(offer.autoscaleMaxThroughput));
|
this.isAutoPilotSelected.setBaseline(AutoPilotUtils.isValidAutoPilotThroughput(offer.autoscaleMaxThroughput));
|
||||||
this.autoPilotThroughput.setBaseline(offer.autoscaleMaxThroughput);
|
this.autoPilotThroughput.setBaseline(offer.autoscaleMaxThroughput);
|
||||||
this.throughput.setBaseline(offer.manualThroughput);
|
this.throughput.setBaseline(offer.manualThroughput);
|
||||||
|
this.userCanChangeProvisioningTypes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getTabsButtons(): CommandButtonComponentProps[] {
|
protected getTabsButtons(): CommandButtonComponentProps[] {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBa
|
|||||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||||
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
|
import { NotebookConfigurationUtils } from "../../Utils/NotebookConfigurationUtils";
|
||||||
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { TreeComponent, TreeNode, TreeNodeMenuItem, TreeNodeComponent } from "..
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "../Notebook/NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "../Notebook/NotebookContentItem";
|
||||||
import { ResourceTreeContextMenuButtonFactory } from "../ContextMenuButtonFactory";
|
import { ResourceTreeContextMenuButtonFactory } from "../ContextMenuButtonFactory";
|
||||||
import { mostRecentActivity } from "../MostRecentActivity/MostRecentActivity";
|
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
||||||
import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
|
import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
|
||||||
import CosmosDBIcon from "../../../images/Azure-Cosmos-DB.svg";
|
import CosmosDBIcon from "../../../images/Azure-Cosmos-DB.svg";
|
||||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||||
@@ -17,7 +17,7 @@ import NewNotebookIcon from "../../../images/notebook/Notebook-new.svg";
|
|||||||
import FileIcon from "../../../images/notebook/file-cosmos.svg";
|
import FileIcon from "../../../images/notebook/file-cosmos.svg";
|
||||||
import PublishIcon from "../../../images/notebook/publish_content.svg";
|
import PublishIcon from "../../../images/notebook/publish_content.svg";
|
||||||
import { ArrayHashMap } from "../../Common/ArrayHashMap";
|
import { ArrayHashMap } from "../../Common/ArrayHashMap";
|
||||||
import { NotebookUtil } from "../Notebook/NotebookUtil";
|
import * as NotebookUtil from "../Notebook/NotebookUtil";
|
||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
import { IPinnedRepo } from "../../Juno/JunoClient";
|
import { IPinnedRepo } from "../../Juno/JunoClient";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
@@ -264,7 +264,15 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
collection.openTab();
|
collection.openTab();
|
||||||
// push to most recent
|
// push to most recent
|
||||||
mostRecentActivity.collectionWasOpened(userContext.databaseAccount?.id, collection);
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
|
type: MostRecentActivity.Type.OpenCollection,
|
||||||
|
title: collection.id(),
|
||||||
|
description: "Data",
|
||||||
|
data: {
|
||||||
|
databaseId: collection.databaseId,
|
||||||
|
collectionId: collection.id(),
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
isSelected: () =>
|
isSelected: () =>
|
||||||
this.isDataNodeSelected(collection.databaseId, collection.id(), [
|
this.isDataNodeSelected(collection.databaseId, collection.id(), [
|
||||||
@@ -565,7 +573,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
(item: NotebookContentItem) => {
|
(item: NotebookContentItem) => {
|
||||||
this.container.openNotebook(item).then((hasOpened) => {
|
this.container.openNotebook(item).then((hasOpened) => {
|
||||||
if (hasOpened) {
|
if (hasOpened) {
|
||||||
mostRecentActivity.notebookWasItemOpened(userContext.databaseAccount?.id, item);
|
this.pushItemToMostRecent(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -586,7 +594,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
(item: NotebookContentItem) => {
|
(item: NotebookContentItem) => {
|
||||||
this.container.openNotebook(item).then((hasOpened) => {
|
this.container.openNotebook(item).then((hasOpened) => {
|
||||||
if (hasOpened) {
|
if (hasOpened) {
|
||||||
mostRecentActivity.notebookWasItemOpened(userContext.databaseAccount?.id, item);
|
this.pushItemToMostRecent(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -616,6 +624,18 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
return gitHubNotebooksTree;
|
return gitHubNotebooksTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private pushItemToMostRecent(item: NotebookContentItem) {
|
||||||
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
|
type: MostRecentActivity.Type.OpenNotebook,
|
||||||
|
title: item.name,
|
||||||
|
description: "Notebook",
|
||||||
|
data: {
|
||||||
|
name: item.name,
|
||||||
|
path: item.path,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private buildChildNodes(
|
private buildChildNodes(
|
||||||
item: NotebookContentItem,
|
item: NotebookContentItem,
|
||||||
onFileClick: (item: NotebookContentItem) => void,
|
onFileClick: (item: NotebookContentItem) => void,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import { mostRecentActivity } from "../MostRecentActivity/MostRecentActivity";
|
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
||||||
@@ -44,7 +44,15 @@ export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
collection.onDocumentDBDocumentsClick();
|
collection.onDocumentDBDocumentsClick();
|
||||||
// push to most recent
|
// push to most recent
|
||||||
mostRecentActivity.collectionWasOpened(userContext.databaseAccount?.id, collection);
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
|
type: MostRecentActivity.Type.OpenCollection,
|
||||||
|
title: collection.id(),
|
||||||
|
description: "Data",
|
||||||
|
data: {
|
||||||
|
databaseId: collection.databaseId,
|
||||||
|
collectionId: collection.id(),
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
isSelected: () =>
|
isSelected: () =>
|
||||||
this.isDataNodeSelected(collection.databaseId, collection.id(), ViewModels.CollectionTabKind.Documents),
|
this.isDataNodeSelected(collection.databaseId, collection.id(), ViewModels.CollectionTabKind.Documents),
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const onInit = async () => {
|
|||||||
<header>
|
<header>
|
||||||
<GalleryHeaderComponent />
|
<GalleryHeaderComponent />
|
||||||
</header>
|
</header>
|
||||||
<div style={{ margin: "auto", width: "85%" }}>
|
<div style={{ marginLeft: 138, marginRight: 138 }}>
|
||||||
<div style={{ paddingLeft: 26, paddingRight: 26, paddingTop: 20 }}>
|
<div style={{ paddingLeft: 26, paddingRight: 26, paddingTop: 20 }}>
|
||||||
<Text block>
|
<Text block>
|
||||||
Welcome to the Azure Cosmos DB notebooks gallery! View the sample notebooks to learn about use cases, best
|
Welcome to the Azure Cosmos DB notebooks gallery! View the sample notebooks to learn about use cases, best
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Octokit } from "@octokit/rest";
|
|||||||
import { HttpStatusCodes } from "../Common/Constants";
|
import { HttpStatusCodes } from "../Common/Constants";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import UrlUtility from "../Common/UrlUtility";
|
import UrlUtility from "../Common/UrlUtility";
|
||||||
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
|
import * as NotebookUtil from "../Explorer/Notebook/NotebookUtil";
|
||||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||||
|
|
||||||
export interface IGitHubPageInfo {
|
export interface IGitHubPageInfo {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { AjaxResponse } from "rxjs/ajax";
|
|||||||
import * as Base64Utils from "../Utils/Base64Utils";
|
import * as Base64Utils from "../Utils/Base64Utils";
|
||||||
import { HttpStatusCodes } from "../Common/Constants";
|
import { HttpStatusCodes } from "../Common/Constants";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
|
import * as NotebookUtil from "../Explorer/Notebook/NotebookUtil";
|
||||||
import { GitHubClient, IGitHubFile, IGitHubResponse } from "./GitHubClient";
|
import { GitHubClient, IGitHubFile, IGitHubResponse } from "./GitHubClient";
|
||||||
import * as GitHubUtils from "../Utils/GitHubUtils";
|
import * as GitHubUtils from "../Utils/GitHubUtils";
|
||||||
import UrlUtility from "../Common/UrlUtility";
|
import UrlUtility from "../Common/UrlUtility";
|
||||||
|
|||||||
@@ -9,11 +9,9 @@
|
|||||||
"North Central US": "North Central US",
|
"North Central US": "North Central US",
|
||||||
"West US": "West US",
|
"West US": "West US",
|
||||||
"East US 2": "East US 2",
|
"East US 2": "East US 2",
|
||||||
"Current Region": "Current Region",
|
"ClassInfo": "This is a self serve class",
|
||||||
"RegionDropdownInfo": "More regions can be added in the future.",
|
"RegionDropdownInfo": "More regions can be added in the future.",
|
||||||
"RegionsAndAccountNameValidationError": "Regions and account name should not be empty.",
|
"ValidationError": "Regions and AccountName should not be empty.",
|
||||||
"DbThroughputValidationError": "Please update throughput for database.",
|
|
||||||
"DescriptionLabel": "Description",
|
|
||||||
"DescriptionText": "This class sets collection and database throughput.",
|
"DescriptionText": "This class sets collection and database throughput.",
|
||||||
"DecriptionLinkText": "Click here for more information",
|
"DecriptionLinkText": "Click here for more information",
|
||||||
"Regions": "Regions",
|
"Regions": "Regions",
|
||||||
@@ -24,17 +22,10 @@
|
|||||||
"Account Name": "Account Name",
|
"Account Name": "Account Name",
|
||||||
"AccountNamePlaceHolder": "Enter the account name",
|
"AccountNamePlaceHolder": "Enter the account name",
|
||||||
"Collection Throughput": "Collection Throughput",
|
"Collection Throughput": "Collection Throughput",
|
||||||
"Enable DB level throughput": "Enable Database Level Throughput",
|
"Enable DB level throughput": "Enable DB level throughput",
|
||||||
"Database Throughput": "Database Throughput",
|
"Database Throughput": "Database Throughput",
|
||||||
"UpdateInProgressMessage": "Data is being updated",
|
"RefreshMessage": "Self Serve Example successfully refreshing",
|
||||||
"UpdateCompletedMessageTitle":"Update succeeded",
|
"SubmissionMessage": "Submitted successfully"
|
||||||
"UpdateCompletedMessageText": "Data updation completed.",
|
|
||||||
"SubmissionMessageSuccessTitle": "Update started",
|
|
||||||
"SubmissionMessageForNewRegionText": "Data update started. Region changed.",
|
|
||||||
"SubmissionMessageForSameRegionText": "Data update started. Region not changed.",
|
|
||||||
"SubmissionMessageErrorTitle": "Data update failed",
|
|
||||||
"SubmissionMessageErrorText": "Data update failed because of errors.",
|
|
||||||
"OnSaveFailureMessage": "Data save operation not currently permitted."
|
|
||||||
},
|
},
|
||||||
"SqlX": {
|
"SqlX": {
|
||||||
}
|
}
|
||||||
|
|||||||
174
src/Main.tsx
174
src/Main.tsx
@@ -1,72 +1,74 @@
|
|||||||
// CSS Dependencies
|
// CSS Dependencies
|
||||||
import "abort-controller/polyfill";
|
|
||||||
import "babel-polyfill";
|
|
||||||
import "bootstrap/dist/css/bootstrap.css";
|
import "bootstrap/dist/css/bootstrap.css";
|
||||||
import "es6-object-assign/auto";
|
import "../less/documentDB.less";
|
||||||
import "es6-symbol/implement";
|
import "../less/tree.less";
|
||||||
import "object.entries/auto";
|
import "../less/forms.less";
|
||||||
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
import "../less/menus.less";
|
||||||
import "promise-polyfill/src/polyfill";
|
import "../less/infobox.less";
|
||||||
import "promise.prototype.finally/auto";
|
import "../less/messagebox.less";
|
||||||
import React, { useState } from "react";
|
import "./Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.less";
|
||||||
import ReactDOM from "react-dom";
|
import "./Explorer/Menus/NotificationConsole/NotificationConsole.less";
|
||||||
import "url-polyfill/url-polyfill.min";
|
import "./Explorer/Menus/CommandBar/CommandBarComponent.less";
|
||||||
import "webcrypto-liner/build/webcrypto-liner.shim.min";
|
import "./Explorer/Menus/CommandBar/MemoryTrackerComponent.less";
|
||||||
import "whatwg-fetch";
|
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
|
||||||
|
import "./Explorer/Controls/DynamicList/DynamicListComponent.less";
|
||||||
|
import "./Explorer/Controls/JsonEditor/JsonEditorComponent.less";
|
||||||
|
import "./Explorer/Graph/GraphExplorerComponent/graphExplorer.less";
|
||||||
|
import "./Explorer/Panes/PanelComponent.less";
|
||||||
|
import "../less/TableStyles/queryBuilder.less";
|
||||||
|
import "../externals/jquery.dataTables.min.css";
|
||||||
|
import "../less/TableStyles/fulldatatables.less";
|
||||||
|
import "../less/TableStyles/EntityEditor.less";
|
||||||
|
import "../less/TableStyles/CustomizeColumns.less";
|
||||||
|
import "../less/resourceTree.less";
|
||||||
|
import "../externals/jquery.typeahead.min.css";
|
||||||
import "../externals/jquery-ui.min.css";
|
import "../externals/jquery-ui.min.css";
|
||||||
import "../externals/jquery-ui.min.js";
|
|
||||||
import "../externals/jquery-ui.structure.min.css";
|
import "../externals/jquery-ui.structure.min.css";
|
||||||
import "../externals/jquery-ui.theme.min.css";
|
import "../externals/jquery-ui.theme.min.css";
|
||||||
import "../externals/jquery.dataTables.min.css";
|
import "./Explorer/Graph/NewVertexComponent/newVertexComponent.less";
|
||||||
import "../externals/jquery.typeahead.min.css";
|
import "./Explorer/Panes/GraphNewVertexPane.less";
|
||||||
import "../externals/jquery.typeahead.min.js";
|
import "./Explorer/Tabs/QueryTab.less";
|
||||||
|
import "./Explorer/Controls/TreeComponent/treeComponent.less";
|
||||||
|
import "./Explorer/Controls/Accordion/AccordionComponent.less";
|
||||||
|
import "./Explorer/SplashScreen/SplashScreen.less";
|
||||||
|
import "./Explorer/Controls/Notebook/NotebookTerminalComponent.less";
|
||||||
|
|
||||||
// Image Dependencies
|
// Image Dependencies
|
||||||
import "../images/CosmosDB_rgb_ui_lighttheme.ico";
|
import "../images/CosmosDB_rgb_ui_lighttheme.ico";
|
||||||
import "../images/favicon.ico";
|
import "../images/favicon.ico";
|
||||||
import hdeConnectImage from "../images/HdeConnectCosmosDB.svg";
|
|
||||||
import arrowLeftImg from "../images/imgarrowlefticon.svg";
|
import "./Shared/appInsights";
|
||||||
import refreshImg from "../images/refresh-cosmos.svg";
|
import "babel-polyfill";
|
||||||
import "../less/documentDB.less";
|
import "es6-symbol/implement";
|
||||||
import "../less/forms.less";
|
import "webcrypto-liner/build/webcrypto-liner.shim.min";
|
||||||
import "../less/infobox.less";
|
import "./Libs/jquery";
|
||||||
import "../less/menus.less";
|
import "bootstrap/dist/js/npm";
|
||||||
import "../less/messagebox.less";
|
import "../externals/jquery.typeahead.min.js";
|
||||||
import "../less/resourceTree.less";
|
import "../externals/jquery-ui.min.js";
|
||||||
import "../less/TableStyles/CustomizeColumns.less";
|
import "promise-polyfill/src/polyfill";
|
||||||
import "../less/TableStyles/EntityEditor.less";
|
import "abort-controller/polyfill";
|
||||||
import "../less/TableStyles/fulldatatables.less";
|
import "whatwg-fetch";
|
||||||
import "../less/TableStyles/queryBuilder.less";
|
import "es6-object-assign/auto";
|
||||||
import "../less/tree.less";
|
import "promise.prototype.finally/auto";
|
||||||
import "./Explorer/Controls/Accordion/AccordionComponent.less";
|
import "object.entries/auto";
|
||||||
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
|
import "./Libs/is-integer-polyfill";
|
||||||
import { Dialog, DialogProps } from "./Explorer/Controls/Dialog";
|
import "url-polyfill/url-polyfill.min";
|
||||||
import "./Explorer/Controls/DynamicList/DynamicListComponent.less";
|
|
||||||
import "./Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.less";
|
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
||||||
import "./Explorer/Controls/JsonEditor/JsonEditorComponent.less";
|
|
||||||
import "./Explorer/Controls/Notebook/NotebookTerminalComponent.less";
|
|
||||||
import "./Explorer/Controls/TreeComponent/treeComponent.less";
|
|
||||||
import { ExplorerParams } from "./Explorer/Explorer";
|
import { ExplorerParams } from "./Explorer/Explorer";
|
||||||
import "./Explorer/Graph/GraphExplorerComponent/graphExplorer.less";
|
import React, { useState } from "react";
|
||||||
import "./Explorer/Graph/NewVertexComponent/newVertexComponent.less";
|
import ReactDOM from "react-dom";
|
||||||
import { CommandBarComponent } from "./Explorer/Menus/CommandBar/CommandBarComponent";
|
import hdeConnectImage from "../images/HdeConnectCosmosDB.svg";
|
||||||
import "./Explorer/Menus/CommandBar/CommandBarComponent.less";
|
import refreshImg from "../images/refresh-cosmos.svg";
|
||||||
import "./Explorer/Menus/CommandBar/MemoryTrackerComponent.less";
|
import arrowLeftImg from "../images/imgarrowlefticon.svg";
|
||||||
import "./Explorer/Menus/NotificationConsole/NotificationConsole.less";
|
import { KOCommentEnd, KOCommentIfStart } from "./koComment";
|
||||||
import { NotificationConsoleComponent } from "./Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
|
||||||
import "./Explorer/Panes/GraphNewVertexPane.less";
|
|
||||||
import "./Explorer/Panes/PanelComponent.less";
|
|
||||||
import { PanelContainerComponent } from "./Explorer/Panes/PanelContainerComponent";
|
|
||||||
import { SplashScreen } from "./Explorer/SplashScreen/SplashScreen";
|
|
||||||
import "./Explorer/SplashScreen/SplashScreen.less";
|
|
||||||
import "./Explorer/Tabs/QueryTab.less";
|
|
||||||
import { useConfig } from "./hooks/useConfig";
|
import { useConfig } from "./hooks/useConfig";
|
||||||
import { useExplorerState } from "./hooks/useExplorerState";
|
|
||||||
import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
|
import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
|
||||||
import { useSidePanel } from "./hooks/useSidePanel";
|
import { useSidePanel } from "./hooks/useSidePanel";
|
||||||
import { KOCommentEnd, KOCommentIfStart } from "./koComment";
|
import { NotificationConsoleComponent } from "./Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import "./Libs/is-integer-polyfill";
|
import { PanelContainerComponent } from "./Explorer/Panes/PanelContainerComponent";
|
||||||
import "./Libs/jquery";
|
import { SplashScreen } from "./Explorer/SplashScreen/SplashScreen";
|
||||||
import "./Shared/appInsights";
|
import { Dialog, DialogProps } from "./Explorer/Controls/Dialog";
|
||||||
|
|
||||||
initializeIcons();
|
initializeIcons();
|
||||||
|
|
||||||
@@ -101,17 +103,20 @@ const App: React.FunctionComponent = () => {
|
|||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const explorer = useKnockoutExplorer(config?.platform, explorerParams);
|
const explorer = useKnockoutExplorer(config?.platform, explorerParams);
|
||||||
|
|
||||||
const { commandBarProperties } = useExplorerState(explorer);
|
|
||||||
|
|
||||||
if (!explorer) {
|
|
||||||
return <LoadingExplorer />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flexContainer">
|
<div className="flexContainer">
|
||||||
<div id="divExplorer" className="flexContainer hideOverflows" style={{ display: "none" }}>
|
<div
|
||||||
{/* Main Command Bar - Start */}
|
id="divSelfServe"
|
||||||
<CommandBarComponent {...commandBarProperties} />
|
className="flexContainer"
|
||||||
|
data-bind="visible: selfServeType() && selfServeType() !== 'none', react: selfServeComponentAdapter"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
id="divExplorer"
|
||||||
|
data-bind="if: selfServeType() === 'none'"
|
||||||
|
className="flexContainer hideOverflows"
|
||||||
|
style={{ display: "none" }}
|
||||||
|
>
|
||||||
|
<div data-bind="react: commandBarComponentAdapter" />
|
||||||
{/* Collections Tree and Tabs - Begin */}
|
{/* Collections Tree and Tabs - Begin */}
|
||||||
<div className="resourceTreeAndTabs">
|
<div className="resourceTreeAndTabs">
|
||||||
{/* Collections Tree - Start */}
|
{/* Collections Tree - Start */}
|
||||||
@@ -240,6 +245,25 @@ const App: React.FunctionComponent = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Global loader - Start */}
|
||||||
|
|
||||||
|
<div className="splashLoaderContainer" data-bind="visible: isRefreshingExplorer">
|
||||||
|
<div className="splashLoaderContentContainer">
|
||||||
|
<div data-bind="visible: selfServeType() === undefined, react: selfServeLoadingComponentAdapter"></div>
|
||||||
|
<div data-bind="if: selfServeType() === 'none'" style={{ display: "none" }}>
|
||||||
|
<p className="connectExplorerContent">
|
||||||
|
<img src={hdeConnectImage} alt="Azure Cosmos DB" />
|
||||||
|
</p>
|
||||||
|
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle">
|
||||||
|
Welcome to Azure Cosmos DB
|
||||||
|
</p>
|
||||||
|
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert">
|
||||||
|
Connecting...
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Global loader - End */}
|
||||||
<PanelContainerComponent
|
<PanelContainerComponent
|
||||||
isOpen={isPanelOpen}
|
isOpen={isPanelOpen}
|
||||||
panelContent={panelContent}
|
panelContent={panelContent}
|
||||||
@@ -283,21 +307,3 @@ const App: React.FunctionComponent = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.body);
|
ReactDOM.render(<App />, document.body);
|
||||||
|
|
||||||
function LoadingExplorer(): JSX.Element {
|
|
||||||
return (
|
|
||||||
<div className="splashLoaderContainer">
|
|
||||||
<div className="splashLoaderContentContainer">
|
|
||||||
<p className="connectExplorerContent">
|
|
||||||
<img src={hdeConnectImage} alt="Azure Cosmos DB" />
|
|
||||||
</p>
|
|
||||||
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle">
|
|
||||||
Welcome to Azure Cosmos DB
|
|
||||||
</p>
|
|
||||||
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert">
|
|
||||||
Connecting...
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ChoiceItem, Description, Info, InputType, NumberUiType, SmartUiInput, RefreshParams } from "./SelfServeTypes";
|
import { ChoiceItem, Description, Info, InputType, NumberUiType, SmartUiInput } from "./SelfServeTypes";
|
||||||
import { addPropertyToMap, DecoratorProperties, buildSmartUiDescriptor } from "./SelfServeUtils";
|
import { addPropertyToMap, DecoratorProperties, buildSmartUiDescriptor } from "./SelfServeUtils";
|
||||||
|
|
||||||
type ValueOf<T> = T[keyof T];
|
type ValueOf<T> = T[keyof T];
|
||||||
@@ -33,9 +33,7 @@ export interface ChoiceInputOptions extends InputOptionsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DescriptionDisplayOptions {
|
export interface DescriptionDisplayOptions {
|
||||||
labelTKey?: string;
|
|
||||||
description?: (() => Promise<Description>) | Description;
|
description?: (() => Promise<Description>) | Description;
|
||||||
isDynamicDescription?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputOptions =
|
type InputOptions =
|
||||||
@@ -58,7 +56,7 @@ const isChoiceInputOptions = (inputOptions: InputOptions): inputOptions is Choic
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isDescriptionDisplayOptions = (inputOptions: InputOptions): inputOptions is DescriptionDisplayOptions => {
|
const isDescriptionDisplayOptions = (inputOptions: InputOptions): inputOptions is DescriptionDisplayOptions => {
|
||||||
return "description" in inputOptions || "isDynamicDescription" in inputOptions;
|
return "description" in inputOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
||||||
@@ -82,11 +80,7 @@ const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const OnChange = (
|
export const OnChange = (
|
||||||
onChange: (
|
onChange: (currentState: Map<string, SmartUiInput>, newValue: InputType) => Map<string, SmartUiInput>
|
||||||
newValue: InputType,
|
|
||||||
currentState: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
) => Map<string, SmartUiInput>
|
|
||||||
): PropertyDecorator => {
|
): PropertyDecorator => {
|
||||||
return addToMap({ name: "onChange", value: onChange });
|
return addToMap({ name: "onChange", value: onChange });
|
||||||
};
|
};
|
||||||
@@ -117,11 +111,7 @@ export const Values = (inputOptions: InputOptions): PropertyDecorator => {
|
|||||||
{ name: "choices", value: inputOptions.choices }
|
{ name: "choices", value: inputOptions.choices }
|
||||||
);
|
);
|
||||||
} else if (isDescriptionDisplayOptions(inputOptions)) {
|
} else if (isDescriptionDisplayOptions(inputOptions)) {
|
||||||
return addToMap(
|
return addToMap({ name: "description", value: inputOptions.description });
|
||||||
{ name: "labelTKey", value: inputOptions.labelTKey },
|
|
||||||
{ name: "description", value: inputOptions.description },
|
|
||||||
{ name: "isDynamicDescription", value: inputOptions.isDynamicDescription }
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return addToMap(
|
return addToMap(
|
||||||
{ name: "labelTKey", value: inputOptions.labelTKey },
|
{ name: "labelTKey", value: inputOptions.labelTKey },
|
||||||
@@ -136,8 +126,8 @@ export const IsDisplayable = (): ClassDecorator => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RefreshOptions = (refreshParams: RefreshParams): ClassDecorator => {
|
export const ClassInfo = (info: (() => Promise<Info>) | Info): ClassDecorator => {
|
||||||
return (target) => {
|
return (target) => {
|
||||||
addPropertyToMap(target.prototype, "root", target.name, "refreshParams", refreshParams);
|
addPropertyToMap(target.prototype, "root", target.name, "info", info);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,20 +64,13 @@ export const initialize = async (): Promise<InitializeResponse> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const onRefreshSelfServeExample = async (): Promise<RefreshResult> => {
|
export const onRefreshSelfServeExample = async (): Promise<RefreshResult> => {
|
||||||
const refreshCountString = SessionStorageUtility.getEntry("refreshCount");
|
|
||||||
const refreshCount = refreshCountString ? parseInt(refreshCountString) : 0;
|
|
||||||
|
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
const resourceGroup = userContext.resourceGroup;
|
const resourceGroup = userContext.resourceGroup;
|
||||||
const databaseAccountName = userContext.databaseAccount.name;
|
const databaseAccountName = userContext.databaseAccount.name;
|
||||||
const databaseAccountGetResults = await get(subscriptionId, resourceGroup, databaseAccountName);
|
const databaseAccountGetResults = await get(subscriptionId, resourceGroup, databaseAccountName);
|
||||||
const isUpdateInProgress = databaseAccountGetResults.properties.provisioningState !== "Succeeded";
|
const isUpdateInProgress = databaseAccountGetResults.properties.provisioningState !== "Succeeded";
|
||||||
|
|
||||||
const progressToBeSent = refreshCount % 5 === 0 ? isUpdateInProgress : true;
|
|
||||||
SessionStorageUtility.setEntry("refreshCount", (refreshCount + 1).toString());
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isUpdateInProgress: progressToBeSent,
|
isUpdateInProgress: isUpdateInProgress,
|
||||||
updateInProgressMessageTKey: "UpdateInProgressMessage",
|
notificationMessage: "RefreshMessage",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { PropertyInfo, OnChange, Values, IsDisplayable, RefreshOptions } from "../Decorators";
|
import { PropertyInfo, OnChange, Values, IsDisplayable, ClassInfo } from "../Decorators";
|
||||||
import {
|
import {
|
||||||
ChoiceItem,
|
ChoiceItem,
|
||||||
Description,
|
|
||||||
DescriptionType,
|
|
||||||
Info,
|
Info,
|
||||||
InputType,
|
InputType,
|
||||||
NumberUiType,
|
NumberUiType,
|
||||||
OnSaveResult,
|
|
||||||
RefreshResult,
|
RefreshResult,
|
||||||
SelfServeBaseClass,
|
SelfServeBaseClass,
|
||||||
|
SelfServeNotification,
|
||||||
|
SelfServeNotificationType,
|
||||||
SmartUiInput,
|
SmartUiInput,
|
||||||
} from "../SelfServeTypes";
|
} from "../SelfServeTypes";
|
||||||
import {
|
import {
|
||||||
@@ -28,19 +27,16 @@ const regionDropdownItems: ChoiceItem[] = [
|
|||||||
{ label: "East US 2", key: Regions.EastUS2 },
|
{ label: "East US 2", key: Regions.EastUS2 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const selfServeExampleInfo: Info = {
|
||||||
|
messageTKey: "ClassInfo",
|
||||||
|
};
|
||||||
|
|
||||||
const regionDropdownInfo: Info = {
|
const regionDropdownInfo: Info = {
|
||||||
messageTKey: "RegionDropdownInfo",
|
messageTKey: "RegionDropdownInfo",
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRegionsChange = (newValue: InputType, currentState: Map<string, SmartUiInput>): Map<string, SmartUiInput> => {
|
const onRegionsChange = (currentState: Map<string, SmartUiInput>, newValue: InputType): Map<string, SmartUiInput> => {
|
||||||
currentState.set("regions", { value: newValue });
|
currentState.set("regions", { value: newValue });
|
||||||
|
|
||||||
const currentRegionText = `current region selected is ${newValue}`;
|
|
||||||
currentState.set("currentRegionText", {
|
|
||||||
value: { textTKey: currentRegionText, type: DescriptionType.Text } as Description,
|
|
||||||
hidden: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentEnableLogging = currentState.get("enableLogging");
|
const currentEnableLogging = currentState.get("enableLogging");
|
||||||
if (newValue === Regions.NorthCentralUS) {
|
if (newValue === Regions.NorthCentralUS) {
|
||||||
currentState.set("enableLogging", { value: false, disabled: true });
|
currentState.set("enableLogging", { value: false, disabled: true });
|
||||||
@@ -51,8 +47,8 @@ const onRegionsChange = (newValue: InputType, currentState: Map<string, SmartUiI
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onEnableDbLevelThroughputChange = (
|
const onEnableDbLevelThroughputChange = (
|
||||||
newValue: InputType,
|
currentState: Map<string, SmartUiInput>,
|
||||||
currentState: Map<string, SmartUiInput>
|
newValue: InputType
|
||||||
): Map<string, SmartUiInput> => {
|
): Map<string, SmartUiInput> => {
|
||||||
currentState.set("enableDbLevelThroughput", { value: newValue });
|
currentState.set("enableDbLevelThroughput", { value: newValue });
|
||||||
const currentDbThroughput = currentState.get("dbThroughput");
|
const currentDbThroughput = currentState.get("dbThroughput");
|
||||||
@@ -61,15 +57,9 @@ const onEnableDbLevelThroughputChange = (
|
|||||||
return currentState;
|
return currentState;
|
||||||
};
|
};
|
||||||
|
|
||||||
const validate = (
|
const validate = (currentvalues: Map<string, SmartUiInput>): void => {
|
||||||
currentvalues: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
): void => {
|
|
||||||
if (currentvalues.get("dbThroughput") === baselineValues.get("dbThroughput")) {
|
|
||||||
throw new Error("DbThroughputValidationError");
|
|
||||||
}
|
|
||||||
if (!currentvalues.get("regions").value || !currentvalues.get("accountName").value) {
|
if (!currentvalues.get("regions").value || !currentvalues.get("accountName").value) {
|
||||||
throw new Error("RegionsAndAccountNameValidationError");
|
throw new Error("ValidationError");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,12 +86,12 @@ const validate = (
|
|||||||
*/
|
*/
|
||||||
@IsDisplayable()
|
@IsDisplayable()
|
||||||
/*
|
/*
|
||||||
@RefreshOptions()
|
@ClassInfo()
|
||||||
- role: Passes the refresh options to be used by the self serve model.
|
- optional
|
||||||
- inputs:
|
- input: Info | () => Promise<Info>
|
||||||
retryIntervalInMs - The time interval between refresh attempts when an update in ongoing.
|
- role: Display an Info bar as the first element of the UI.
|
||||||
*/
|
*/
|
||||||
@RefreshOptions({ retryIntervalInMs: 2000 })
|
@ClassInfo(selfServeExampleInfo)
|
||||||
export default class SelfServeExample extends SelfServeBaseClass {
|
export default class SelfServeExample extends SelfServeBaseClass {
|
||||||
/*
|
/*
|
||||||
onRefresh()
|
onRefresh()
|
||||||
@@ -119,21 +109,18 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
onSave()
|
onSave()
|
||||||
- input: (currentValues: Map<string, InputType>, baselineValues: ReadonlyMap<string, SmartUiInput>) => Promise<string>
|
- input: (currentValues: Map<string, InputType>) => Promise<void>
|
||||||
- role: Callback that is triggerred when the submit button is clicked. You should perform your rest API
|
- role: Callback that is triggerred when the submit button is clicked. You should perform your rest API
|
||||||
calls here using the data from the different inputs passed as a Map to this callback function.
|
calls here using the data from the different inputs passed as a Map to this callback function.
|
||||||
|
|
||||||
In this example, the onSave callback simply sets the value for keys corresponding to the field name
|
In this example, the onSave callback simply sets the value for keys corresponding to the field name
|
||||||
in the SessionStorage. It uses the currentValues and baselineValues maps to perform custom validations
|
in the SessionStorage.
|
||||||
as well.
|
- returns: SelfServeNotification -
|
||||||
|
message: The message to be displayed in the message bar after the onSave is completed
|
||||||
- returns: The initialize, success and failure messages to be displayed in the Portal Notification blade after the operation is completed.
|
type: The type of message bar to be used (info, warning, error)
|
||||||
*/
|
*/
|
||||||
public onSave = async (
|
public onSave = async (currentValues: Map<string, SmartUiInput>): Promise<SelfServeNotification> => {
|
||||||
currentValues: Map<string, SmartUiInput>,
|
validate(currentValues);
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
): Promise<OnSaveResult> => {
|
|
||||||
validate(currentValues, baselineValues);
|
|
||||||
const regions = Regions[currentValues.get("regions")?.value as keyof typeof Regions];
|
const regions = Regions[currentValues.get("regions")?.value as keyof typeof Regions];
|
||||||
const enableLogging = currentValues.get("enableLogging")?.value as boolean;
|
const enableLogging = currentValues.get("enableLogging")?.value as boolean;
|
||||||
const accountName = currentValues.get("accountName")?.value as string;
|
const accountName = currentValues.get("accountName")?.value as string;
|
||||||
@@ -141,48 +128,8 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
|||||||
const enableDbLevelThroughput = currentValues.get("enableDbLevelThroughput")?.value as boolean;
|
const enableDbLevelThroughput = currentValues.get("enableDbLevelThroughput")?.value as boolean;
|
||||||
let dbThroughput = currentValues.get("dbThroughput")?.value as number;
|
let dbThroughput = currentValues.get("dbThroughput")?.value as number;
|
||||||
dbThroughput = enableDbLevelThroughput ? dbThroughput : undefined;
|
dbThroughput = enableDbLevelThroughput ? dbThroughput : undefined;
|
||||||
try {
|
await update(regions, enableLogging, accountName, collectionThroughput, dbThroughput);
|
||||||
await update(regions, enableLogging, accountName, collectionThroughput, dbThroughput);
|
return { message: "SubmissionMessage", type: SelfServeNotificationType.info };
|
||||||
if (currentValues.get("regions") === baselineValues.get("regions")) {
|
|
||||||
return {
|
|
||||||
operationStatusUrl: undefined,
|
|
||||||
portalNotification: {
|
|
||||||
initialize: {
|
|
||||||
titleTKey: "SubmissionMessageSuccessTitle",
|
|
||||||
messageTKey: "SubmissionMessageForSameRegionText",
|
|
||||||
},
|
|
||||||
success: {
|
|
||||||
titleTKey: "UpdateCompletedMessageTitle",
|
|
||||||
messageTKey: "UpdateCompletedMessageText",
|
|
||||||
},
|
|
||||||
failure: {
|
|
||||||
titleTKey: "SubmissionMessageErrorTitle",
|
|
||||||
messageTKey: "SubmissionMessageErrorText",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
operationStatusUrl: undefined,
|
|
||||||
portalNotification: {
|
|
||||||
initialize: {
|
|
||||||
titleTKey: "SubmissionMessageSuccessTitle",
|
|
||||||
messageTKey: "SubmissionMessageForNewRegionText",
|
|
||||||
},
|
|
||||||
success: {
|
|
||||||
titleTKey: "UpdateCompletedMessageTitle",
|
|
||||||
messageTKey: "UpdateCompletedMessageText",
|
|
||||||
},
|
|
||||||
failure: {
|
|
||||||
titleTKey: "SubmissionMessageErrorTitle",
|
|
||||||
messageTKey: "SubmissionMessageErrorText",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error("OnSaveFailureMessage");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -203,11 +150,6 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
|||||||
public initialize = async (): Promise<Map<string, SmartUiInput>> => {
|
public initialize = async (): Promise<Map<string, SmartUiInput>> => {
|
||||||
const initializeResponse = await initialize();
|
const initializeResponse = await initialize();
|
||||||
const defaults = new Map<string, SmartUiInput>();
|
const defaults = new Map<string, SmartUiInput>();
|
||||||
const currentRegionText = `current region selected is ${initializeResponse.regions}`;
|
|
||||||
defaults.set("currentRegionText", {
|
|
||||||
value: { textTKey: currentRegionText, type: DescriptionType.Text } as Description,
|
|
||||||
hidden: false,
|
|
||||||
});
|
|
||||||
defaults.set("regions", { value: initializeResponse.regions });
|
defaults.set("regions", { value: initializeResponse.regions });
|
||||||
defaults.set("enableLogging", { value: initializeResponse.enableLogging });
|
defaults.set("enableLogging", { value: initializeResponse.enableLogging });
|
||||||
const accountName = initializeResponse.accountName;
|
const accountName = initializeResponse.accountName;
|
||||||
@@ -230,24 +172,15 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
|||||||
e) Text (with optional hyperlink) for descriptions
|
e) Text (with optional hyperlink) for descriptions
|
||||||
*/
|
*/
|
||||||
@Values({
|
@Values({
|
||||||
labelTKey: "DescriptionLabel",
|
|
||||||
description: {
|
description: {
|
||||||
textTKey: "DescriptionText",
|
textTKey: "DescriptionText",
|
||||||
type: DescriptionType.Text,
|
|
||||||
link: {
|
link: {
|
||||||
href: "https://aka.ms/cosmos-create-account-portal",
|
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
||||||
textTKey: "DecriptionLinkText",
|
textTKey: "DecriptionLinkText",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
@Values({
|
|
||||||
labelTKey: "Current Region",
|
|
||||||
isDynamicDescription: true,
|
|
||||||
})
|
|
||||||
currentRegionText: string;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@PropertyInfo()
|
@PropertyInfo()
|
||||||
- optional
|
- optional
|
||||||
@@ -259,8 +192,8 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
|||||||
/*
|
/*
|
||||||
@OnChange()
|
@OnChange()
|
||||||
- optional
|
- optional
|
||||||
- input: (currentValues: Map<string, InputType>, newValue: InputType, baselineValues: ReadonlyMap<string, SmartUiInput>) => Map<string, InputType>
|
- input: (currentValues: Map<string, InputType>, newValue: InputType) => Map<string, InputType>
|
||||||
- role: Takes a Map of current values, the newValue for this property and a ReadonlyMap of baselineValues as inputs. This is called when a property,
|
- role: Takes a Map of current values and the newValue for this property as inputs. This is called when a property,
|
||||||
say prop1, changes its value in the UI. This can be used to
|
say prop1, changes its value in the UI. This can be used to
|
||||||
a) Change the value (and reflect it in the UI) for prop2 based on prop1.
|
a) Change the value (and reflect it in the UI) for prop2 based on prop1.
|
||||||
b) Change the visibility for prop2 in the UI, based on prop1
|
b) Change the visibility for prop2 in the UI, based on prop1
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
.selfServeComponentContainer {
|
|
||||||
text-transform: none;
|
|
||||||
line-height: 1.28581;
|
|
||||||
letter-spacing: 0;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: #182026;
|
|
||||||
height: 100%;
|
|
||||||
min-height: 100vh;
|
|
||||||
width: 100%;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import ReactDOM from "react-dom";
|
|
||||||
import { sendMessage } from "../Common/MessageHandler";
|
|
||||||
import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation";
|
|
||||||
import { SelfServeComponent } from "./SelfServeComponent";
|
|
||||||
import { SelfServeDescriptor } from "./SelfServeTypes";
|
|
||||||
import { SelfServeType } from "./SelfServeUtils";
|
|
||||||
import { SelfServeFrameInputs } from "../Contracts/ViewModels";
|
|
||||||
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
|
||||||
import { configContext, updateConfigContext } from "../ConfigContext";
|
|
||||||
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
|
||||||
import { updateUserContext } from "../UserContext";
|
|
||||||
import "./SelfServe.less";
|
|
||||||
import { Spinner, SpinnerSize } from "office-ui-fabric-react";
|
|
||||||
initializeIcons();
|
|
||||||
|
|
||||||
const getDescriptor = async (selfServeType: SelfServeType): Promise<SelfServeDescriptor> => {
|
|
||||||
switch (selfServeType) {
|
|
||||||
case SelfServeType.example: {
|
|
||||||
const SelfServeExample = await import(/* webpackChunkName: "SelfServeExample" */ "./Example/SelfServeExample");
|
|
||||||
return new SelfServeExample.default().toSelfServeDescriptor();
|
|
||||||
}
|
|
||||||
case SelfServeType.sqlx: {
|
|
||||||
const SqlX = await import(/* webpackChunkName: "SqlX" */ "./SqlX/SqlX");
|
|
||||||
return new SqlX.default().toSelfServeDescriptor();
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderComponent = (selfServeDescriptor: SelfServeDescriptor): JSX.Element => {
|
|
||||||
if (!selfServeDescriptor) {
|
|
||||||
return <h1>Invalid self serve type!</h1>;
|
|
||||||
}
|
|
||||||
return <SelfServeComponent descriptor={selfServeDescriptor} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderSpinner = (): JSX.Element => {
|
|
||||||
return <Spinner size={SpinnerSize.large}></Spinner>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMessage = async (event: MessageEvent): Promise<void> => {
|
|
||||||
if (isInvalidParentFrameOrigin(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.data["signature"] !== "pcIframe") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof event.data !== "object") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const inputs = event.data.data.inputs as SelfServeFrameInputs;
|
|
||||||
if (!inputs) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
||||||
const selfServeTypeText = inputs.selfServeType || urlSearchParams.get("selfServeType");
|
|
||||||
const selfServeType = SelfServeType[selfServeTypeText?.toLowerCase() as keyof typeof SelfServeType];
|
|
||||||
if (
|
|
||||||
!inputs.subscriptionId ||
|
|
||||||
!inputs.resourceGroup ||
|
|
||||||
!inputs.databaseAccount ||
|
|
||||||
!inputs.authorizationToken ||
|
|
||||||
!inputs.csmEndpoint ||
|
|
||||||
!selfServeType
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateConfigContext({
|
|
||||||
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
|
||||||
});
|
|
||||||
|
|
||||||
updateUserContext({
|
|
||||||
authorizationToken: inputs.authorizationToken,
|
|
||||||
databaseAccount: inputs.databaseAccount,
|
|
||||||
resourceGroup: inputs.resourceGroup,
|
|
||||||
subscriptionId: inputs.subscriptionId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const descriptor = await getDescriptor(selfServeType);
|
|
||||||
ReactDOM.render(renderComponent(descriptor), document.getElementById("selfServeContent"));
|
|
||||||
};
|
|
||||||
|
|
||||||
ReactDOM.render(renderSpinner(), document.getElementById("selfServeContent"));
|
|
||||||
window.addEventListener("message", handleMessage, false);
|
|
||||||
sendMessage("ready");
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import { SelfServeComponent, SelfServeComponentState } from "./SelfServeComponent";
|
import { SelfServeComponent, SelfServeComponentState } from "./SelfServeComponent";
|
||||||
import { NumberUiType, OnSaveResult, SelfServeDescriptor, SmartUiInput } from "./SelfServeTypes";
|
import { NumberUiType, SelfServeDescriptor, SelfServeNotificationType, SmartUiInput } from "./SelfServeTypes";
|
||||||
|
|
||||||
describe("SelfServeComponent", () => {
|
describe("SelfServeComponent", () => {
|
||||||
const defaultValues = new Map<string, SmartUiInput>([
|
const defaultValues = new Map<string, SmartUiInput>([
|
||||||
@@ -17,20 +17,13 @@ describe("SelfServeComponent", () => {
|
|||||||
|
|
||||||
const initializeMock = jest.fn(async () => new Map(defaultValues));
|
const initializeMock = jest.fn(async () => new Map(defaultValues));
|
||||||
const onSaveMock = jest.fn(async () => {
|
const onSaveMock = jest.fn(async () => {
|
||||||
return {
|
return { message: "submitted successfully", type: SelfServeNotificationType.info };
|
||||||
operationStatusUrl: undefined,
|
|
||||||
} as OnSaveResult;
|
|
||||||
});
|
});
|
||||||
const refreshResult = {
|
|
||||||
isUpdateInProgress: false,
|
|
||||||
updateInProgressMessageTKey: "refresh performed successfully",
|
|
||||||
};
|
|
||||||
|
|
||||||
const onRefreshMock = jest.fn(async () => {
|
const onRefreshMock = jest.fn(async () => {
|
||||||
return { ...refreshResult };
|
return { isUpdateInProgress: false, notificationMessage: "refresh performed successfully" };
|
||||||
});
|
});
|
||||||
const onRefreshIsUpdatingMock = jest.fn(async () => {
|
const onRefreshIsUpdatingMock = jest.fn(async () => {
|
||||||
return { ...refreshResult, isUpdateInProgress: true };
|
return { isUpdateInProgress: true, notificationMessage: "refresh performed successfully" };
|
||||||
});
|
});
|
||||||
|
|
||||||
const exampleData: SelfServeDescriptor = {
|
const exampleData: SelfServeDescriptor = {
|
||||||
@@ -143,15 +136,16 @@ describe("SelfServeComponent", () => {
|
|||||||
wrapper.update();
|
wrapper.update();
|
||||||
state = wrapper.state() as SelfServeComponentState;
|
state = wrapper.state() as SelfServeComponentState;
|
||||||
isEqual(state.baselineValues, updatedValues);
|
isEqual(state.baselineValues, updatedValues);
|
||||||
selfServeComponent.updateBaselineValues();
|
selfServeComponent.resetBaselineValues();
|
||||||
state = wrapper.state() as SelfServeComponentState;
|
state = wrapper.state() as SelfServeComponentState;
|
||||||
isEqual(state.baselineValues, defaultValues);
|
isEqual(state.baselineValues, defaultValues);
|
||||||
isEqual(state.currentValues, state.baselineValues);
|
isEqual(state.currentValues, state.baselineValues);
|
||||||
|
|
||||||
// clicking refresh calls onRefresh.
|
// clicking refresh calls onRefresh. If component is not updating, it calls initialize() as well
|
||||||
selfServeComponent.onRefreshClicked();
|
selfServeComponent.onRefreshClicked();
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
expect(onRefreshMock).toHaveBeenCalledTimes(2);
|
expect(onRefreshMock).toHaveBeenCalledTimes(2);
|
||||||
|
expect(initializeMock).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
selfServeComponent.onSaveButtonClick();
|
selfServeComponent.onSaveButtonClick();
|
||||||
expect(onSaveMock).toHaveBeenCalledTimes(1);
|
expect(onSaveMock).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
@@ -15,45 +15,20 @@ import {
|
|||||||
InputType,
|
InputType,
|
||||||
RefreshResult,
|
RefreshResult,
|
||||||
SelfServeDescriptor,
|
SelfServeDescriptor,
|
||||||
|
SelfServeNotification,
|
||||||
SmartUiInput,
|
SmartUiInput,
|
||||||
DescriptionDisplay,
|
DescriptionDisplay,
|
||||||
StringInput,
|
StringInput,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
ChoiceInput,
|
ChoiceInput,
|
||||||
|
SelfServeNotificationType,
|
||||||
} from "./SelfServeTypes";
|
} from "./SelfServeTypes";
|
||||||
import { SmartUiComponent, SmartUiDescriptor } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
import { SmartUiComponent, SmartUiDescriptor } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
import { getMessageBarType } from "./SelfServeUtils";
|
||||||
import { Translation } from "react-i18next";
|
import { Translation } from "react-i18next";
|
||||||
import { TFunction } from "i18next";
|
import { TFunction } from "i18next";
|
||||||
import "../i18n";
|
import "../i18n";
|
||||||
import { sendMessage } from "../Common/MessageHandler";
|
|
||||||
import { SelfServeMessageTypes } from "../Contracts/SelfServeContracts";
|
|
||||||
import promiseRetry, { AbortError } from "p-retry";
|
|
||||||
|
|
||||||
interface SelfServeNotification {
|
|
||||||
message: string;
|
|
||||||
type: MessageBarType;
|
|
||||||
isCancellable: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PortalNotificationContent {
|
|
||||||
retryIntervalInMs: number;
|
|
||||||
operationStatusUrl: string;
|
|
||||||
portalNotification?: {
|
|
||||||
initialize: {
|
|
||||||
title: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
success: {
|
|
||||||
title: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
failure: {
|
|
||||||
title: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SelfServeComponentProps {
|
export interface SelfServeComponentProps {
|
||||||
descriptor: SelfServeDescriptor;
|
descriptor: SelfServeDescriptor;
|
||||||
@@ -64,26 +39,17 @@ export interface SelfServeComponentState {
|
|||||||
currentValues: Map<string, SmartUiInput>;
|
currentValues: Map<string, SmartUiInput>;
|
||||||
baselineValues: Map<string, SmartUiInput>;
|
baselineValues: Map<string, SmartUiInput>;
|
||||||
isInitializing: boolean;
|
isInitializing: boolean;
|
||||||
isSaving: boolean;
|
|
||||||
hasErrors: boolean;
|
hasErrors: boolean;
|
||||||
compileErrorMessage: string;
|
compileErrorMessage: string;
|
||||||
refreshResult: RefreshResult;
|
|
||||||
notification: SelfServeNotification;
|
notification: SelfServeNotification;
|
||||||
|
refreshResult: RefreshResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SelfServeComponent extends React.Component<SelfServeComponentProps, SelfServeComponentState> {
|
export class SelfServeComponent extends React.Component<SelfServeComponentProps, SelfServeComponentState> {
|
||||||
private static readonly defaultRetryIntervalInMs = 30000;
|
|
||||||
private smartUiGeneratorClassName: string;
|
private smartUiGeneratorClassName: string;
|
||||||
private retryIntervalInMs: number;
|
|
||||||
private retryOptions: promiseRetry.Options;
|
|
||||||
private translationFunction: TFunction;
|
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
this.performRefresh().then(() => {
|
this.performRefresh();
|
||||||
if (this.state.refreshResult?.isUpdateInProgress) {
|
|
||||||
promiseRetry(() => this.pollRefresh(), this.retryOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.initializeSmartUiComponent();
|
this.initializeSmartUiComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,18 +60,12 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
currentValues: new Map(),
|
currentValues: new Map(),
|
||||||
baselineValues: new Map(),
|
baselineValues: new Map(),
|
||||||
isInitializing: true,
|
isInitializing: true,
|
||||||
isSaving: false,
|
|
||||||
hasErrors: false,
|
hasErrors: false,
|
||||||
compileErrorMessage: undefined,
|
compileErrorMessage: undefined,
|
||||||
refreshResult: undefined,
|
|
||||||
notification: undefined,
|
notification: undefined,
|
||||||
|
refreshResult: undefined,
|
||||||
};
|
};
|
||||||
this.smartUiGeneratorClassName = this.props.descriptor.root.id;
|
this.smartUiGeneratorClassName = this.props.descriptor.root.id;
|
||||||
this.retryIntervalInMs = this.props.descriptor.refreshParams?.retryIntervalInMs;
|
|
||||||
if (!this.retryIntervalInMs) {
|
|
||||||
this.retryIntervalInMs = SelfServeComponent.defaultRetryIntervalInMs;
|
|
||||||
}
|
|
||||||
this.retryOptions = { forever: true, maxTimeout: this.retryIntervalInMs, minTimeout: this.retryIntervalInMs };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private onError = (hasErrors: boolean): void => {
|
private onError = (hasErrors: boolean): void => {
|
||||||
@@ -149,7 +109,7 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
this.setState({ currentValues, baselineValues });
|
this.setState({ currentValues, baselineValues });
|
||||||
};
|
};
|
||||||
|
|
||||||
public updateBaselineValues = (): void => {
|
public resetBaselineValues = (): void => {
|
||||||
const currentValues = this.state.currentValues;
|
const currentValues = this.state.currentValues;
|
||||||
let baselineValues = this.state.baselineValues;
|
let baselineValues = this.state.baselineValues;
|
||||||
for (const key of currentValues.keys()) {
|
for (const key of currentValues.keys()) {
|
||||||
@@ -244,11 +204,7 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
|
|
||||||
private onInputChange = (input: AnyDisplay, newValue: InputType) => {
|
private onInputChange = (input: AnyDisplay, newValue: InputType) => {
|
||||||
if (input.onChange) {
|
if (input.onChange) {
|
||||||
const newValues = input.onChange(
|
const newValues = input.onChange(this.state.currentValues, newValue);
|
||||||
newValue,
|
|
||||||
this.state.currentValues,
|
|
||||||
this.state.baselineValues as ReadonlyMap<string, SmartUiInput>
|
|
||||||
);
|
|
||||||
this.setState({ currentValues: newValues });
|
this.setState({ currentValues: newValues });
|
||||||
} else {
|
} else {
|
||||||
const dataFieldName = input.dataFieldName;
|
const dataFieldName = input.dataFieldName;
|
||||||
@@ -259,62 +215,29 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public performSave = async (): Promise<void> => {
|
public onSaveButtonClick = (): void => {
|
||||||
this.setState({ isSaving: true, notification: undefined });
|
const onSavePromise = this.props.descriptor.onSave(this.state.currentValues);
|
||||||
try {
|
onSavePromise.catch((error) => {
|
||||||
const onSaveResult = await this.props.descriptor.onSave(
|
|
||||||
this.state.currentValues,
|
|
||||||
this.state.baselineValues as ReadonlyMap<string, SmartUiInput>
|
|
||||||
);
|
|
||||||
if (onSaveResult.portalNotification) {
|
|
||||||
const requestInitializedPortalNotification = onSaveResult.portalNotification.initialize;
|
|
||||||
const requestSucceededPortalNotification = onSaveResult.portalNotification.success;
|
|
||||||
const requestFailedPortalNotification = onSaveResult.portalNotification.failure;
|
|
||||||
|
|
||||||
this.sendNotificationMessage({
|
|
||||||
retryIntervalInMs: this.retryIntervalInMs,
|
|
||||||
operationStatusUrl: onSaveResult.operationStatusUrl,
|
|
||||||
portalNotification: {
|
|
||||||
initialize: {
|
|
||||||
title: this.getTranslation(requestInitializedPortalNotification.titleTKey),
|
|
||||||
message: this.getTranslation(requestInitializedPortalNotification.messageTKey),
|
|
||||||
},
|
|
||||||
success: {
|
|
||||||
title: this.getTranslation(requestSucceededPortalNotification.titleTKey),
|
|
||||||
message: this.getTranslation(requestSucceededPortalNotification.messageTKey),
|
|
||||||
},
|
|
||||||
failure: {
|
|
||||||
title: this.getTranslation(requestFailedPortalNotification.titleTKey),
|
|
||||||
message: this.getTranslation(requestFailedPortalNotification.messageTKey),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
promiseRetry(() => this.pollRefresh(), this.retryOptions);
|
|
||||||
} catch (error) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
notification: {
|
notification: {
|
||||||
type: MessageBarType.error,
|
message: `${error.message}`,
|
||||||
isCancellable: true,
|
type: SelfServeNotificationType.error,
|
||||||
message: this.getTranslation(error.message),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw error;
|
});
|
||||||
} finally {
|
onSavePromise.then((notification: SelfServeNotification) => {
|
||||||
this.setState({ isSaving: false });
|
this.setState({
|
||||||
}
|
notification: {
|
||||||
await this.onRefreshClicked();
|
message: notification.message,
|
||||||
this.updateBaselineValues();
|
type: notification.type,
|
||||||
};
|
},
|
||||||
|
});
|
||||||
public onSaveButtonClick = (): void => {
|
this.resetBaselineValues();
|
||||||
this.performSave();
|
this.onRefreshClicked();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
public isDiscardButtonDisabled = (): boolean => {
|
public isDiscardButtonDisabled = (): boolean => {
|
||||||
if (this.state.isSaving) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (const key of this.state.currentValues.keys()) {
|
for (const key of this.state.currentValues.keys()) {
|
||||||
const currentValue = JSON.stringify(this.state.currentValues.get(key));
|
const currentValue = JSON.stringify(this.state.currentValues.get(key));
|
||||||
const baselineValue = JSON.stringify(this.state.baselineValues.get(key));
|
const baselineValue = JSON.stringify(this.state.baselineValues.get(key));
|
||||||
@@ -327,7 +250,7 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
};
|
};
|
||||||
|
|
||||||
public isSaveButtonDisabled = (): boolean => {
|
public isSaveButtonDisabled = (): boolean => {
|
||||||
if (this.state.hasErrors || this.state.isSaving) {
|
if (this.state.hasErrors) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (const key of this.state.currentValues.keys()) {
|
for (const key of this.state.currentValues.keys()) {
|
||||||
@@ -341,69 +264,38 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
private performRefresh = async (): Promise<void> => {
|
private performRefresh = async (): Promise<RefreshResult> => {
|
||||||
const refreshResult = await this.props.descriptor.onRefresh();
|
const refreshResult = await this.props.descriptor.onRefresh();
|
||||||
let updateInProgressNotification: SelfServeNotification;
|
this.setState({ refreshResult: { ...refreshResult } });
|
||||||
if (this.state.refreshResult?.isUpdateInProgress && !refreshResult.isUpdateInProgress) {
|
return refreshResult;
|
||||||
await this.initializeSmartUiComponent();
|
|
||||||
}
|
|
||||||
if (refreshResult.isUpdateInProgress) {
|
|
||||||
updateInProgressNotification = {
|
|
||||||
type: MessageBarType.info,
|
|
||||||
isCancellable: false,
|
|
||||||
message: this.getTranslation(refreshResult.updateInProgressMessageTKey),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
this.setState({
|
|
||||||
refreshResult: { ...refreshResult },
|
|
||||||
notification: updateInProgressNotification,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onRefreshClicked = async (): Promise<void> => {
|
public onRefreshClicked = async (): Promise<void> => {
|
||||||
this.setState({ isInitializing: true });
|
this.setState({ isInitializing: true });
|
||||||
await this.performRefresh();
|
const refreshResult = await this.performRefresh();
|
||||||
|
if (!refreshResult.isUpdateInProgress) {
|
||||||
|
this.initializeSmartUiComponent();
|
||||||
|
}
|
||||||
this.setState({ isInitializing: false });
|
this.setState({ isInitializing: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
public pollRefresh = async (): Promise<void> => {
|
public getCommonTranslation = (translationFunction: TFunction, key: string): string => {
|
||||||
try {
|
return translationFunction(`Common.${key}`);
|
||||||
await this.performRefresh();
|
|
||||||
} catch (error) {
|
|
||||||
throw new AbortError(error);
|
|
||||||
}
|
|
||||||
const refreshResult = this.state.refreshResult;
|
|
||||||
if (refreshResult.isUpdateInProgress) {
|
|
||||||
throw new Error("update in progress. retrying ...");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public getCommonTranslation = (key: string): string => {
|
private getCommandBarItems = (translate: TFunction): ICommandBarItemProps[] => {
|
||||||
return this.getTranslation(key, "Common");
|
|
||||||
};
|
|
||||||
|
|
||||||
private getTranslation = (messageKey: string, prefix = `${this.smartUiGeneratorClassName}`): string => {
|
|
||||||
const translationKey = `${prefix}.${messageKey}`;
|
|
||||||
const translation = this.translationFunction ? this.translationFunction(translationKey) : messageKey;
|
|
||||||
if (translation === translationKey) {
|
|
||||||
return messageKey;
|
|
||||||
}
|
|
||||||
return translation;
|
|
||||||
};
|
|
||||||
|
|
||||||
private getCommandBarItems = (): ICommandBarItemProps[] => {
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
key: "save",
|
key: "save",
|
||||||
text: this.getCommonTranslation("Save"),
|
text: this.getCommonTranslation(translate, "Save"),
|
||||||
iconProps: { iconName: "Save" },
|
iconProps: { iconName: "Save" },
|
||||||
split: true,
|
split: true,
|
||||||
disabled: this.isSaveButtonDisabled(),
|
disabled: this.isSaveButtonDisabled(),
|
||||||
onClick: () => this.onSaveButtonClick(),
|
onClick: this.onSaveButtonClick,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "discard",
|
key: "discard",
|
||||||
text: this.getCommonTranslation("Discard"),
|
text: this.getCommonTranslation(translate, "Discard"),
|
||||||
iconProps: { iconName: "Undo" },
|
iconProps: { iconName: "Undo" },
|
||||||
split: true,
|
split: true,
|
||||||
disabled: this.isDiscardButtonDisabled(),
|
disabled: this.isDiscardButtonDisabled(),
|
||||||
@@ -413,7 +305,7 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "refresh",
|
key: "refresh",
|
||||||
text: this.getCommonTranslation("Refresh"),
|
text: this.getCommonTranslation(translate, "Refresh"),
|
||||||
disabled: this.state.isInitializing,
|
disabled: this.state.isInitializing,
|
||||||
iconProps: { iconName: "Refresh" },
|
iconProps: { iconName: "Refresh" },
|
||||||
split: true,
|
split: true,
|
||||||
@@ -424,11 +316,12 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
private sendNotificationMessage = (portalNotificationContent: PortalNotificationContent): void => {
|
private getNotificationMessageTranslation = (translationFunction: TFunction, messageKey: string): string => {
|
||||||
sendMessage({
|
const translation = translationFunction(messageKey);
|
||||||
type: SelfServeMessageTypes.Notification,
|
if (translation === `${this.smartUiGeneratorClassName}.${messageKey}`) {
|
||||||
data: { portalNotificationContent },
|
return messageKey;
|
||||||
});
|
}
|
||||||
|
return translation;
|
||||||
};
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
@@ -439,14 +332,14 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
return (
|
return (
|
||||||
<Translation>
|
<Translation>
|
||||||
{(translate) => {
|
{(translate) => {
|
||||||
if (!this.translationFunction) {
|
const getTranslation = (key: string): string => {
|
||||||
this.translationFunction = translate;
|
return translate(`${this.smartUiGeneratorClassName}.${key}`);
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ overflowX: "auto" }}>
|
<div style={{ overflowX: "auto" }}>
|
||||||
<Stack tokens={containerStackTokens} styles={{ root: { padding: 10 } }}>
|
<Stack tokens={containerStackTokens} styles={{ root: { padding: 10 } }}>
|
||||||
<CommandBar styles={{ root: { paddingLeft: 0 } }} items={this.getCommandBarItems()} />
|
<CommandBar styles={{ root: { paddingLeft: 0 } }} items={this.getCommandBarItems(translate)} />
|
||||||
{this.state.isInitializing ? (
|
{this.state.isInitializing ? (
|
||||||
<Spinner
|
<Spinner
|
||||||
size={SpinnerSize.large}
|
size={SpinnerSize.large}
|
||||||
@@ -454,25 +347,27 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
{this.state.refreshResult?.isUpdateInProgress && (
|
||||||
|
<MessageBar messageBarType={MessageBarType.info} styles={{ root: { width: 400 } }}>
|
||||||
|
{getTranslation(this.state.refreshResult.notificationMessage)}
|
||||||
|
</MessageBar>
|
||||||
|
)}
|
||||||
{this.state.notification && (
|
{this.state.notification && (
|
||||||
<MessageBar
|
<MessageBar
|
||||||
messageBarType={this.state.notification.type}
|
messageBarType={getMessageBarType(this.state.notification.type)}
|
||||||
onDismiss={
|
styles={{ root: { width: 400 } }}
|
||||||
this.state.notification.isCancellable
|
onDismiss={() => this.setState({ notification: undefined })}
|
||||||
? () => this.setState({ notification: undefined })
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{this.state.notification.message}
|
{this.getNotificationMessageTranslation(getTranslation, this.state.notification.message)}
|
||||||
</MessageBar>
|
</MessageBar>
|
||||||
)}
|
)}
|
||||||
<SmartUiComponent
|
<SmartUiComponent
|
||||||
disabled={this.state.refreshResult?.isUpdateInProgress || this.state.isSaving}
|
disabled={this.state.refreshResult?.isUpdateInProgress}
|
||||||
descriptor={this.state.root as SmartUiDescriptor}
|
descriptor={this.state.root as SmartUiDescriptor}
|
||||||
currentValues={this.state.currentValues}
|
currentValues={this.state.currentValues}
|
||||||
onInputChange={this.onInputChange}
|
onInputChange={this.onInputChange}
|
||||||
onError={this.onError}
|
onError={this.onError}
|
||||||
getTranslation={this.getTranslation}
|
getTranslation={getTranslation}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
56
src/SelfServe/SelfServeComponentAdapter.tsx
Normal file
56
src/SelfServe/SelfServeComponentAdapter.tsx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* This adapter is responsible to render the React component
|
||||||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||||||
|
* and update any knockout observables passed from the parent.
|
||||||
|
*/
|
||||||
|
import * as ko from "knockout";
|
||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
|
import Explorer from "../Explorer/Explorer";
|
||||||
|
import { SelfServeComponent } from "./SelfServeComponent";
|
||||||
|
import { SelfServeDescriptor } from "./SelfServeTypes";
|
||||||
|
import { SelfServeType } from "./SelfServeUtils";
|
||||||
|
|
||||||
|
export class SelfServeComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<SelfServeDescriptor>;
|
||||||
|
public container: Explorer;
|
||||||
|
|
||||||
|
constructor(container: Explorer) {
|
||||||
|
this.container = container;
|
||||||
|
this.parameters = ko.observable(undefined);
|
||||||
|
this.container.selfServeType.subscribe(() => {
|
||||||
|
this.triggerRender();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getDescriptor = async (selfServeType: SelfServeType): Promise<SelfServeDescriptor> => {
|
||||||
|
switch (selfServeType) {
|
||||||
|
case SelfServeType.example: {
|
||||||
|
const SelfServeExample = await import(/* webpackChunkName: "SelfServeExample" */ "./Example/SelfServeExample");
|
||||||
|
return new SelfServeExample.default().toSelfServeDescriptor();
|
||||||
|
}
|
||||||
|
case SelfServeType.sqlx: {
|
||||||
|
const SqlX = await import(/* webpackChunkName: "SqlX" */ "./SqlX/SqlX");
|
||||||
|
return new SqlX.default().toSelfServeDescriptor();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
if (this.container.selfServeType() === SelfServeType.invalid) {
|
||||||
|
return <h1>Invalid self serve type!</h1>;
|
||||||
|
}
|
||||||
|
const smartUiDescriptor = this.parameters();
|
||||||
|
return smartUiDescriptor ? <SelfServeComponent descriptor={smartUiDescriptor} /> : <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
private triggerRender() {
|
||||||
|
window.requestAnimationFrame(async () => {
|
||||||
|
const selfServeType = this.container.selfServeType();
|
||||||
|
const smartUiDescriptor = await SelfServeComponentAdapter.getDescriptor(selfServeType);
|
||||||
|
this.parameters(smartUiDescriptor);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/SelfServe/SelfServeLoadingComponentAdapter.tsx
Normal file
25
src/SelfServe/SelfServeLoadingComponentAdapter.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* This adapter is responsible to render the React component
|
||||||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||||||
|
* and update any knockout observables passed from the parent.
|
||||||
|
*/
|
||||||
|
import * as ko from "knockout";
|
||||||
|
import { Spinner, SpinnerSize } from "office-ui-fabric-react";
|
||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
|
|
||||||
|
export class SelfServeLoadingComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<number>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.parameters = ko.observable(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
return <Spinner size={SpinnerSize.large} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
private triggerRender() {
|
||||||
|
window.requestAnimationFrame(() => this.renderComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,11 +3,7 @@ interface BaseInput {
|
|||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
type: InputTypeValue;
|
type: InputTypeValue;
|
||||||
labelTKey?: (() => Promise<string>) | string;
|
labelTKey?: (() => Promise<string>) | string;
|
||||||
onChange?: (
|
onChange?: (currentState: Map<string, SmartUiInput>, newValue: InputType) => Map<string, SmartUiInput>;
|
||||||
newValue: InputType,
|
|
||||||
currentState: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
) => Map<string, SmartUiInput>;
|
|
||||||
placeholderTKey?: (() => Promise<string>) | string;
|
placeholderTKey?: (() => Promise<string>) | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,23 +44,16 @@ export interface Node {
|
|||||||
export interface SelfServeDescriptor {
|
export interface SelfServeDescriptor {
|
||||||
root: Node;
|
root: Node;
|
||||||
initialize?: () => Promise<Map<string, SmartUiInput>>;
|
initialize?: () => Promise<Map<string, SmartUiInput>>;
|
||||||
onSave?: (
|
onSave?: (currentValues: Map<string, SmartUiInput>) => Promise<SelfServeNotification>;
|
||||||
currentValues: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
) => Promise<OnSaveResult>;
|
|
||||||
inputNames?: string[];
|
inputNames?: string[];
|
||||||
onRefresh?: () => Promise<RefreshResult>;
|
onRefresh?: () => Promise<RefreshResult>;
|
||||||
refreshParams?: RefreshParams;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnyDisplay = NumberInput | BooleanInput | StringInput | ChoiceInput | DescriptionDisplay;
|
export type AnyDisplay = NumberInput | BooleanInput | StringInput | ChoiceInput | DescriptionDisplay;
|
||||||
|
|
||||||
export abstract class SelfServeBaseClass {
|
export abstract class SelfServeBaseClass {
|
||||||
public abstract initialize: () => Promise<Map<string, SmartUiInput>>;
|
public abstract initialize: () => Promise<Map<string, SmartUiInput>>;
|
||||||
public abstract onSave: (
|
public abstract onSave: (currentValues: Map<string, SmartUiInput>) => Promise<SelfServeNotification>;
|
||||||
currentValues: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
) => Promise<OnSaveResult>;
|
|
||||||
public abstract onRefresh: () => Promise<RefreshResult>;
|
public abstract onRefresh: () => Promise<RefreshResult>;
|
||||||
|
|
||||||
public toSelfServeDescriptor(): SelfServeDescriptor {
|
public toSelfServeDescriptor(): SelfServeDescriptor {
|
||||||
@@ -81,7 +70,7 @@ export abstract class SelfServeBaseClass {
|
|||||||
throw new Error(`onRefresh() was not declared for the class '${className}'`);
|
throw new Error(`onRefresh() was not declared for the class '${className}'`);
|
||||||
}
|
}
|
||||||
if (!selfServeDescriptor?.root) {
|
if (!selfServeDescriptor?.root) {
|
||||||
throw new Error(`@IsDisplayable decorator was not declared for the class '${className}'`);
|
throw new Error(`@SmartUi decorator was not declared for the class '${className}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
selfServeDescriptor.initialize = this.initialize;
|
selfServeDescriptor.initialize = this.initialize;
|
||||||
@@ -100,7 +89,7 @@ export enum NumberUiType {
|
|||||||
|
|
||||||
export type ChoiceItem = { label: string; key: string };
|
export type ChoiceItem = { label: string; key: string };
|
||||||
|
|
||||||
export type InputType = number | string | boolean | ChoiceItem | Description;
|
export type InputType = number | string | boolean | ChoiceItem;
|
||||||
|
|
||||||
export interface Info {
|
export interface Info {
|
||||||
messageTKey: string;
|
messageTKey: string;
|
||||||
@@ -110,15 +99,8 @@ export interface Info {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DescriptionType {
|
|
||||||
Text,
|
|
||||||
InfoMessageBar,
|
|
||||||
WarningMessageBar,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Description {
|
export interface Description {
|
||||||
textTKey: string;
|
textTKey: string;
|
||||||
type: DescriptionType;
|
|
||||||
link?: {
|
link?: {
|
||||||
href: string;
|
href: string;
|
||||||
textTKey: string;
|
textTKey: string;
|
||||||
@@ -131,29 +113,18 @@ export interface SmartUiInput {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OnSaveResult {
|
export enum SelfServeNotificationType {
|
||||||
operationStatusUrl: string;
|
info = "info",
|
||||||
portalNotification?: {
|
warning = "warning",
|
||||||
initialize: {
|
error = "error",
|
||||||
titleTKey: string;
|
}
|
||||||
messageTKey: string;
|
|
||||||
};
|
export interface SelfServeNotification {
|
||||||
success: {
|
message: string;
|
||||||
titleTKey: string;
|
type: SelfServeNotificationType;
|
||||||
messageTKey: string;
|
|
||||||
};
|
|
||||||
failure: {
|
|
||||||
titleTKey: string;
|
|
||||||
messageTKey: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RefreshResult {
|
export interface RefreshResult {
|
||||||
isUpdateInProgress: boolean;
|
isUpdateInProgress: boolean;
|
||||||
updateInProgressMessageTKey: string;
|
notificationMessage: string;
|
||||||
}
|
|
||||||
|
|
||||||
export interface RefreshParams {
|
|
||||||
retryIntervalInMs: number;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { NumberUiType, OnSaveResult, RefreshResult, SelfServeBaseClass, SmartUiInput } from "./SelfServeTypes";
|
import { NumberUiType, RefreshResult, SelfServeBaseClass, SelfServeNotification, SmartUiInput } from "./SelfServeTypes";
|
||||||
import { DecoratorProperties, mapToSmartUiDescriptor, updateContextWithDecorator } from "./SelfServeUtils";
|
import { DecoratorProperties, mapToSmartUiDescriptor, updateContextWithDecorator } from "./SelfServeUtils";
|
||||||
|
|
||||||
describe("SelfServeUtils", () => {
|
describe("SelfServeUtils", () => {
|
||||||
it("initialize should be declared for self serve classes", () => {
|
it("initialize should be declared for self serve classes", () => {
|
||||||
class Test extends SelfServeBaseClass {
|
class Test extends SelfServeBaseClass {
|
||||||
public initialize: () => Promise<Map<string, SmartUiInput>>;
|
public initialize: () => Promise<Map<string, SmartUiInput>>;
|
||||||
public onSave: (currentValues: Map<string, SmartUiInput>) => Promise<OnSaveResult>;
|
public onSave: (currentValues: Map<string, SmartUiInput>) => Promise<SelfServeNotification>;
|
||||||
public onRefresh: () => Promise<RefreshResult>;
|
public onRefresh: () => Promise<RefreshResult>;
|
||||||
}
|
}
|
||||||
expect(() => new Test().toSelfServeDescriptor()).toThrow("initialize() was not declared for the class 'Test'");
|
expect(() => new Test().toSelfServeDescriptor()).toThrow("initialize() was not declared for the class 'Test'");
|
||||||
@@ -14,7 +14,7 @@ describe("SelfServeUtils", () => {
|
|||||||
it("onSave should be declared for self serve classes", () => {
|
it("onSave should be declared for self serve classes", () => {
|
||||||
class Test extends SelfServeBaseClass {
|
class Test extends SelfServeBaseClass {
|
||||||
public initialize = jest.fn();
|
public initialize = jest.fn();
|
||||||
public onSave: () => Promise<OnSaveResult>;
|
public onSave: () => Promise<SelfServeNotification>;
|
||||||
public onRefresh: () => Promise<RefreshResult>;
|
public onRefresh: () => Promise<RefreshResult>;
|
||||||
}
|
}
|
||||||
expect(() => new Test().toSelfServeDescriptor()).toThrow("onSave() was not declared for the class 'Test'");
|
expect(() => new Test().toSelfServeDescriptor()).toThrow("onSave() was not declared for the class 'Test'");
|
||||||
@@ -29,14 +29,14 @@ describe("SelfServeUtils", () => {
|
|||||||
expect(() => new Test().toSelfServeDescriptor()).toThrow("onRefresh() was not declared for the class 'Test'");
|
expect(() => new Test().toSelfServeDescriptor()).toThrow("onRefresh() was not declared for the class 'Test'");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("@IsDisplayable decorator must be present for self serve classes", () => {
|
it("@SmartUi decorator must be present for self serve classes", () => {
|
||||||
class Test extends SelfServeBaseClass {
|
class Test extends SelfServeBaseClass {
|
||||||
public initialize = jest.fn();
|
public initialize = jest.fn();
|
||||||
public onSave = jest.fn();
|
public onSave = jest.fn();
|
||||||
public onRefresh = jest.fn();
|
public onRefresh = jest.fn();
|
||||||
}
|
}
|
||||||
expect(() => new Test().toSelfServeDescriptor()).toThrow(
|
expect(() => new Test().toSelfServeDescriptor()).toThrow(
|
||||||
"@IsDisplayable decorator was not declared for the class 'Test'"
|
"@SmartUi decorator was not declared for the class 'Test'"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { MessageBarType } from "office-ui-fabric-react";
|
||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import {
|
import {
|
||||||
Node,
|
Node,
|
||||||
@@ -14,9 +15,8 @@ import {
|
|||||||
SelfServeDescriptor,
|
SelfServeDescriptor,
|
||||||
SmartUiInput,
|
SmartUiInput,
|
||||||
StringInput,
|
StringInput,
|
||||||
RefreshParams,
|
SelfServeNotificationType,
|
||||||
} from "./SelfServeTypes";
|
} from "./SelfServeTypes";
|
||||||
import { userContext } from "../UserContext";
|
|
||||||
|
|
||||||
export enum SelfServeType {
|
export enum SelfServeType {
|
||||||
// No self serve type passed, launch explorer
|
// No self serve type passed, launch explorer
|
||||||
@@ -28,14 +28,6 @@ export enum SelfServeType {
|
|||||||
sqlx = "sqlx",
|
sqlx = "sqlx",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum BladeType {
|
|
||||||
SqlKeys = "keys",
|
|
||||||
MongoKeys = "mongoDbKeys",
|
|
||||||
CassandraKeys = "cassandraDbKeys",
|
|
||||||
GremlinKeys = "keys",
|
|
||||||
TableKeys = "tableKeys",
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DecoratorProperties {
|
export interface DecoratorProperties {
|
||||||
id: string;
|
id: string;
|
||||||
info?: (() => Promise<Info>) | Info;
|
info?: (() => Promise<Info>) | Info;
|
||||||
@@ -52,13 +44,9 @@ export interface DecoratorProperties {
|
|||||||
uiType?: string;
|
uiType?: string;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
description?: (() => Promise<Description>) | Description;
|
description?: (() => Promise<Description>) | Description;
|
||||||
isDynamicDescription?: boolean;
|
onChange?: (currentState: Map<string, SmartUiInput>, newValue: InputType) => Map<string, SmartUiInput>;
|
||||||
refreshParams?: RefreshParams;
|
onSave?: (currentValues: Map<string, SmartUiInput>) => Promise<void>;
|
||||||
onChange?: (
|
initialize?: () => Promise<Map<string, SmartUiInput>>;
|
||||||
newValue: InputType,
|
|
||||||
currentState: Map<string, SmartUiInput>,
|
|
||||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
|
||||||
) => Map<string, SmartUiInput>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setValue = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
const setValue = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
||||||
@@ -95,7 +83,7 @@ export const updateContextWithDecorator = <T extends keyof DecoratorProperties,
|
|||||||
descriptorValue: K
|
descriptorValue: K
|
||||||
): void => {
|
): void => {
|
||||||
if (!(context instanceof Map)) {
|
if (!(context instanceof Map)) {
|
||||||
throw new Error(`@IsDisplayable should be the first decorator for the class '${className}'.`);
|
throw new Error(`@SmartUi should be the first decorator for the class '${className}'.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const propertyObject = context.get(propertyName) ?? { id: propertyName };
|
const propertyObject = context.get(propertyName) ?? { id: propertyName };
|
||||||
@@ -120,17 +108,16 @@ export const mapToSmartUiDescriptor = (
|
|||||||
className: string,
|
className: string,
|
||||||
context: Map<string, DecoratorProperties>
|
context: Map<string, DecoratorProperties>
|
||||||
): SelfServeDescriptor => {
|
): SelfServeDescriptor => {
|
||||||
const inputNames: string[] = [];
|
|
||||||
const root = context.get("root");
|
const root = context.get("root");
|
||||||
context.delete("root");
|
context.delete("root");
|
||||||
|
const inputNames: string[] = [];
|
||||||
|
|
||||||
const smartUiDescriptor: SelfServeDescriptor = {
|
const smartUiDescriptor: SelfServeDescriptor = {
|
||||||
root: {
|
root: {
|
||||||
id: className,
|
id: className,
|
||||||
info: undefined,
|
info: root?.info,
|
||||||
children: [],
|
children: [],
|
||||||
},
|
},
|
||||||
refreshParams: root?.refreshParams,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while (context.size > 0) {
|
while (context.size > 0) {
|
||||||
@@ -168,10 +155,7 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
|
|||||||
}
|
}
|
||||||
return value as NumberInput;
|
return value as NumberInput;
|
||||||
case "string":
|
case "string":
|
||||||
if (value.description || value.isDynamicDescription) {
|
if (value.description) {
|
||||||
if (value.description && value.isDynamicDescription) {
|
|
||||||
value.errorMessage = `dynamic descriptions should not have defaults set here.`;
|
|
||||||
}
|
|
||||||
return value as DescriptionDisplay;
|
return value as DescriptionDisplay;
|
||||||
}
|
}
|
||||||
if (!value.labelTKey) {
|
if (!value.labelTKey) {
|
||||||
@@ -191,9 +175,13 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generateBladeLink = (blade: BladeType): string => {
|
export const getMessageBarType = (type: SelfServeNotificationType): MessageBarType => {
|
||||||
const subscriptionId = userContext.subscriptionId;
|
switch (type) {
|
||||||
const resourceGroupName = userContext.resourceGroup;
|
case SelfServeNotificationType.info:
|
||||||
const databaseAccountName = userContext.databaseAccount.name;
|
return MessageBarType.info;
|
||||||
return `www.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDb/databaseAccounts/${databaseAccountName}/${blade}`;
|
case SelfServeNotificationType.warning:
|
||||||
|
return MessageBarType.warning;
|
||||||
|
case SelfServeNotificationType.error:
|
||||||
|
return MessageBarType.error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
import { IsDisplayable, OnChange, Values } from "../Decorators";
|
import { IsDisplayable, OnChange, Values } from "../Decorators";
|
||||||
import {
|
import {
|
||||||
ChoiceItem,
|
ChoiceItem,
|
||||||
DescriptionType,
|
|
||||||
InputType,
|
InputType,
|
||||||
NumberUiType,
|
NumberUiType,
|
||||||
OnSaveResult,
|
|
||||||
RefreshResult,
|
RefreshResult,
|
||||||
SelfServeBaseClass,
|
SelfServeBaseClass,
|
||||||
|
SelfServeNotification,
|
||||||
SmartUiInput,
|
SmartUiInput,
|
||||||
} from "../SelfServeTypes";
|
} from "../SelfServeTypes";
|
||||||
import { refreshDedicatedGatewayProvisioning } from "./SqlX.rp";
|
import { refreshDedicatedGatewayProvisioning } from "./SqlX.rp";
|
||||||
|
|
||||||
const onEnableDedicatedGatewayChange = (
|
const onEnableDedicatedGatewayChange = (
|
||||||
newValue: InputType,
|
currentState: Map<string, SmartUiInput>,
|
||||||
currentState: Map<string, SmartUiInput>
|
newValue: InputType
|
||||||
): Map<string, SmartUiInput> => {
|
): Map<string, SmartUiInput> => {
|
||||||
const sku = currentState.get("sku");
|
const sku = currentState.get("sku");
|
||||||
const instances = currentState.get("instances");
|
const instances = currentState.get("instances");
|
||||||
@@ -50,7 +49,7 @@ export default class SqlX extends SelfServeBaseClass {
|
|||||||
return refreshDedicatedGatewayProvisioning();
|
return refreshDedicatedGatewayProvisioning();
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSave = async (currentValues: Map<string, SmartUiInput>): Promise<OnSaveResult> => {
|
public onSave = async (currentValues: Map<string, SmartUiInput>): Promise<SelfServeNotification> => {
|
||||||
validate(currentValues);
|
validate(currentValues);
|
||||||
// TODO: add pre processing logic before calling the updateDedicatedGatewayProvisioning() RP call.
|
// TODO: add pre processing logic before calling the updateDedicatedGatewayProvisioning() RP call.
|
||||||
throw new Error(`onSave not implemented. No. of properties to save: ${currentValues.size}`);
|
throw new Error(`onSave not implemented. No. of properties to save: ${currentValues.size}`);
|
||||||
@@ -64,7 +63,6 @@ export default class SqlX extends SelfServeBaseClass {
|
|||||||
@Values({
|
@Values({
|
||||||
description: {
|
description: {
|
||||||
textTKey: "Provisioning dedicated gateways for SqlX accounts.",
|
textTKey: "Provisioning dedicated gateways for SqlX accounts.",
|
||||||
type: DescriptionType.Text,
|
|
||||||
link: {
|
link: {
|
||||||
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
||||||
textTKey: "Learn more about dedicated gateway.",
|
textTKey: "Learn more about dedicated gateway.",
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="selfServeViewport" content="height=device-height, width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Self Serve</title>
|
|
||||||
<link rel="shortcut icon" href="images/CosmosDB_rgb_ui_lighttheme.ico" type="image/x-icon" />
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="selfServeComponentContainer" id="selfServeContent"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as StringUtility from "./StringUtility";
|
import { StringUtility } from "./StringUtility";
|
||||||
|
|
||||||
export class LocalStorageUtility {
|
export class LocalStorageUtility {
|
||||||
public static hasItem(key: StorageKey): boolean {
|
public static hasItem(key: StorageKey): boolean {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as StringUtility from "./StringUtility";
|
import { StringUtility } from "./StringUtility";
|
||||||
|
|
||||||
describe("String utility", () => {
|
describe("String utility", () => {
|
||||||
it("Convert to integer from string", () => {
|
it("Convert to integer from string", () => {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
export function toNumber(num: string | null): number {
|
export class StringUtility {
|
||||||
return Number(num);
|
public static toNumber(num: string | null): number {
|
||||||
}
|
return Number(num);
|
||||||
|
}
|
||||||
|
|
||||||
export function toBoolean(valueStr: string | null): boolean {
|
public static toBoolean(valueStr: string | null): boolean {
|
||||||
return valueStr === "true";
|
return valueStr === "true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,43 +17,12 @@ interface UserContext {
|
|||||||
useSDKOperations?: boolean;
|
useSDKOperations?: boolean;
|
||||||
subscriptionType?: SubscriptionType;
|
subscriptionType?: SubscriptionType;
|
||||||
quotaId?: string;
|
quotaId?: string;
|
||||||
// API Type is not yet provided by ARM. You need to manually inspect all the capabilities+kind so we abstract that logic in userContext
|
|
||||||
// This is coming in a future Cosmos ARM API version as a prperty on databaseAccount
|
|
||||||
apiType?: ApiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
const userContext: Readonly<UserContext> = {} as const;
|
||||||
|
|
||||||
const userContext: UserContext = {};
|
|
||||||
|
|
||||||
function updateUserContext(newContext: UserContext): void {
|
function updateUserContext(newContext: UserContext): void {
|
||||||
Object.assign(userContext, newContext);
|
Object.assign(userContext, newContext);
|
||||||
Object.assign(userContext, { apiType: apiType(userContext.databaseAccount) });
|
|
||||||
}
|
|
||||||
|
|
||||||
function apiType(account: DatabaseAccount | undefined): ApiType {
|
|
||||||
if (!account) {
|
|
||||||
return "SQL";
|
|
||||||
}
|
|
||||||
const capabilities = account.properties?.capabilities;
|
|
||||||
if (capabilities) {
|
|
||||||
if (capabilities.find((c) => c.name === "EnableCassandra")) {
|
|
||||||
return "Cassandra";
|
|
||||||
}
|
|
||||||
if (capabilities.find((c) => c.name === "EnableGremlin")) {
|
|
||||||
return "Gremlin";
|
|
||||||
}
|
|
||||||
if (capabilities.find((c) => c.name === "EnableMongo")) {
|
|
||||||
return "Mongo";
|
|
||||||
}
|
|
||||||
if (capabilities.find((c) => c.name === "EnableTable")) {
|
|
||||||
return "Tables";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (account.kind === "MongoDB" || account.kind === "Parse") {
|
|
||||||
return "Mongo";
|
|
||||||
}
|
|
||||||
return "SQL";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { userContext, updateUserContext };
|
export { userContext, updateUserContext };
|
||||||
|
|||||||
@@ -8,81 +8,85 @@ interface KernelConnectionMetadata {
|
|||||||
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
|
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const _configureServiceEndpoints = async (kernelMetadata: KernelConnectionMetadata): Promise<void> => {
|
export class NotebookConfigurationUtils {
|
||||||
if (!kernelMetadata) {
|
private constructor() {}
|
||||||
// should never get into this state
|
|
||||||
Logger.logWarning("kernel metadata is null or undefined", "NotebookConfigurationUtils/configureServiceEndpoints");
|
public static async configureServiceEndpoints(
|
||||||
return;
|
notebookPath: string,
|
||||||
|
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo,
|
||||||
|
kernelName: string,
|
||||||
|
clusterConnectionInfo: DataModels.SparkClusterConnectionInfo
|
||||||
|
): Promise<void> {
|
||||||
|
if (!notebookPath || !notebookConnectionInfo || !kernelName) {
|
||||||
|
Logger.logError(
|
||||||
|
"Invalid or missing notebook connection info/path",
|
||||||
|
"NotebookConfigurationUtils/configureServiceEndpoints"
|
||||||
|
);
|
||||||
|
return Promise.reject("Invalid or missing notebook connection info");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!clusterConnectionInfo || !clusterConnectionInfo.endpoints || clusterConnectionInfo.endpoints.length === 0) {
|
||||||
|
Logger.logError(
|
||||||
|
"Invalid or missing cluster connection info/endpoints",
|
||||||
|
"NotebookConfigurationUtils/configureServiceEndpoints"
|
||||||
|
);
|
||||||
|
return Promise.reject("Invalid or missing cluster connection info");
|
||||||
|
}
|
||||||
|
|
||||||
|
const dataExplorer = window.dataExplorer;
|
||||||
|
const notebookEndpointInfo: DataModels.NotebookConfigurationEndpointInfo[] = clusterConnectionInfo.endpoints.map(
|
||||||
|
(clusterEndpoint) => ({
|
||||||
|
type: clusterEndpoint.kind.toLowerCase(),
|
||||||
|
endpoint: clusterEndpoint && clusterEndpoint.endpoint,
|
||||||
|
username: clusterConnectionInfo.userName,
|
||||||
|
password: clusterConnectionInfo.password,
|
||||||
|
token: dataExplorer && dataExplorer.arcadiaToken(),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const configurationEndpoints: DataModels.NotebookConfigurationEndpoints = {
|
||||||
|
path: notebookPath,
|
||||||
|
endpoints: notebookEndpointInfo,
|
||||||
|
};
|
||||||
|
const kernelMetadata: KernelConnectionMetadata = {
|
||||||
|
configurationEndpoints,
|
||||||
|
notebookConnectionInfo,
|
||||||
|
name: kernelName,
|
||||||
|
};
|
||||||
|
|
||||||
|
return await NotebookConfigurationUtils._configureServiceEndpoints(kernelMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
const notebookConnectionInfo = kernelMetadata.notebookConnectionInfo;
|
private static async _configureServiceEndpoints(kernelMetadata: KernelConnectionMetadata): Promise<void> {
|
||||||
const configurationEndpoints = kernelMetadata.configurationEndpoints;
|
if (!kernelMetadata) {
|
||||||
if (notebookConnectionInfo && configurationEndpoints) {
|
// should never get into this state
|
||||||
try {
|
Logger.logWarning("kernel metadata is null or undefined", "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||||
const headers: HeadersInit = { "Content-Type": "application/json" };
|
return;
|
||||||
if (notebookConnectionInfo.authToken) {
|
}
|
||||||
headers["Authorization"] = `token ${notebookConnectionInfo.authToken}`;
|
|
||||||
|
const notebookConnectionInfo = kernelMetadata.notebookConnectionInfo;
|
||||||
|
const configurationEndpoints = kernelMetadata.configurationEndpoints;
|
||||||
|
if (notebookConnectionInfo && configurationEndpoints) {
|
||||||
|
try {
|
||||||
|
const headers: any = { "Content-Type": "application/json" };
|
||||||
|
if (notebookConnectionInfo.authToken) {
|
||||||
|
headers["Authorization"] = `token ${notebookConnectionInfo.authToken}`;
|
||||||
|
}
|
||||||
|
const response = await fetch(`${notebookConnectionInfo.notebookServerEndpoint}/api/configureEndpoints`, {
|
||||||
|
method: "POST",
|
||||||
|
headers,
|
||||||
|
body: JSON.stringify(configurationEndpoints),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const responseMessage = await response.json();
|
||||||
|
Logger.logError(
|
||||||
|
getErrorMessage(responseMessage),
|
||||||
|
"NotebookConfigurationUtils/configureServiceEndpoints",
|
||||||
|
response.status
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Logger.logError(getErrorMessage(error), "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||||
}
|
}
|
||||||
const response = await fetch(`${notebookConnectionInfo.notebookServerEndpoint}/api/configureEndpoints`, {
|
|
||||||
method: "POST",
|
|
||||||
headers,
|
|
||||||
body: JSON.stringify(configurationEndpoints),
|
|
||||||
});
|
|
||||||
if (!response.ok) {
|
|
||||||
const responseMessage = await response.json();
|
|
||||||
Logger.logError(
|
|
||||||
getErrorMessage(responseMessage),
|
|
||||||
"NotebookConfigurationUtils/configureServiceEndpoints",
|
|
||||||
response.status
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
Logger.logError(getErrorMessage(error), "NotebookConfigurationUtils/configureServiceEndpoints");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export const configureServiceEndpoints = async (
|
|
||||||
notebookPath: string,
|
|
||||||
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo,
|
|
||||||
kernelName: string,
|
|
||||||
clusterConnectionInfo: DataModels.SparkClusterConnectionInfo
|
|
||||||
): Promise<void> => {
|
|
||||||
if (!notebookPath || !notebookConnectionInfo || !kernelName) {
|
|
||||||
Logger.logError(
|
|
||||||
"Invalid or missing notebook connection info/path",
|
|
||||||
"NotebookConfigurationUtils/configureServiceEndpoints"
|
|
||||||
);
|
|
||||||
return Promise.reject("Invalid or missing notebook connection info");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clusterConnectionInfo || !clusterConnectionInfo.endpoints || clusterConnectionInfo.endpoints.length === 0) {
|
|
||||||
Logger.logError(
|
|
||||||
"Invalid or missing cluster connection info/endpoints",
|
|
||||||
"NotebookConfigurationUtils/configureServiceEndpoints"
|
|
||||||
);
|
|
||||||
return Promise.reject("Invalid or missing cluster connection info");
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataExplorer = window.dataExplorer;
|
|
||||||
const notebookEndpointInfo: DataModels.NotebookConfigurationEndpointInfo[] = clusterConnectionInfo.endpoints.map(
|
|
||||||
(clusterEndpoint) => ({
|
|
||||||
type: clusterEndpoint.kind.toLowerCase(),
|
|
||||||
endpoint: clusterEndpoint && clusterEndpoint.endpoint,
|
|
||||||
username: clusterConnectionInfo.userName,
|
|
||||||
password: clusterConnectionInfo.password,
|
|
||||||
token: dataExplorer && dataExplorer.arcadiaToken(),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
const configurationEndpoints: DataModels.NotebookConfigurationEndpoints = {
|
|
||||||
path: notebookPath,
|
|
||||||
endpoints: notebookEndpointInfo,
|
|
||||||
};
|
|
||||||
const kernelMetadata: KernelConnectionMetadata = {
|
|
||||||
configurationEndpoints,
|
|
||||||
notebookConnectionInfo,
|
|
||||||
name: kernelName,
|
|
||||||
};
|
|
||||||
|
|
||||||
return await _configureServiceEndpoints(kernelMetadata);
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -47,14 +47,15 @@ interface Options {
|
|||||||
queryParams?: ARMQueryParams;
|
queryParams?: ARMQueryParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function armRequestWithoutPolling<T>({
|
// TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them.
|
||||||
|
export async function armRequest<T>({
|
||||||
host,
|
host,
|
||||||
path,
|
path,
|
||||||
apiVersion,
|
apiVersion,
|
||||||
method,
|
method,
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
queryParams,
|
queryParams,
|
||||||
}: Options): Promise<{ result: T; operationStatusUrl: string }> {
|
}: Options): Promise<T> {
|
||||||
const url = new URL(path, host);
|
const url = new URL(path, host);
|
||||||
url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion);
|
url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion);
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
@@ -91,33 +92,13 @@ export async function armRequestWithoutPolling<T>({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const operationStatusUrl = (response.headers && response.headers.get("location")) || "";
|
const operationStatusUrl = response.headers && response.headers.get("location");
|
||||||
const responseBody = (await response.json()) as T;
|
|
||||||
return { result: responseBody, operationStatusUrl: operationStatusUrl };
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them.
|
|
||||||
export async function armRequest<T>({
|
|
||||||
host,
|
|
||||||
path,
|
|
||||||
apiVersion,
|
|
||||||
method,
|
|
||||||
body: requestBody,
|
|
||||||
queryParams,
|
|
||||||
}: Options): Promise<T> {
|
|
||||||
const armRequestResult = await armRequestWithoutPolling<T>({
|
|
||||||
host,
|
|
||||||
path,
|
|
||||||
apiVersion,
|
|
||||||
method,
|
|
||||||
body: requestBody,
|
|
||||||
queryParams,
|
|
||||||
});
|
|
||||||
const operationStatusUrl = armRequestResult.operationStatusUrl;
|
|
||||||
if (operationStatusUrl) {
|
if (operationStatusUrl) {
|
||||||
return await promiseRetry(() => getOperationStatus(operationStatusUrl));
|
return await promiseRetry(() => getOperationStatus(operationStatusUrl));
|
||||||
}
|
}
|
||||||
return armRequestResult.result;
|
|
||||||
|
const responseBody = (await response.json()) as T;
|
||||||
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOperationStatus(operationStatusUrl: string) {
|
async function getOperationStatus(operationStatusUrl: string) {
|
||||||
|
|||||||
13
src/global.d.ts
vendored
13
src/global.d.ts
vendored
@@ -1,22 +1,11 @@
|
|||||||
|
import { AuthType } from "./AuthType";
|
||||||
import Explorer from "./Explorer/Explorer";
|
import Explorer from "./Explorer/Explorer";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* DO NOT take new usage of window.dataExplorer. If you must use Explorer, find it directly.
|
|
||||||
* */
|
|
||||||
dataExplorer: Explorer;
|
dataExplorer: Explorer;
|
||||||
__REACT_DEVTOOLS_GLOBAL_HOOK__: any;
|
__REACT_DEVTOOLS_GLOBAL_HOOK__: any;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* No new usage of jQuery ($)
|
|
||||||
* */
|
|
||||||
$: any;
|
$: any;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* No new usage of jQuery
|
|
||||||
* */
|
|
||||||
jQuery: any;
|
jQuery: any;
|
||||||
gitSha: string;
|
gitSha: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import Explorer from "../Explorer/Explorer";
|
|
||||||
|
|
||||||
export interface ExplorerStateProperties {
|
|
||||||
commandBarProperties: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useExplorerState = (container: Explorer): ExplorerStateProperties => {
|
|
||||||
const [isPanelOpen, setIsPanelOpen] = useState<boolean>(false);
|
|
||||||
|
|
||||||
|
|
||||||
return {};
|
|
||||||
};
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
import { applyExplorerBindings } from "../applyExplorerBindings";
|
import { applyExplorerBindings } from "../applyExplorerBindings";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { AccountKind, DefaultAccountExperience } from "../Common/Constants";
|
import { AccountKind, DefaultAccountExperience } from "../Common/Constants";
|
||||||
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
|
||||||
import { sendMessage } from "../Common/MessageHandler";
|
import { sendMessage } from "../Common/MessageHandler";
|
||||||
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
import { configContext, Platform } from "../ConfigContext";
|
||||||
import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
|
import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
import { DataExplorerInputsFrame } from "../Contracts/ViewModels";
|
import { DataExplorerInputsFrame } from "../Contracts/ViewModels";
|
||||||
@@ -24,6 +23,7 @@ import {
|
|||||||
getDatabaseAccountKindFromExperience,
|
getDatabaseAccountKindFromExperience,
|
||||||
getDatabaseAccountPropertiesFromMetadata,
|
getDatabaseAccountPropertiesFromMetadata,
|
||||||
} from "../Platform/Hosted/HostedUtils";
|
} from "../Platform/Hosted/HostedUtils";
|
||||||
|
import { SelfServeType } from "../SelfServe/SelfServeUtils";
|
||||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||||
import { updateUserContext } from "../UserContext";
|
import { updateUserContext } from "../UserContext";
|
||||||
import { listKeys } from "../Utils/arm/generatedClients/2020-04-01/databaseAccounts";
|
import { listKeys } from "../Utils/arm/generatedClients/2020-04-01/databaseAccounts";
|
||||||
@@ -32,65 +32,54 @@ import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation";
|
|||||||
// This hook will create a new instance of Explorer.ts and bind it to the DOM
|
// This hook will create a new instance of Explorer.ts and bind it to the DOM
|
||||||
// This hook has a LOT of magic, but ideally we can delete it once we have removed KO and switched entirely to React
|
// This hook has a LOT of magic, but ideally we can delete it once we have removed KO and switched entirely to React
|
||||||
// Pleas tread carefully :)
|
// Pleas tread carefully :)
|
||||||
|
let explorer: Explorer;
|
||||||
|
|
||||||
export function useKnockoutExplorer(platform: Platform, explorerParams: ExplorerParams): Explorer {
|
export function useKnockoutExplorer(platform: Platform, explorerParams: ExplorerParams): Explorer {
|
||||||
const [explorer, setExplorer] = useState<Explorer>();
|
explorer = explorer || new Explorer(explorerParams);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const effect = async () => {
|
const effect = async () => {
|
||||||
if (platform) {
|
if (platform) {
|
||||||
if (platform === Platform.Hosted) {
|
if (platform === Platform.Hosted) {
|
||||||
const explorer = await configureHosted(explorerParams);
|
await configureHosted();
|
||||||
setExplorer(explorer);
|
applyExplorerBindings(explorer);
|
||||||
} else if (platform === Platform.Emulator) {
|
} else if (platform === Platform.Emulator) {
|
||||||
const explorer = configureEmulator(explorerParams);
|
configureEmulator();
|
||||||
setExplorer(explorer);
|
applyExplorerBindings(explorer);
|
||||||
} else if (platform === Platform.Portal) {
|
} else if (platform === Platform.Portal) {
|
||||||
const explorer = await configurePortal(explorerParams);
|
configurePortal();
|
||||||
setExplorer(explorer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
effect();
|
effect();
|
||||||
}, [platform]);
|
}, [platform]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (explorer) {
|
|
||||||
applyExplorerBindings(explorer);
|
|
||||||
}
|
|
||||||
}, [explorer]);
|
|
||||||
|
|
||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function configureHosted(explorerParams: ExplorerParams): Promise<Explorer> {
|
async function configureHosted() {
|
||||||
const win = (window as unknown) as HostedExplorerChildFrame;
|
const win = (window as unknown) as HostedExplorerChildFrame;
|
||||||
|
explorer.selfServeType(SelfServeType.none);
|
||||||
if (win.hostedConfig.authType === AuthType.EncryptedToken) {
|
if (win.hostedConfig.authType === AuthType.EncryptedToken) {
|
||||||
return configureHostedWithEncryptedToken(win.hostedConfig, explorerParams);
|
configureHostedWithEncryptedToken(win.hostedConfig);
|
||||||
} else if (win.hostedConfig.authType === AuthType.ResourceToken) {
|
} else if (win.hostedConfig.authType === AuthType.ResourceToken) {
|
||||||
return configureHostedWithResourceToken(win.hostedConfig, explorerParams);
|
configureHostedWithResourceToken(win.hostedConfig);
|
||||||
} else if (win.hostedConfig.authType === AuthType.ConnectionString) {
|
} else if (win.hostedConfig.authType === AuthType.ConnectionString) {
|
||||||
return configureHostedWithConnectionString(win.hostedConfig, explorerParams);
|
configureHostedWithConnectionString(win.hostedConfig);
|
||||||
} else if (win.hostedConfig.authType === AuthType.AAD) {
|
} else if (win.hostedConfig.authType === AuthType.AAD) {
|
||||||
return configureHostedWithAAD(win.hostedConfig, explorerParams);
|
await configureHostedWithAAD(win.hostedConfig);
|
||||||
}
|
}
|
||||||
throw new Error(`Unknown hosted config: ${win.hostedConfig}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function configureHostedWithAAD(config: AAD, explorerParams: ExplorerParams): Promise<Explorer> {
|
async function configureHostedWithAAD(config: AAD) {
|
||||||
const account = config.databaseAccount;
|
const account = config.databaseAccount;
|
||||||
const accountResourceId = account.id;
|
const accountResourceId = account.id;
|
||||||
const subscriptionId = accountResourceId && accountResourceId.split("subscriptions/")[1].split("/")[0];
|
const subscriptionId = accountResourceId && accountResourceId.split("subscriptions/")[1].split("/")[0];
|
||||||
const resourceGroup = accountResourceId && accountResourceId.split("resourceGroups/")[1].split("/")[0];
|
const resourceGroup = accountResourceId && accountResourceId.split("resourceGroups/")[1].split("/")[0];
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
subscriptionId,
|
|
||||||
resourceGroup,
|
|
||||||
authType: AuthType.AAD,
|
authType: AuthType.AAD,
|
||||||
authorizationToken: `Bearer ${config.authorizationToken}`,
|
authorizationToken: `Bearer ${config.authorizationToken}`,
|
||||||
databaseAccount: config.databaseAccount,
|
databaseAccount: config.databaseAccount,
|
||||||
});
|
});
|
||||||
const keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
const keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
const explorer = new Explorer(explorerParams);
|
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount: account,
|
databaseAccount: account,
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
@@ -99,69 +88,56 @@ async function configureHostedWithAAD(config: AAD, explorerParams: ExplorerParam
|
|||||||
authorizationToken: `Bearer ${config.authorizationToken}`,
|
authorizationToken: `Bearer ${config.authorizationToken}`,
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
});
|
});
|
||||||
return explorer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureHostedWithConnectionString(config: ConnectionString, explorerParams: ExplorerParams): Explorer {
|
function configureHostedWithConnectionString(config: ConnectionString) {
|
||||||
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
|
||||||
const databaseAccount = {
|
|
||||||
id: "",
|
|
||||||
location: "",
|
|
||||||
type: "",
|
|
||||||
name: config.encryptedTokenMetadata.accountName,
|
|
||||||
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
|
||||||
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
|
||||||
tags: {},
|
|
||||||
};
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
// For legacy reasons lots of code expects a connection string login to look and act like an encrypted token login
|
// For legacy reasons lots of code expects a connection string login to look and act like an encrypted token login
|
||||||
authType: AuthType.EncryptedToken,
|
authType: AuthType.EncryptedToken,
|
||||||
accessToken: encodeURIComponent(config.encryptedToken),
|
accessToken: encodeURIComponent(config.encryptedToken),
|
||||||
databaseAccount,
|
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount,
|
databaseAccount: {
|
||||||
|
id: "",
|
||||||
|
name: config.encryptedTokenMetadata.accountName,
|
||||||
|
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
||||||
|
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
||||||
|
tags: {},
|
||||||
|
},
|
||||||
masterKey: config.masterKey,
|
masterKey: config.masterKey,
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
});
|
});
|
||||||
return explorer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureHostedWithResourceToken(config: ResourceToken, explorerParams: ExplorerParams): Explorer {
|
function configureHostedWithResourceToken(config: ResourceToken) {
|
||||||
const parsedResourceToken = parseResourceTokenConnectionString(config.resourceToken);
|
const parsedResourceToken = parseResourceTokenConnectionString(config.resourceToken);
|
||||||
const databaseAccount = {
|
|
||||||
id: "",
|
|
||||||
location: "",
|
|
||||||
type: "",
|
|
||||||
name: parsedResourceToken.accountEndpoint,
|
|
||||||
kind: AccountKind.GlobalDocumentDB,
|
|
||||||
properties: { documentEndpoint: parsedResourceToken.accountEndpoint },
|
|
||||||
// Resource tokens can only be used with SQL API
|
|
||||||
tags: { defaultExperience: DefaultAccountExperience.DocumentDB },
|
|
||||||
};
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount,
|
|
||||||
authType: AuthType.ResourceToken,
|
authType: AuthType.ResourceToken,
|
||||||
resourceToken: parsedResourceToken.resourceToken,
|
resourceToken: parsedResourceToken.resourceToken,
|
||||||
endpoint: parsedResourceToken.accountEndpoint,
|
endpoint: parsedResourceToken.accountEndpoint,
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
|
||||||
explorer.resourceTokenDatabaseId(parsedResourceToken.databaseId);
|
explorer.resourceTokenDatabaseId(parsedResourceToken.databaseId);
|
||||||
explorer.resourceTokenCollectionId(parsedResourceToken.collectionId);
|
explorer.resourceTokenCollectionId(parsedResourceToken.collectionId);
|
||||||
if (parsedResourceToken.partitionKey) {
|
if (parsedResourceToken.partitionKey) {
|
||||||
explorer.resourceTokenPartitionKey(parsedResourceToken.partitionKey);
|
explorer.resourceTokenPartitionKey(parsedResourceToken.partitionKey);
|
||||||
}
|
}
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount,
|
databaseAccount: {
|
||||||
|
id: "",
|
||||||
|
name: parsedResourceToken.accountEndpoint,
|
||||||
|
kind: AccountKind.GlobalDocumentDB,
|
||||||
|
properties: { documentEndpoint: parsedResourceToken.accountEndpoint },
|
||||||
|
// Resource tokens can only be used with SQL API
|
||||||
|
tags: { defaultExperience: DefaultAccountExperience.DocumentDB },
|
||||||
|
},
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
isAuthWithresourceToken: true,
|
isAuthWithresourceToken: true,
|
||||||
});
|
});
|
||||||
explorer.isRefreshingExplorer(false);
|
explorer.isRefreshingExplorer(false);
|
||||||
return explorer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParams: ExplorerParams): Explorer {
|
function configureHostedWithEncryptedToken(config: EncryptedToken) {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authType: AuthType.EncryptedToken,
|
authType: AuthType.EncryptedToken,
|
||||||
accessToken: encodeURIComponent(config.encryptedToken),
|
accessToken: encodeURIComponent(config.encryptedToken),
|
||||||
@@ -169,7 +145,6 @@ function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParam
|
|||||||
const apiExperience: string = DefaultExperienceUtility.getDefaultExperienceFromApiKind(
|
const apiExperience: string = DefaultExperienceUtility.getDefaultExperienceFromApiKind(
|
||||||
config.encryptedTokenMetadata.apiKind
|
config.encryptedTokenMetadata.apiKind
|
||||||
);
|
);
|
||||||
const explorer = new Explorer(explorerParams);
|
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount: {
|
databaseAccount: {
|
||||||
id: "",
|
id: "",
|
||||||
@@ -180,98 +155,72 @@ function configureHostedWithEncryptedToken(config: EncryptedToken, explorerParam
|
|||||||
},
|
},
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
});
|
});
|
||||||
return explorer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureEmulator(explorerParams: ExplorerParams): Explorer {
|
function configureEmulator() {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount: emulatorAccount,
|
|
||||||
authType: AuthType.MasterKey,
|
authType: AuthType.MasterKey,
|
||||||
});
|
});
|
||||||
const explorer = new Explorer(explorerParams);
|
explorer.selfServeType(SelfServeType.none);
|
||||||
explorer.databaseAccount(emulatorAccount);
|
explorer.databaseAccount(emulatorAccount);
|
||||||
explorer.isAccountReady(true);
|
explorer.isAccountReady(true);
|
||||||
return explorer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function configurePortal(explorerParams: ExplorerParams): Promise<Explorer> {
|
function configurePortal() {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authType: AuthType.AAD,
|
authType: AuthType.AAD,
|
||||||
});
|
});
|
||||||
return new Promise((resolve) => {
|
// In development mode, try to load the iframe message from session storage.
|
||||||
// In development mode, try to load the iframe message from session storage.
|
// This allows webpack hot reload to function properly in the portal
|
||||||
// This allows webpack hot reload to function properly in the portal
|
if (process.env.NODE_ENV === "development" && !window.location.search.includes("disablePortalInitCache")) {
|
||||||
if (process.env.NODE_ENV === "development" && !window.location.search.includes("disablePortalInitCache")) {
|
const initMessage = sessionStorage.getItem("portalDataExplorerInitMessage");
|
||||||
const initMessage = sessionStorage.getItem("portalDataExplorerInitMessage");
|
if (initMessage) {
|
||||||
if (initMessage) {
|
const message = JSON.parse(initMessage);
|
||||||
const message = JSON.parse(initMessage);
|
console.warn(
|
||||||
console.warn(
|
"Loaded cached portal iframe message from session storage. Do a full page refresh to get a new message"
|
||||||
"Loaded cached portal iframe message from session storage. Do a full page refresh to get a new message"
|
);
|
||||||
);
|
console.dir(message);
|
||||||
console.dir(message);
|
explorer.configure(message);
|
||||||
const explorer = new Explorer(explorerParams);
|
applyExplorerBindings(explorer);
|
||||||
explorer.configure(message);
|
|
||||||
resolve(explorer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In the Portal, configuration of Explorer happens via iframe message
|
// In the Portal, configuration of Explorer happens via iframe message
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
"message",
|
"message",
|
||||||
(event) => {
|
(event) => {
|
||||||
if (isInvalidParentFrameOrigin(event)) {
|
if (isInvalidParentFrameOrigin(event)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldProcessMessage(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for init message
|
||||||
|
const message: PortalMessage = event.data?.data;
|
||||||
|
const inputs = message?.inputs;
|
||||||
|
const openAction = message?.openAction;
|
||||||
|
if (inputs) {
|
||||||
|
if (
|
||||||
|
configContext.BACKEND_ENDPOINT &&
|
||||||
|
configContext.platform === Platform.Portal &&
|
||||||
|
process.env.NODE_ENV === "development"
|
||||||
|
) {
|
||||||
|
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldProcessMessage(event)) {
|
explorer.configure(inputs);
|
||||||
return;
|
applyExplorerBindings(explorer);
|
||||||
|
if (openAction) {
|
||||||
|
handleOpenAction(openAction, explorer.nonSystemDatabases(), explorer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
// Check for init message
|
sendMessage("ready");
|
||||||
const message: PortalMessage = event.data?.data;
|
|
||||||
const inputs = message?.inputs;
|
|
||||||
const openAction = message?.openAction;
|
|
||||||
if (inputs) {
|
|
||||||
if (
|
|
||||||
configContext.BACKEND_ENDPOINT &&
|
|
||||||
configContext.platform === Platform.Portal &&
|
|
||||||
process.env.NODE_ENV === "development"
|
|
||||||
) {
|
|
||||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
|
||||||
const masterKey = inputs.masterKey || "";
|
|
||||||
const databaseAccount = inputs.databaseAccount;
|
|
||||||
|
|
||||||
updateConfigContext({
|
|
||||||
BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT,
|
|
||||||
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
|
||||||
});
|
|
||||||
|
|
||||||
updateUserContext({
|
|
||||||
authorizationToken,
|
|
||||||
masterKey,
|
|
||||||
databaseAccount,
|
|
||||||
resourceGroup: inputs.resourceGroup,
|
|
||||||
subscriptionId: inputs.subscriptionId,
|
|
||||||
subscriptionType: inputs.subscriptionType,
|
|
||||||
quotaId: inputs.quotaId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const explorer = new Explorer(explorerParams);
|
|
||||||
explorer.configure(inputs);
|
|
||||||
resolve(explorer);
|
|
||||||
if (openAction) {
|
|
||||||
handleOpenAction(openAction, explorer.nonSystemDatabases(), explorer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
sendMessage("ready");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldProcessMessage(event: MessageEvent): boolean {
|
function shouldProcessMessage(event: MessageEvent): boolean {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import "expect-puppeteer";
|
import "expect-puppeteer";
|
||||||
import { createDatabase, generateUniqueName, onClickSaveButton } from "../utils/shared";
|
import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils";
|
||||||
|
import { createDatabase, onClickSaveButton } from "../utils/shared";
|
||||||
|
import { generateUniqueName } from "../utils/shared";
|
||||||
|
import { ApiKind } from "../../src/Contracts/DataModels";
|
||||||
|
|
||||||
const LOADING_STATE_DELAY = 5000;
|
const LOADING_STATE_DELAY = 5000;
|
||||||
jest.setTimeout(300000);
|
jest.setTimeout(300000);
|
||||||
@@ -9,9 +12,7 @@ describe("MongoDB Index policy tests", () => {
|
|||||||
try {
|
try {
|
||||||
const singleFieldId = generateUniqueName("key");
|
const singleFieldId = generateUniqueName("key");
|
||||||
const wildCardId = generateUniqueName("key") + "$**";
|
const wildCardId = generateUniqueName("key") + "$**";
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo-runner");
|
const frame = await getTestExplorerFrame(ApiKind.MongoDB);
|
||||||
const handle = await page.waitForSelector("iframe");
|
|
||||||
const frame = await handle.contentFrame();
|
|
||||||
const dropDown = "Index Type ";
|
const dropDown = "Index Type ";
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
@@ -19,18 +20,24 @@ describe("MongoDB Index policy tests", () => {
|
|||||||
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
||||||
await frame.waitFor(LOADING_STATE_DELAY);
|
await frame.waitFor(LOADING_STATE_DELAY);
|
||||||
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
||||||
const { databaseId, collectionId } = await createDatabase(frame);
|
const dbId = await createDatabase(frame);
|
||||||
await frame.waitFor(25000);
|
await frame.waitFor(25000);
|
||||||
// click on database
|
// click on database
|
||||||
await frame.waitForSelector(`div[data-test="${databaseId}"]`);
|
await frame.waitForSelector(`div[data-test="${dbId}"]`);
|
||||||
await frame.waitFor(LOADING_STATE_DELAY);
|
await frame.waitFor(LOADING_STATE_DELAY);
|
||||||
await frame.click(`div[data-test="${databaseId}"]`);
|
await frame.click(`div[data-test="${dbId}"]`);
|
||||||
await frame.waitFor(LOADING_STATE_DELAY);
|
await frame.waitFor(LOADING_STATE_DELAY);
|
||||||
|
|
||||||
// click on scale & setting
|
// click on scale & setting
|
||||||
await frame.waitFor(`div[data-test="${collectionId}"]`), { visible: true };
|
const containers = await frame.$$(
|
||||||
|
`div[class="nodeChildren"] > div[class="collectionHeader main2 nodeItem "]> div[class="treeNodeHeader "]`
|
||||||
|
);
|
||||||
|
const selectedContainer = (await frame.evaluate((element) => element.innerText, containers[0]))
|
||||||
|
.replace(/[\u{0080}-\u{FFFF}]/gu, "")
|
||||||
|
.trim();
|
||||||
|
await frame.waitFor(`div[data-test="${selectedContainer}"]`), { visible: true };
|
||||||
await frame.waitFor(LOADING_STATE_DELAY);
|
await frame.waitFor(LOADING_STATE_DELAY);
|
||||||
await frame.click(`div[data-test="${collectionId}"]`);
|
await frame.click(`div[data-test="${selectedContainer}"]`);
|
||||||
|
|
||||||
await frame.waitFor(`div[data-test="Scale & Settings"]`), { visible: true };
|
await frame.waitFor(`div[data-test="Scale & Settings"]`), { visible: true };
|
||||||
await frame.waitFor(LOADING_STATE_DELAY);
|
await frame.waitFor(LOADING_STATE_DELAY);
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
import { uploadNotebookIfNotExist } from "./notebookTestUtils";
|
import { uploadNotebookIfNotExist } from "./notebookTestUtils";
|
||||||
|
import { ElementHandle, Frame } from "puppeteer";
|
||||||
|
import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils";
|
||||||
|
|
||||||
jest.setTimeout(300000);
|
jest.setTimeout(300000);
|
||||||
|
|
||||||
const notebookName = "GettingStarted.ipynb";
|
const notebookName = "GettingStarted.ipynb";
|
||||||
|
let frame: Frame;
|
||||||
|
let uploadedNotebookNode: ElementHandle<Element>;
|
||||||
|
|
||||||
describe("Notebook UI tests", () => {
|
describe("Notebook UI tests", () => {
|
||||||
it("Upload, Open and Delete Notebook", async () => {
|
it("Upload, Open and Delete Notebook", async () => {
|
||||||
try {
|
try {
|
||||||
await page.goto("https://localhost:1234/testExplorer.html");
|
frame = await getTestExplorerFrame();
|
||||||
const handle = await page.waitForSelector("iframe");
|
|
||||||
const frame = await handle.contentFrame();
|
|
||||||
await frame.waitForSelector(".galleryHeader");
|
await frame.waitForSelector(".galleryHeader");
|
||||||
const uploadedNotebookNode = await uploadNotebookIfNotExist(frame, notebookName);
|
uploadedNotebookNode = await uploadNotebookIfNotExist(frame, notebookName);
|
||||||
await uploadedNotebookNode.click();
|
await uploadedNotebookNode.click();
|
||||||
await frame.waitForSelector(".tabNavText");
|
await frame.waitForSelector(".tabNavText");
|
||||||
const tabTitle = await frame.$eval(".tabNavText", (element) => element.textContent);
|
const tabTitle = await frame.$eval(".tabNavText", (element) => element.textContent);
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
|
import { Frame } from "puppeteer";
|
||||||
|
import { TestExplorerParams } from "../testExplorer/TestExplorerParams";
|
||||||
|
import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils";
|
||||||
|
import { SelfServeType } from "../../src/SelfServe/SelfServeUtils";
|
||||||
|
import { ApiKind } from "../../src/Contracts/DataModels";
|
||||||
|
|
||||||
jest.setTimeout(300000);
|
jest.setTimeout(300000);
|
||||||
|
|
||||||
|
let frame: Frame;
|
||||||
describe("Self Serve", () => {
|
describe("Self Serve", () => {
|
||||||
it("Launch Self Serve Example", async () => {
|
it("Launch Self Serve Example", async () => {
|
||||||
try {
|
try {
|
||||||
await page.goto("https://localhost:1234/testExplorer.html?iframeSrc=selfServe.html");
|
frame = await getTestExplorerFrame(
|
||||||
const handle = await page.waitForSelector("iframe");
|
ApiKind.SQL,
|
||||||
const frame = await handle.contentFrame();
|
new Map<string, string>([[TestExplorerParams.selfServeType, SelfServeType.example]])
|
||||||
|
);
|
||||||
|
|
||||||
// wait for refresh RP call to end
|
// wait for refresh RP call to end
|
||||||
await frame.waitFor(10000);
|
await frame.waitFor(10000);
|
||||||
|
|
||||||
// id of the display element is in the format {PROPERTY_NAME}-{DISPLAY_NAME}-{DISPLAY_TYPE}
|
// id of the display element is in the format {PROPERTY_NAME}-{DISPLAY_NAME}-{DISPLAY_TYPE}
|
||||||
await frame.waitForSelector("#description-text-display");
|
await frame.waitForSelector("#description-text-display");
|
||||||
await frame.waitForSelector("#currentRegionText-text-display");
|
|
||||||
|
|
||||||
const regions = await frame.waitForSelector("#regions-dropdown-input");
|
const regions = await frame.waitForSelector("#regions-dropdown-input");
|
||||||
let disabledLoggingToggle = await frame.$$("#enableLogging-toggle-input[disabled]");
|
let disabledLoggingToggle = await frame.$$("#enableLogging-toggle-input[disabled]");
|
||||||
|
|||||||
@@ -1,50 +1,82 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import { ClientSecretCredential } from "@azure/identity";
|
|
||||||
import "../../less/hostedexplorer.less";
|
import "../../less/hostedexplorer.less";
|
||||||
import { DataExplorerInputsFrame } from "../../src/Contracts/ViewModels";
|
import { TestExplorerParams } from "./TestExplorerParams";
|
||||||
import { updateUserContext } from "../../src/UserContext";
|
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||||
import { get, listKeys } from "../../src/Utils/arm/generatedClients/2020-04-01/databaseAccounts";
|
import * as msRest from "@azure/ms-rest-js";
|
||||||
|
import * as ViewModels from "../../src/Contracts/ViewModels";
|
||||||
|
import { Capability, DatabaseAccount } from "../../src/Contracts/DataModels";
|
||||||
|
|
||||||
const resourceGroup = process.env.RESOURCE_GROUP || "";
|
class CustomSigner implements msRest.ServiceClientCredentials {
|
||||||
const subscriptionId = process.env.SUBSCRIPTION_ID || "";
|
private token: string;
|
||||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
constructor(token: string) {
|
||||||
const accountName = urlSearchParams.get("accountName") || "portal-sql-runner";
|
this.token = token;
|
||||||
const selfServeType = urlSearchParams.get("selfServeType") || "example";
|
}
|
||||||
const iframeSrc = urlSearchParams.get("iframeSrc") || "explorer.html?platform=Portal&disablePortalInitCache";
|
|
||||||
|
|
||||||
if (!process.env.AZURE_CLIENT_SECRET) {
|
async signRequest(webResource: msRest.WebResourceLike): Promise<msRest.WebResourceLike> {
|
||||||
throw new Error(
|
webResource.headers.set("authorization", `bearer ${this.token}`);
|
||||||
"process.env.AZURE_CLIENT_SECRET was not set! Set it in your .env file and restart webpack dev server"
|
return webResource;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Azure SDK clients accept the credential as a parameter
|
const getDatabaseAccount = async (
|
||||||
const credentials = new ClientSecretCredential(
|
token: string,
|
||||||
process.env.AZURE_TENANT_ID,
|
notebooksAccountSubscriptonId: string,
|
||||||
process.env.AZURE_CLIENT_ID,
|
notebooksAccountResourceGroup: string,
|
||||||
process.env.AZURE_CLIENT_SECRET,
|
notebooksAccountName: string
|
||||||
{
|
): Promise<DatabaseAccount> => {
|
||||||
authorityHost: "https://localhost:1234",
|
const client = new CosmosDBManagementClient(new CustomSigner(token), notebooksAccountSubscriptonId);
|
||||||
}
|
const databaseAccountGetResponse = await client.databaseAccounts.get(
|
||||||
);
|
notebooksAccountResourceGroup,
|
||||||
|
notebooksAccountName
|
||||||
|
);
|
||||||
|
|
||||||
console.log("Resource Group:", resourceGroup);
|
const databaseAccount: DatabaseAccount = {
|
||||||
console.log("Subcription: ", subscriptionId);
|
id: databaseAccountGetResponse.id,
|
||||||
console.log("Account Name: ", accountName);
|
name: databaseAccountGetResponse.name,
|
||||||
|
location: databaseAccountGetResponse.location,
|
||||||
|
type: databaseAccountGetResponse.type,
|
||||||
|
kind: databaseAccountGetResponse.kind,
|
||||||
|
tags: databaseAccountGetResponse.tags,
|
||||||
|
properties: {
|
||||||
|
documentEndpoint: databaseAccountGetResponse.documentEndpoint,
|
||||||
|
tableEndpoint: undefined,
|
||||||
|
gremlinEndpoint: undefined,
|
||||||
|
cassandraEndpoint: undefined,
|
||||||
|
capabilities: databaseAccountGetResponse.capabilities.map((capability) => {
|
||||||
|
return { name: capability.name } as Capability;
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return databaseAccount;
|
||||||
|
};
|
||||||
|
|
||||||
const initTestExplorer = async (): Promise<void> => {
|
const initTestExplorer = async (): Promise<void> => {
|
||||||
const { token } = await credentials.getToken("https://management.core.windows.net/.default");
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||||
updateUserContext({
|
const portalRunnerDatabaseAccount = decodeURIComponent(
|
||||||
authorizationToken: `bearer ${token}`,
|
urlSearchParams.get(TestExplorerParams.portalRunnerDatabaseAccount)
|
||||||
});
|
);
|
||||||
const databaseAccount = await get(subscriptionId, resourceGroup, accountName);
|
const portalRunnerDatabaseAccountKey = decodeURIComponent(
|
||||||
const keys = await listKeys(subscriptionId, resourceGroup, accountName);
|
urlSearchParams.get(TestExplorerParams.portalRunnerDatabaseAccountKey)
|
||||||
|
);
|
||||||
|
const portalRunnerSubscripton = decodeURIComponent(urlSearchParams.get(TestExplorerParams.portalRunnerSubscripton));
|
||||||
|
const portalRunnerResourceGroup = decodeURIComponent(
|
||||||
|
urlSearchParams.get(TestExplorerParams.portalRunnerResourceGroup)
|
||||||
|
);
|
||||||
|
const selfServeType = urlSearchParams.get(TestExplorerParams.selfServeType);
|
||||||
|
|
||||||
|
const token = decodeURIComponent(urlSearchParams.get(TestExplorerParams.token));
|
||||||
|
const databaseAccount = await getDatabaseAccount(
|
||||||
|
token,
|
||||||
|
portalRunnerSubscripton,
|
||||||
|
portalRunnerResourceGroup,
|
||||||
|
portalRunnerDatabaseAccount
|
||||||
|
);
|
||||||
|
|
||||||
const initTestExplorerContent = {
|
const initTestExplorerContent = {
|
||||||
inputs: {
|
inputs: {
|
||||||
databaseAccount: databaseAccount,
|
databaseAccount: databaseAccount,
|
||||||
subscriptionId,
|
subscriptionId: portalRunnerSubscripton,
|
||||||
resourceGroup,
|
resourceGroup: portalRunnerResourceGroup,
|
||||||
authorizationToken: `Bearer ${token}`,
|
authorizationToken: `Bearer ${token}`,
|
||||||
features: {},
|
features: {},
|
||||||
hasWriteAccess: true,
|
hasWriteAccess: true,
|
||||||
@@ -56,7 +88,7 @@ const initTestExplorer = async (): Promise<void> => {
|
|||||||
quotaId: "Internal_2014-09-01",
|
quotaId: "Internal_2014-09-01",
|
||||||
addCollectionDefaultFlight: "2",
|
addCollectionDefaultFlight: "2",
|
||||||
isTryCosmosDBSubscription: false,
|
isTryCosmosDBSubscription: false,
|
||||||
masterKey: keys.primaryMasterKey,
|
masterKey: portalRunnerDatabaseAccountKey,
|
||||||
loadDatabaseAccountTimestamp: 1604663109836,
|
loadDatabaseAccountTimestamp: 1604663109836,
|
||||||
dataExplorerVersion: "1.0.1",
|
dataExplorerVersion: "1.0.1",
|
||||||
sharedThroughputMinimum: 400,
|
sharedThroughputMinimum: 400,
|
||||||
@@ -69,7 +101,7 @@ const initTestExplorer = async (): Promise<void> => {
|
|||||||
// add UI test only when feature is not dependent on flights anymore
|
// add UI test only when feature is not dependent on flights anymore
|
||||||
flights: [],
|
flights: [],
|
||||||
selfServeType,
|
selfServeType,
|
||||||
} as DataExplorerInputsFrame,
|
} as ViewModels.DataExplorerInputsFrame,
|
||||||
};
|
};
|
||||||
|
|
||||||
const iframe = document.createElement("iframe");
|
const iframe = document.createElement("iframe");
|
||||||
@@ -95,7 +127,7 @@ const initTestExplorer = async (): Promise<void> => {
|
|||||||
iframe.name = "explorer";
|
iframe.name = "explorer";
|
||||||
iframe.classList.add("iframe");
|
iframe.classList.add("iframe");
|
||||||
iframe.title = "explorer";
|
iframe.title = "explorer";
|
||||||
iframe.src = iframeSrc;
|
iframe.src = "explorer.html?platform=Portal&disablePortalInitCache";
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
8
test/testExplorer/TestExplorerParams.ts
Normal file
8
test/testExplorer/TestExplorerParams.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export enum TestExplorerParams {
|
||||||
|
portalRunnerDatabaseAccount = "portalRunnerDatabaseAccount",
|
||||||
|
portalRunnerDatabaseAccountKey = "portalRunnerDatabaseAccountKey",
|
||||||
|
portalRunnerSubscripton = "portalRunnerSubscripton",
|
||||||
|
portalRunnerResourceGroup = "portalRunnerResourceGroup",
|
||||||
|
selfServeType = "selfServeType",
|
||||||
|
token = "token",
|
||||||
|
}
|
||||||
64
test/testExplorer/TestExplorerUtils.ts
Normal file
64
test/testExplorer/TestExplorerUtils.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import { Frame } from "puppeteer";
|
||||||
|
import { TestExplorerParams } from "./TestExplorerParams";
|
||||||
|
import { ClientSecretCredential } from "@azure/identity";
|
||||||
|
import { ApiKind } from "../../src/Contracts/DataModels";
|
||||||
|
|
||||||
|
let testExplorerFrame: Frame;
|
||||||
|
export const getTestExplorerFrame = async (apiKind?: ApiKind, params?: Map<string, string>): Promise<Frame> => {
|
||||||
|
if (testExplorerFrame) {
|
||||||
|
return testExplorerFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
let portalRunnerDatabaseAccount: string;
|
||||||
|
let portalRunnerDatabaseAccountKey: string;
|
||||||
|
|
||||||
|
switch (apiKind) {
|
||||||
|
case ApiKind.MongoDB:
|
||||||
|
portalRunnerDatabaseAccount = process.env.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT;
|
||||||
|
portalRunnerDatabaseAccountKey = process.env.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT_KEY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
portalRunnerDatabaseAccount = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT;
|
||||||
|
portalRunnerDatabaseAccountKey = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
const notebooksTestRunnerTenantId = process.env.NOTEBOOKS_TEST_RUNNER_TENANT_ID;
|
||||||
|
const notebooksTestRunnerClientId = process.env.NOTEBOOKS_TEST_RUNNER_CLIENT_ID;
|
||||||
|
const notebooksTestRunnerClientSecret = process.env.NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET;
|
||||||
|
const portalRunnerSubscripton = process.env.PORTAL_RUNNER_SUBSCRIPTION;
|
||||||
|
const portalRunnerResourceGroup = process.env.PORTAL_RUNNER_RESOURCE_GROUP;
|
||||||
|
|
||||||
|
const credentials = new ClientSecretCredential(
|
||||||
|
notebooksTestRunnerTenantId,
|
||||||
|
notebooksTestRunnerClientId,
|
||||||
|
notebooksTestRunnerClientSecret
|
||||||
|
);
|
||||||
|
|
||||||
|
const { token } = await credentials.getToken("https://management.core.windows.net/.default");
|
||||||
|
|
||||||
|
const testExplorerUrl = new URL("testExplorer.html", "https://localhost:1234");
|
||||||
|
testExplorerUrl.searchParams.append(
|
||||||
|
TestExplorerParams.portalRunnerDatabaseAccount,
|
||||||
|
encodeURI(portalRunnerDatabaseAccount)
|
||||||
|
);
|
||||||
|
testExplorerUrl.searchParams.append(
|
||||||
|
TestExplorerParams.portalRunnerDatabaseAccountKey,
|
||||||
|
encodeURI(portalRunnerDatabaseAccountKey)
|
||||||
|
);
|
||||||
|
testExplorerUrl.searchParams.append(TestExplorerParams.portalRunnerSubscripton, encodeURI(portalRunnerSubscripton));
|
||||||
|
testExplorerUrl.searchParams.append(
|
||||||
|
TestExplorerParams.portalRunnerResourceGroup,
|
||||||
|
encodeURI(portalRunnerResourceGroup)
|
||||||
|
);
|
||||||
|
testExplorerUrl.searchParams.append(TestExplorerParams.token, encodeURI(token));
|
||||||
|
|
||||||
|
if (params) {
|
||||||
|
for (const key of params.keys()) {
|
||||||
|
testExplorerUrl.searchParams.append(key, encodeURI(params.get(key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.goto(testExplorerUrl.toString());
|
||||||
|
const handle = await page.waitForSelector("iframe");
|
||||||
|
return await handle.contentFrame();
|
||||||
|
};
|
||||||
@@ -30,8 +30,8 @@ export function generateDatabaseName(baseName = "db", length = 1): string {
|
|||||||
return `${baseName}${crypto.randomBytes(length).toString("hex")}-${Date.now()}`;
|
return `${baseName}${crypto.randomBytes(length).toString("hex")}-${Date.now()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createDatabase(frame: Frame): Promise<{ databaseId: string; collectionId: string }> {
|
export async function createDatabase(frame: Frame): Promise<string> {
|
||||||
const databaseId = generateDatabaseName();
|
const dbId = generateDatabaseName();
|
||||||
const collectionId = generateUniqueName("col");
|
const collectionId = generateUniqueName("col");
|
||||||
const shardKey = "partitionKey";
|
const shardKey = "partitionKey";
|
||||||
// create new collection
|
// create new collection
|
||||||
@@ -50,7 +50,7 @@ export async function createDatabase(frame: Frame): Promise<{ databaseId: string
|
|||||||
await frame.waitFor('input[data-test="addCollection-newDatabaseId"]');
|
await frame.waitFor('input[data-test="addCollection-newDatabaseId"]');
|
||||||
const dbInput = await frame.$('input[data-test="addCollection-newDatabaseId"]');
|
const dbInput = await frame.$('input[data-test="addCollection-newDatabaseId"]');
|
||||||
await dbInput.press("Backspace");
|
await dbInput.press("Backspace");
|
||||||
await dbInput.type(databaseId);
|
await dbInput.type(dbId);
|
||||||
|
|
||||||
// type collection id
|
// type collection id
|
||||||
await frame.waitFor('input[data-test="addCollection-collectionId"]');
|
await frame.waitFor('input[data-test="addCollection-collectionId"]');
|
||||||
@@ -67,7 +67,7 @@ export async function createDatabase(frame: Frame): Promise<{ databaseId: string
|
|||||||
// click submit
|
// click submit
|
||||||
await frame.waitFor("#submitBtnAddCollection");
|
await frame.waitFor("#submitBtnAddCollection");
|
||||||
await frame.click("#submitBtnAddCollection");
|
await frame.click("#submitBtnAddCollection");
|
||||||
return { databaseId, collectionId };
|
return dbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function onClickSaveButton(frame: Frame): Promise<void> {
|
export async function onClickSaveButton(frame: Frame): Promise<void> {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
"./src/Contracts/ActionContracts.ts",
|
"./src/Contracts/ActionContracts.ts",
|
||||||
"./src/Contracts/Diagnostics.ts",
|
"./src/Contracts/Diagnostics.ts",
|
||||||
"./src/Contracts/ExplorerContracts.ts",
|
"./src/Contracts/ExplorerContracts.ts",
|
||||||
"./src/Contracts/SelfServeContracts.ts",
|
|
||||||
"./src/Contracts/Versions.ts"
|
"./src/Contracts/Versions.ts"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
|
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
|
||||||
const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb");
|
const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb");
|
||||||
const ms = require("ms");
|
const ms = require("ms");
|
||||||
|
const { time } = require("console");
|
||||||
|
|
||||||
const clientId = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_ID"];
|
const clientId = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_ID"];
|
||||||
const secret = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET"];
|
const secret = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET"];
|
||||||
@@ -8,15 +9,7 @@ const tenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47";
|
|||||||
const subscriptionId = "69e02f2d-f059-4409-9eac-97e8a276ae2c";
|
const subscriptionId = "69e02f2d-f059-4409-9eac-97e8a276ae2c";
|
||||||
const resourceGroupName = "runners";
|
const resourceGroupName = "runners";
|
||||||
|
|
||||||
const thirtyMinutesAgo = new Date(Date.now() - 1000 * 60 * 30).getTime();
|
const sixtyMinutesAgo = new Date(Date.now() - 1000 * 60 * 60).getTime();
|
||||||
|
|
||||||
function friendlyTime(date) {
|
|
||||||
try {
|
|
||||||
return ms(date);
|
|
||||||
} catch (error) {
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deletes all SQL and Mongo databases created more than 20 minutes ago in the test runner accounts
|
// Deletes all SQL and Mongo databases created more than 20 minutes ago in the test runner accounts
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -28,22 +21,22 @@ async function main() {
|
|||||||
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
||||||
for (const database of mongoDatabases) {
|
for (const database of mongoDatabases) {
|
||||||
const timestamp = Number(database.name.split("-")[1]);
|
const timestamp = Number(database.name.split("-")[1]);
|
||||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
if (timestamp && timestamp < sixtyMinutesAgo) {
|
||||||
await client.mongoDBResources.deleteMongoDBDatabase(resourceGroupName, account.name, database.name);
|
await client.mongoDBResources.deleteMongoDBDatabase(resourceGroupName, account.name, database.name);
|
||||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (account.kind === "GlobalDocumentDB") {
|
} else if (account.kind === "GlobalDocumentDB") {
|
||||||
const sqlDatabases = await client.sqlResources.listSqlDatabases(resourceGroupName, account.name);
|
const sqlDatabases = await client.sqlResources.listSqlDatabases(resourceGroupName, account.name);
|
||||||
for (const database of sqlDatabases) {
|
for (const database of sqlDatabases) {
|
||||||
const timestamp = Number(database.name.split("-")[1]);
|
const timestamp = Number(database.name.split("-")[1]);
|
||||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
if (timestamp && timestamp < sixtyMinutesAgo) {
|
||||||
await client.sqlResources.deleteSqlDatabase(resourceGroupName, account.name, database.name);
|
await client.sqlResources.deleteSqlDatabase(resourceGroupName, account.name, database.name);
|
||||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${ms(Date.now() - timestamp)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
require("dotenv/config");
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
|
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
@@ -15,16 +14,6 @@ const isCI = require("is-ci");
|
|||||||
|
|
||||||
const gitSha = childProcess.execSync("git rev-parse HEAD").toString("utf8");
|
const gitSha = childProcess.execSync("git rev-parse HEAD").toString("utf8");
|
||||||
|
|
||||||
const AZURE_CLIENT_ID = "fd8753b0-0707-4e32-84e9-2532af865fb4";
|
|
||||||
const AZURE_TENANT_ID = "72f988bf-86f1-41af-91ab-2d7cd011db47";
|
|
||||||
const SUBSCRIPTION_ID = "69e02f2d-f059-4409-9eac-97e8a276ae2c";
|
|
||||||
const RESOURCE_GROUP = "runners";
|
|
||||||
const AZURE_CLIENT_SECRET = process.env.AZURE_CLIENT_SECRET || process.env.NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET; // TODO Remove. Exists for backwards compat with old .env files. Prefer AZURE_CLIENT_SECRET
|
|
||||||
|
|
||||||
if (!AZURE_CLIENT_SECRET) {
|
|
||||||
console.warn("AZURE_CLIENT_SECRET is not set. testExplorer.html will not work.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const cssRule = {
|
const cssRule = {
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
||||||
@@ -113,11 +102,6 @@ module.exports = function (env = {}, argv = {}) {
|
|||||||
|
|
||||||
if (mode === "development") {
|
if (mode === "development") {
|
||||||
envVars.NODE_ENV = "development";
|
envVars.NODE_ENV = "development";
|
||||||
envVars.AZURE_CLIENT_ID = AZURE_CLIENT_ID;
|
|
||||||
envVars.AZURE_TENANT_ID = AZURE_TENANT_ID;
|
|
||||||
envVars.AZURE_CLIENT_SECRET = AZURE_CLIENT_SECRET;
|
|
||||||
envVars.SUBSCRIPTION_ID = SUBSCRIPTION_ID;
|
|
||||||
envVars.RESOURCE_GROUP = RESOURCE_GROUP;
|
|
||||||
typescriptRule.use[0].options.compilerOptions = { target: "ES2018" };
|
typescriptRule.use[0].options.compilerOptions = { target: "ES2018" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +166,6 @@ module.exports = function (env = {}, argv = {}) {
|
|||||||
template: "src/connectToGitHub.html",
|
template: "src/connectToGitHub.html",
|
||||||
chunks: ["connectToGitHub"],
|
chunks: ["connectToGitHub"],
|
||||||
}),
|
}),
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
filename: "selfServe.html",
|
|
||||||
template: "src/SelfServe/selfServe.html",
|
|
||||||
chunks: ["selfServe"],
|
|
||||||
}),
|
|
||||||
new MonacoWebpackPlugin(),
|
new MonacoWebpackPlugin(),
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [{ from: "DataExplorer.nuspec" }, { from: "web.config" }, { from: "quickstart/*.zip" }],
|
patterns: [{ from: "DataExplorer.nuspec" }, { from: "web.config" }, { from: "quickstart/*.zip" }],
|
||||||
@@ -210,7 +189,6 @@ module.exports = function (env = {}, argv = {}) {
|
|||||||
terminal: "./src/Terminal/index.ts",
|
terminal: "./src/Terminal/index.ts",
|
||||||
notebookViewer: "./src/NotebookViewer/NotebookViewer.tsx",
|
notebookViewer: "./src/NotebookViewer/NotebookViewer.tsx",
|
||||||
galleryViewer: "./src/GalleryViewer/GalleryViewer.tsx",
|
galleryViewer: "./src/GalleryViewer/GalleryViewer.tsx",
|
||||||
selfServe: "./src/SelfServe/SelfServe.tsx",
|
|
||||||
connectToGitHub: "./src/GitHub/GitHubConnector.ts",
|
connectToGitHub: "./src/GitHub/GitHubConnector.ts",
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
@@ -298,12 +276,6 @@ module.exports = function (env = {}, argv = {}) {
|
|||||||
secure: false,
|
secure: false,
|
||||||
logLevel: "debug",
|
logLevel: "debug",
|
||||||
},
|
},
|
||||||
[`/${AZURE_TENANT_ID}`]: {
|
|
||||||
target: "https://login.microsoftonline.com/",
|
|
||||||
changeOrigin: true,
|
|
||||||
secure: false,
|
|
||||||
logLevel: "debug",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
stats: "minimal",
|
stats: "minimal",
|
||||||
|
|||||||
Reference in New Issue
Block a user