mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-08 03:57:31 +00:00
Merge branch 'master' into users/dshilov/restore-container
This commit is contained in:
88
package-lock.json
generated
88
package-lock.json
generated
@@ -116,6 +116,7 @@
|
|||||||
"tinykeys": "2.1.0",
|
"tinykeys": "2.1.0",
|
||||||
"underscore": "1.12.1",
|
"underscore": "1.12.1",
|
||||||
"utility-types": "3.10.0",
|
"utility-types": "3.10.0",
|
||||||
|
"uuid": "9.0.0",
|
||||||
"zustand": "3.5.0"
|
"zustand": "3.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -626,6 +627,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@azure/ms-rest-js/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@azure/ms-rest-js/node_modules/xml2js": {
|
"node_modules/@azure/ms-rest-js/node_modules/xml2js": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -685,6 +694,14 @@
|
|||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@azure/msal-node/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
"version": "7.24.7",
|
"version": "7.24.7",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz",
|
||||||
@@ -7595,6 +7612,14 @@
|
|||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/commutable/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nteract/connected-components": {
|
"node_modules/@nteract/connected-components": {
|
||||||
"version": "6.8.2",
|
"version": "6.8.2",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -9125,6 +9150,14 @@
|
|||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/fixtures/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nteract/iron-icons": {
|
"node_modules/@nteract/iron-icons": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -9282,6 +9315,14 @@
|
|||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/messaging/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nteract/monaco-editor": {
|
"node_modules/@nteract/monaco-editor": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -9397,6 +9438,14 @@
|
|||||||
"version": "0.18.1",
|
"version": "0.18.1",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/monaco-editor/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nteract/mythic-configuration": {
|
"node_modules/@nteract/mythic-configuration": {
|
||||||
"version": "1.0.12",
|
"version": "1.0.12",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -9665,6 +9714,14 @@
|
|||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/reducers/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nteract/selectors": {
|
"node_modules/@nteract/selectors": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -9888,6 +9945,14 @@
|
|||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nteract/types/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@octokit/auth-token": {
|
"node_modules/@octokit/auth-token": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -26419,6 +26484,15 @@
|
|||||||
"xmlbuilder": "^15.1.0"
|
"xmlbuilder": "^15.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jest-trx-results-processor/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/jest-util": {
|
"node_modules/jest-util": {
|
||||||
"version": "24.9.0",
|
"version": "24.9.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -33753,6 +33827,15 @@
|
|||||||
"websocket-driver": "^0.7.4"
|
"websocket-driver": "^0.7.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/sockjs/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map": {
|
"node_modules/source-map": {
|
||||||
"version": "0.5.7",
|
"version": "0.5.7",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -35619,8 +35702,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/uuid": {
|
"node_modules/uuid": {
|
||||||
"version": "8.3.2",
|
"version": "9.0.0",
|
||||||
"license": "MIT",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
|
||||||
|
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"uuid": "dist/bin/uuid"
|
"uuid": "dist/bin/uuid"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
"@types/mkdirp": "1.0.1",
|
"@types/mkdirp": "1.0.1",
|
||||||
"@types/node-fetch": "2.5.7",
|
"@types/node-fetch": "2.5.7",
|
||||||
"@xmldom/xmldom": "0.7.13",
|
"@xmldom/xmldom": "0.7.13",
|
||||||
"@xterm/xterm": "5.5.0",
|
|
||||||
"@xterm/addon-fit": "0.10.0",
|
"@xterm/addon-fit": "0.10.0",
|
||||||
|
"@xterm/xterm": "5.5.0",
|
||||||
"allotment": "1.20.2",
|
"allotment": "1.20.2",
|
||||||
"applicationinsights": "1.8.0",
|
"applicationinsights": "1.8.0",
|
||||||
"bootstrap": "3.4.1",
|
"bootstrap": "3.4.1",
|
||||||
@@ -111,6 +111,7 @@
|
|||||||
"tinykeys": "2.1.0",
|
"tinykeys": "2.1.0",
|
||||||
"underscore": "1.12.1",
|
"underscore": "1.12.1",
|
||||||
"utility-types": "3.10.0",
|
"utility-types": "3.10.0",
|
||||||
|
"uuid": "9.0.0",
|
||||||
"zustand": "3.5.0"
|
"zustand": "3.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -248,4 +249,4 @@
|
|||||||
"printWidth": 120,
|
"printWidth": 120,
|
||||||
"endOfLine": "auto"
|
"endOfLine": "auto"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export class CapabilityNames {
|
|||||||
public static readonly EnableDataMasking: string = "EnableDataMasking";
|
public static readonly EnableDataMasking: string = "EnableDataMasking";
|
||||||
public static readonly EnableDynamicDataMasking: string = "EnableDynamicDataMasking";
|
public static readonly EnableDynamicDataMasking: string = "EnableDynamicDataMasking";
|
||||||
public static readonly EnableNoSQLFullTextSearchPreviewFeatures: string = "EnableNoSQLFullTextSearchPreviewFeatures";
|
public static readonly EnableNoSQLFullTextSearchPreviewFeatures: string = "EnableNoSQLFullTextSearchPreviewFeatures";
|
||||||
public static readonly EnableOnlineCopyFeature: string = "EnableOnlineCopyFeature";
|
public static readonly EnableOnlineCopyFeature: string = "EnableOnlineContainerCopy";
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CapacityMode {
|
export enum CapacityMode {
|
||||||
@@ -297,6 +297,7 @@ export class HttpHeaders {
|
|||||||
public static migrateOfferToManualThroughput: string = "x-ms-cosmos-migrate-offer-to-manual-throughput";
|
public static migrateOfferToManualThroughput: string = "x-ms-cosmos-migrate-offer-to-manual-throughput";
|
||||||
public static migrateOfferToAutopilot: string = "x-ms-cosmos-migrate-offer-to-autopilot";
|
public static migrateOfferToAutopilot: string = "x-ms-cosmos-migrate-offer-to-autopilot";
|
||||||
public static xAPIKey: string = "X-API-Key";
|
public static xAPIKey: string = "X-API-Key";
|
||||||
|
public static sessionId: string = "x-ms-client-session-id";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ContentType {
|
export class ContentType {
|
||||||
|
|||||||
31
src/Common/LoadingOverlay.tsx
Normal file
31
src/Common/LoadingOverlay.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Overlay, Spinner, SpinnerSize } from "@fluentui/react";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface LoadingOverlayProps {
|
||||||
|
isLoading: boolean;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LoadingOverlay: React.FC<LoadingOverlayProps> = ({ isLoading, label }) => {
|
||||||
|
if (!isLoading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Overlay
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
backgroundColor: "rgba(255,255,255,0.9)",
|
||||||
|
zIndex: 9999,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Spinner size={SpinnerSize.large} label={label} styles={{ label: { fontWeight: 600 } }} />
|
||||||
|
</Overlay>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LoadingOverlay;
|
||||||
@@ -17,6 +17,7 @@ const defaultHeaders = {
|
|||||||
[HttpHeaders.apiType]: ApiType.MongoDB.toString(),
|
[HttpHeaders.apiType]: ApiType.MongoDB.toString(),
|
||||||
[CosmosSDKConstants.HttpHeaders.MaxEntityCount]: "100",
|
[CosmosSDKConstants.HttpHeaders.MaxEntityCount]: "100",
|
||||||
[CosmosSDKConstants.HttpHeaders.Version]: "2017-11-15",
|
[CosmosSDKConstants.HttpHeaders.Version]: "2017-11-15",
|
||||||
|
[HttpHeaders.sessionId]: userContext.sessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
function authHeaders() {
|
function authHeaders() {
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import { handleError } from "../ErrorHandlingUtils";
|
|||||||
import { readOfferWithSDK } from "./readOfferWithSDK";
|
import { readOfferWithSDK } from "./readOfferWithSDK";
|
||||||
|
|
||||||
export const readCollectionOffer = async (params: ReadCollectionOfferParams): Promise<Offer> => {
|
export const readCollectionOffer = async (params: ReadCollectionOfferParams): Promise<Offer> => {
|
||||||
const clearMessage = logConsoleProgress(`Querying offer for collection ${params.collectionId}`);
|
|
||||||
|
|
||||||
if (isFabric()) {
|
if (isFabric()) {
|
||||||
// Not exposing offers in Fabric
|
// Not exposing offers in Fabric
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clearMessage = logConsoleProgress(`Querying offer for collection ${params.collectionId}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
userContext.authType === AuthType.AAD &&
|
userContext.authType === AuthType.AAD &&
|
||||||
|
|||||||
@@ -446,6 +446,7 @@ export interface DataExplorerInputsFrame {
|
|||||||
feedbackPolicies?: any;
|
feedbackPolicies?: any;
|
||||||
aadToken?: string;
|
aadToken?: string;
|
||||||
containerCopyEnabled?: boolean;
|
containerCopyEnabled?: boolean;
|
||||||
|
sessionId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SelfServeFrameInputs {
|
export interface SelfServeFrameInputs {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
|
import { logError } from "../../../Common/Logger";
|
||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
import {
|
import {
|
||||||
cancel,
|
cancel,
|
||||||
@@ -28,12 +30,12 @@ import CopyJobDetails from "../MonitorCopyJobs/Components/CopyJobDetails";
|
|||||||
import { MonitorCopyJobsRefState } from "../MonitorCopyJobs/MonitorCopyJobRefState";
|
import { MonitorCopyJobsRefState } from "../MonitorCopyJobs/MonitorCopyJobRefState";
|
||||||
import { CopyJobContextState, CopyJobError, CopyJobErrorType, CopyJobType } from "../Types/CopyJobTypes";
|
import { CopyJobContextState, CopyJobError, CopyJobErrorType, CopyJobType } from "../Types/CopyJobTypes";
|
||||||
|
|
||||||
export const openCreateCopyJobPanel = () => {
|
export const openCreateCopyJobPanel = (explorer: Explorer) => {
|
||||||
const sidePanelState = useSidePanel.getState();
|
const sidePanelState = useSidePanel.getState();
|
||||||
sidePanelState.setPanelHasConsole(false);
|
sidePanelState.setPanelHasConsole(false);
|
||||||
sidePanelState.openSidePanel(
|
sidePanelState.openSidePanel(
|
||||||
ContainerCopyMessages.createCopyJobPanelTitle,
|
ContainerCopyMessages.createCopyJobPanelTitle,
|
||||||
<CreateCopyJobScreensProvider />,
|
<CreateCopyJobScreensProvider explorer={explorer} />,
|
||||||
"650px",
|
"650px",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -159,7 +161,8 @@ export const submitCreateCopyJob = async (state: CopyJobContextState, onSuccess:
|
|||||||
onSuccess();
|
onSuccess();
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error submitting create copy job:", error);
|
const errorMessage = error.message || "Error submitting create copy job. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/CopyJobActions.submitCreateCopyJob");
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -198,8 +201,7 @@ export const updateCopyJobStatus = async (job: CopyJobType, action: string): Pro
|
|||||||
pattern,
|
pattern,
|
||||||
`'${ContainerCopyMessages.MonitorJobs.Status.InProgress}'`,
|
`'${ContainerCopyMessages.MonitorJobs.Status.InProgress}'`,
|
||||||
);
|
);
|
||||||
|
logError(`Error updating copy job status: ${normalizedErrorMessage}`, "CopyJob/CopyJobActions.updateCopyJobStatus");
|
||||||
console.error(`Error updating copy job status: ${normalizedErrorMessage}`);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ const rootStyle = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CopyJobCommandBar: React.FC<ContainerCopyProps> = ({ container }) => {
|
const CopyJobCommandBar: React.FC<ContainerCopyProps> = ({ explorer }) => {
|
||||||
const commandBarItems: CommandButtonComponentProps[] = getCommandBarButtons(container);
|
const commandBarItems: CommandButtonComponentProps[] = getCommandBarButtons(explorer);
|
||||||
const controlButtons: ICommandBarItemProps[] = CommandBarUtil.convertButton(commandBarItems, backgroundColor);
|
const controlButtons: ICommandBarItemProps[] = CommandBarUtil.convertButton(commandBarItems, backgroundColor);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import ContainerCopyMessages from "../ContainerCopyMessages";
|
|||||||
import { MonitorCopyJobsRefState } from "../MonitorCopyJobs/MonitorCopyJobRefState";
|
import { MonitorCopyJobsRefState } from "../MonitorCopyJobs/MonitorCopyJobRefState";
|
||||||
import { CopyJobCommandBarBtnType } from "../Types/CopyJobTypes";
|
import { CopyJobCommandBarBtnType } from "../Types/CopyJobTypes";
|
||||||
|
|
||||||
function getCopyJobBtns(container: Explorer): CopyJobCommandBarBtnType[] {
|
function getCopyJobBtns(explorer: Explorer): CopyJobCommandBarBtnType[] {
|
||||||
const monitorCopyJobsRef = MonitorCopyJobsRefState((state) => state.ref);
|
const monitorCopyJobsRef = MonitorCopyJobsRefState((state) => state.ref);
|
||||||
const buttons: CopyJobCommandBarBtnType[] = [
|
const buttons: CopyJobCommandBarBtnType[] = [
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ function getCopyJobBtns(container: Explorer): CopyJobCommandBarBtnType[] {
|
|||||||
iconSrc: AddIcon,
|
iconSrc: AddIcon,
|
||||||
label: ContainerCopyMessages.createCopyJobButtonLabel,
|
label: ContainerCopyMessages.createCopyJobButtonLabel,
|
||||||
ariaLabel: ContainerCopyMessages.createCopyJobButtonAriaLabel,
|
ariaLabel: ContainerCopyMessages.createCopyJobButtonAriaLabel,
|
||||||
onClick: Actions.openCreateCopyJobPanel,
|
onClick: Actions.openCreateCopyJobPanel.bind(null, explorer),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "refresh",
|
key: "refresh",
|
||||||
@@ -34,7 +34,7 @@ function getCopyJobBtns(container: Explorer): CopyJobCommandBarBtnType[] {
|
|||||||
label: ContainerCopyMessages.feedbackButtonLabel,
|
label: ContainerCopyMessages.feedbackButtonLabel,
|
||||||
ariaLabel: ContainerCopyMessages.feedbackButtonAriaLabel,
|
ariaLabel: ContainerCopyMessages.feedbackButtonAriaLabel,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
container.openContainerCopyFeedbackBlade();
|
explorer.openContainerCopyFeedbackBlade();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,6 @@ function btnMapper(config: CopyJobCommandBarBtnType): CommandButtonComponentProp
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCommandBarButtons(container: Explorer): CommandButtonComponentProps[] {
|
export function getCommandBarButtons(explorer: Explorer): CommandButtonComponentProps[] {
|
||||||
return getCopyJobBtns(container).map(btnMapper);
|
return getCopyJobBtns(explorer).map(btnMapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ export default {
|
|||||||
databaseDropdownPlaceholder: "Select a database",
|
databaseDropdownPlaceholder: "Select a database",
|
||||||
containerDropdownLabel: "Container",
|
containerDropdownLabel: "Container",
|
||||||
containerDropdownPlaceholder: "Select a container",
|
containerDropdownPlaceholder: "Select a container",
|
||||||
|
createNewContainerSubHeading: "Select the properties for your container.",
|
||||||
|
createContainerButtonLabel: "Create a new container",
|
||||||
|
createContainerHeading: "Create new container",
|
||||||
|
|
||||||
// Preview and Create Screen
|
// Preview and Create Screen
|
||||||
jobNameLabel: "Job name",
|
jobNameLabel: "Job name",
|
||||||
@@ -48,13 +51,24 @@ export default {
|
|||||||
|
|
||||||
// Assign Permissions Screen
|
// Assign Permissions Screen
|
||||||
assignPermissions: {
|
assignPermissions: {
|
||||||
description:
|
crossAccountDescription:
|
||||||
"To copy data from the source to the destination container, ensure that the managed identity of the destination account has read access to the source account by completing the following steps.",
|
"To copy data from the source to the destination container, ensure that the managed identity of the destination account has read access to the source account by completing the following steps.",
|
||||||
|
intraAccountOnlineDescription: (accountName: string) =>
|
||||||
|
`Follow the steps below to enable online copy on your "${accountName}" account.`,
|
||||||
|
commonConfiguration: {
|
||||||
|
title: "Common configuration",
|
||||||
|
description: "Basic permissions required for copy operations",
|
||||||
|
},
|
||||||
|
onlineConfiguration: {
|
||||||
|
title: "Online copy configuration",
|
||||||
|
description: "Additional permissions required for online copy operations",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
toggleBtn: {
|
toggleBtn: {
|
||||||
onText: "On",
|
onText: "On",
|
||||||
offText: "Off",
|
offText: "Off",
|
||||||
},
|
},
|
||||||
|
popoverOverlaySpinnerLabel: "Please wait while we process your request...",
|
||||||
addManagedIdentity: {
|
addManagedIdentity: {
|
||||||
title: "System-assigned managed identity enabled.",
|
title: "System-assigned managed identity enabled.",
|
||||||
description:
|
description:
|
||||||
@@ -115,7 +129,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onlineCopyEnabled: {
|
onlineCopyEnabled: {
|
||||||
title: "Online copy enabled",
|
title: "Online copy enabled",
|
||||||
description: (accountName: string) => `Use Azure CLI to enable Online copy on "${accountName}".`,
|
description: (accountName: string) => `Enable Online copy on "${accountName}".`,
|
||||||
hrefText: "Learn more about online copy jobs",
|
hrefText: "Learn more about online copy jobs",
|
||||||
href: "https://learn.microsoft.com/en-us/azure/cosmos-db/container-copy?tabs=online-copy&pivots=api-nosql#enable-online-copy",
|
href: "https://learn.microsoft.com/en-us/azure/cosmos-db/container-copy?tabs=online-copy&pivots=api-nosql#enable-online-copy",
|
||||||
buttonText: "Enable Online Copy",
|
buttonText: "Enable Online Copy",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { MonitorCopyJobsRefState } from "./MonitorCopyJobs/MonitorCopyJobRefStat
|
|||||||
import MonitorCopyJobs, { MonitorCopyJobsRef } from "./MonitorCopyJobs/MonitorCopyJobs";
|
import MonitorCopyJobs, { MonitorCopyJobsRef } from "./MonitorCopyJobs/MonitorCopyJobs";
|
||||||
import { ContainerCopyProps } from "./Types/CopyJobTypes";
|
import { ContainerCopyProps } from "./Types/CopyJobTypes";
|
||||||
|
|
||||||
const ContainerCopyPanel: React.FC<ContainerCopyProps> = ({ container }) => {
|
const ContainerCopyPanel: React.FC<ContainerCopyProps> = ({ explorer }) => {
|
||||||
const monitorCopyJobsRef = React.useRef<MonitorCopyJobsRef>();
|
const monitorCopyJobsRef = React.useRef<MonitorCopyJobsRef>();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (monitorCopyJobsRef.current) {
|
if (monitorCopyJobsRef.current) {
|
||||||
@@ -14,8 +14,8 @@ const ContainerCopyPanel: React.FC<ContainerCopyProps> = ({ container }) => {
|
|||||||
}, [monitorCopyJobsRef.current]);
|
}, [monitorCopyJobsRef.current]);
|
||||||
return (
|
return (
|
||||||
<div id="containerCopyWrapper" className="flexContainer hideOverflows">
|
<div id="containerCopyWrapper" className="flexContainer hideOverflows">
|
||||||
<CopyJobCommandBar container={container} />
|
<CopyJobCommandBar explorer={explorer} />
|
||||||
<MonitorCopyJobs ref={monitorCopyJobsRef} />
|
<MonitorCopyJobs ref={monitorCopyJobsRef} explorer={explorer} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
|
import { Subscription } from "Contracts/DataModels";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
import { CopyJobMigrationType } from "../Enums/CopyJobEnums";
|
import { CopyJobMigrationType } from "../Enums/CopyJobEnums";
|
||||||
@@ -14,6 +16,7 @@ export const useCopyJobContext = (): CopyJobContextProviderType => {
|
|||||||
|
|
||||||
interface CopyJobContextProviderProps {
|
interface CopyJobContextProviderProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
explorer: Explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getInitialCopyJobState = (): CopyJobContextState => {
|
const getInitialCopyJobState = (): CopyJobContextState => {
|
||||||
@@ -21,8 +24,10 @@ const getInitialCopyJobState = (): CopyJobContextState => {
|
|||||||
jobName: "",
|
jobName: "",
|
||||||
migrationType: CopyJobMigrationType.Offline,
|
migrationType: CopyJobMigrationType.Offline,
|
||||||
source: {
|
source: {
|
||||||
subscription: null,
|
subscription: {
|
||||||
account: null,
|
subscriptionId: userContext.subscriptionId || "",
|
||||||
|
} as Subscription,
|
||||||
|
account: userContext.databaseAccount || null,
|
||||||
databaseId: "",
|
databaseId: "",
|
||||||
containerId: "",
|
containerId: "",
|
||||||
},
|
},
|
||||||
@@ -39,16 +44,24 @@ const getInitialCopyJobState = (): CopyJobContextState => {
|
|||||||
const CopyJobContextProvider: React.FC<CopyJobContextProviderProps> = (props) => {
|
const CopyJobContextProvider: React.FC<CopyJobContextProviderProps> = (props) => {
|
||||||
const [copyJobState, setCopyJobState] = React.useState<CopyJobContextState>(getInitialCopyJobState());
|
const [copyJobState, setCopyJobState] = React.useState<CopyJobContextState>(getInitialCopyJobState());
|
||||||
const [flow, setFlow] = React.useState<CopyJobFlowType | null>(null);
|
const [flow, setFlow] = React.useState<CopyJobFlowType | null>(null);
|
||||||
|
const [contextError, setContextError] = React.useState<string | null>(null);
|
||||||
|
|
||||||
const resetCopyJobState = () => {
|
const resetCopyJobState = () => {
|
||||||
setCopyJobState(getInitialCopyJobState());
|
setCopyJobState(getInitialCopyJobState());
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const contextValue: CopyJobContextProviderType = {
|
||||||
<CopyJobContext.Provider value={{ copyJobState, setCopyJobState, flow, setFlow, resetCopyJobState }}>
|
contextError,
|
||||||
{props.children}
|
setContextError,
|
||||||
</CopyJobContext.Provider>
|
copyJobState,
|
||||||
);
|
setCopyJobState,
|
||||||
|
flow,
|
||||||
|
setFlow,
|
||||||
|
resetCopyJobState,
|
||||||
|
explorer: props.explorer,
|
||||||
|
};
|
||||||
|
|
||||||
|
return <CopyJobContext.Provider value={contextValue}>{props.children}</CopyJobContext.Provider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CopyJobContextProvider;
|
export default CopyJobContextProvider;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DatabaseAccount } from "Contracts/DataModels";
|
import { DatabaseAccount } from "Contracts/DataModels";
|
||||||
import { CopyJobErrorType } from "./Types/CopyJobTypes";
|
import { CopyJobContextState, CopyJobErrorType, CopyJobType } from "./Types/CopyJobTypes";
|
||||||
|
|
||||||
const azurePortalMpacEndpoint = "https://ms.portal.azure.com/";
|
const azurePortalMpacEndpoint = "https://ms.portal.azure.com/";
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ export function getAccountDetailsFromResourceId(accountId: string | undefined) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const pattern = new RegExp(
|
const pattern = new RegExp(
|
||||||
"/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/Microsoft\\.DocumentDB/databaseAccounts/([^/]+)",
|
"/subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/Microsoft\\.DocumentDB?/databaseAccounts/([^/]+)",
|
||||||
"i",
|
"i",
|
||||||
);
|
);
|
||||||
const matches = accountId.match(pattern);
|
const matches = accountId.match(pattern);
|
||||||
@@ -114,3 +114,58 @@ export function getAccountDetailsFromResourceId(accountId: string | undefined) {
|
|||||||
const [_, subscriptionId, resourceGroup, accountName] = matches || [];
|
const [_, subscriptionId, resourceGroup, accountName] = matches || [];
|
||||||
return { subscriptionId, resourceGroup, accountName };
|
return { subscriptionId, resourceGroup, accountName };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getContainerIdentifiers(container: CopyJobContextState["source"] | CopyJobContextState["target"]) {
|
||||||
|
return {
|
||||||
|
accountId: container?.account?.id || "",
|
||||||
|
databaseId: container?.databaseId || "",
|
||||||
|
containerId: container?.containerId || "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isIntraAccountCopy(sourceAccountId: string | undefined, targetAccountId: string | undefined): boolean {
|
||||||
|
const sourceAccountDetails = getAccountDetailsFromResourceId(sourceAccountId);
|
||||||
|
const targetAccountDetails = getAccountDetailsFromResourceId(targetAccountId);
|
||||||
|
return (
|
||||||
|
sourceAccountDetails?.subscriptionId === targetAccountDetails?.subscriptionId &&
|
||||||
|
sourceAccountDetails?.resourceGroup === targetAccountDetails?.resourceGroup &&
|
||||||
|
sourceAccountDetails?.accountName === targetAccountDetails?.accountName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isEqual(prevJobs: CopyJobType[], newJobs: CopyJobType[]): boolean {
|
||||||
|
if (prevJobs.length !== newJobs.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return prevJobs.every((prevJob: CopyJobType) => {
|
||||||
|
const newJob = newJobs.find((job) => job.Name === prevJob.Name);
|
||||||
|
if (!newJob) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return prevJob.Status === newJob.Status;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const truncateLength = 5;
|
||||||
|
const truncateName = (name: string, length: number = truncateLength): string => {
|
||||||
|
return name.length <= length ? name : name.slice(0, length);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getDefaultJobName(
|
||||||
|
selectedDatabaseAndContainers: {
|
||||||
|
sourceDatabaseName?: string;
|
||||||
|
sourceContainerName?: string;
|
||||||
|
targetDatabaseName?: string;
|
||||||
|
targetContainerName?: string;
|
||||||
|
}[],
|
||||||
|
): string {
|
||||||
|
if (selectedDatabaseAndContainers.length === 1) {
|
||||||
|
const { sourceDatabaseName, sourceContainerName, targetDatabaseName, targetContainerName } =
|
||||||
|
selectedDatabaseAndContainers[0];
|
||||||
|
const timestamp = new Date().getTime().toString();
|
||||||
|
const sourcePart = `${truncateName(sourceDatabaseName)}.${truncateName(sourceContainerName)}`;
|
||||||
|
const targetPart = `${truncateName(targetDatabaseName)}.${truncateName(targetContainerName)}`;
|
||||||
|
return `${sourcePart}_${targetPart}_${timestamp}`;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Link, Stack, Text, Toggle } from "@fluentui/react";
|
import { Link, Stack, Text, Toggle } from "@fluentui/react";
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
|
import { logError } from "../../../../../Common/Logger";
|
||||||
import { assignRole } from "../../../../../Utils/arm/RbacUtils";
|
import { assignRole } from "../../../../../Utils/arm/RbacUtils";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
@@ -21,7 +22,7 @@ type AddReadPermissionToDefaultIdentityProps = Partial<PermissionSectionConfig>;
|
|||||||
|
|
||||||
const AddReadPermissionToDefaultIdentity: React.FC<AddReadPermissionToDefaultIdentityProps> = () => {
|
const AddReadPermissionToDefaultIdentity: React.FC<AddReadPermissionToDefaultIdentityProps> = () => {
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
const { copyJobState, setCopyJobState, setContextError } = useCopyJobContext();
|
||||||
const [readPermissionAssigned, onToggle] = useToggle(false);
|
const [readPermissionAssigned, onToggle] = useToggle(false);
|
||||||
|
|
||||||
const handleAddReadPermission = useCallback(async () => {
|
const handleAddReadPermission = useCallback(async () => {
|
||||||
@@ -48,11 +49,14 @@ const AddReadPermissionToDefaultIdentity: React.FC<AddReadPermissionToDefaultIde
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error assigning read permission to default identity:", error);
|
const errorMessage =
|
||||||
|
error.message || "Error assigning read permission to default identity. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/AddReadPermissionToDefaultIdentity.handleAddReadPermission");
|
||||||
|
setContextError(errorMessage);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [copyJobState, setCopyJobState]);
|
}, [copyJobState, setCopyJobState, setContextError]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="defaultManagedIdentityContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
<Stack className="defaultManagedIdentityContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import WarningIcon from "../../../../../../images/warning.svg";
|
|||||||
import ShimmerTree, { IndentLevel } from "../../../../../Common/ShimmerTree/ShimmerTree";
|
import ShimmerTree, { IndentLevel } from "../../../../../Common/ShimmerTree/ShimmerTree";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
|
import { isIntraAccountCopy } from "../../../CopyJobUtils";
|
||||||
import { CopyJobMigrationType } from "../../../Enums/CopyJobEnums";
|
import { CopyJobMigrationType } from "../../../Enums/CopyJobEnums";
|
||||||
import usePermissionSections, { PermissionSectionConfig } from "./hooks/usePermissionsSection";
|
import { useCopyJobPrerequisitesCache } from "../../Utils/useCopyJobPrerequisitesCache";
|
||||||
|
import usePermissionSections, { PermissionGroupConfig, PermissionSectionConfig } from "./hooks/usePermissionsSection";
|
||||||
|
|
||||||
const PermissionSection: React.FC<PermissionSectionConfig> = ({ id, title, Component, completed, disabled }) => (
|
const PermissionSection: React.FC<PermissionSectionConfig> = ({ id, title, Component, completed, disabled }) => (
|
||||||
<AccordionItem key={id} value={id} disabled={disabled}>
|
<AccordionItem key={id} value={id} disabled={disabled}>
|
||||||
@@ -29,35 +31,91 @@ const PermissionSection: React.FC<PermissionSectionConfig> = ({ id, title, Compo
|
|||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
);
|
);
|
||||||
|
|
||||||
const AssignPermissions = () => {
|
const PermissionGroup: React.FC<PermissionGroupConfig> = ({ title, description, sections }) => {
|
||||||
const { copyJobState } = useCopyJobContext();
|
|
||||||
const permissionSections = usePermissionSections(copyJobState);
|
|
||||||
const [openItems, setOpenItems] = React.useState<string[]>([]);
|
const [openItems, setOpenItems] = React.useState<string[]>([]);
|
||||||
|
|
||||||
const indentLevels = React.useMemo<IndentLevel[]>(
|
|
||||||
() => Array(copyJobState.migrationType === CopyJobMigrationType.Online ? 5 : 3).fill({ level: 0, width: "100%" }),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const firstIncompleteSection = permissionSections.find((section) => !section.completed);
|
const firstIncompleteSection = sections.find((section) => !section.completed);
|
||||||
const nextOpenItems = firstIncompleteSection ? [firstIncompleteSection.id] : [];
|
const nextOpenItems = firstIncompleteSection ? [firstIncompleteSection.id] : [];
|
||||||
if (JSON.stringify(openItems) !== JSON.stringify(nextOpenItems)) {
|
if (JSON.stringify(openItems) !== JSON.stringify(nextOpenItems)) {
|
||||||
setOpenItems(nextOpenItems);
|
setOpenItems(nextOpenItems);
|
||||||
}
|
}
|
||||||
}, [permissionSections]);
|
}, [sections]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="assignPermissionsContainer" tokens={{ childrenGap: 15 }}>
|
<Stack
|
||||||
<span>{ContainerCopyMessages.assignPermissions.description}</span>
|
tokens={{ childrenGap: 15 }}
|
||||||
{permissionSections?.length === 0 ? (
|
styles={{
|
||||||
|
root: {
|
||||||
|
background: "#fafafa",
|
||||||
|
border: "1px solid #e1e1e1",
|
||||||
|
borderRadius: 8,
|
||||||
|
padding: 16,
|
||||||
|
boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack tokens={{ childrenGap: 5 }}>
|
||||||
|
<Text variant="medium" style={{ fontWeight: 600 }}>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
|
{description && (
|
||||||
|
<Text variant="small" styles={{ root: { color: "#605E5C" } }}>
|
||||||
|
{description}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Accordion className="permissionsAccordion" collapsible openItems={openItems}>
|
||||||
|
{sections.map((section) => (
|
||||||
|
<PermissionSection key={section.id} {...section} />
|
||||||
|
))}
|
||||||
|
</Accordion>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const AssignPermissions = () => {
|
||||||
|
const { setValidationCache } = useCopyJobPrerequisitesCache();
|
||||||
|
const { copyJobState } = useCopyJobContext();
|
||||||
|
const permissionGroups = usePermissionSections(copyJobState);
|
||||||
|
|
||||||
|
const totalSectionsCount = React.useMemo(
|
||||||
|
() => permissionGroups.reduce((total, group) => total + group.sections.length, 0),
|
||||||
|
[permissionGroups],
|
||||||
|
);
|
||||||
|
|
||||||
|
const indentLevels = React.useMemo<IndentLevel[]>(
|
||||||
|
() => Array(copyJobState.migrationType === CopyJobMigrationType.Online ? 5 : 3).fill({ level: 0, width: "100%" }),
|
||||||
|
[copyJobState.migrationType],
|
||||||
|
);
|
||||||
|
|
||||||
|
const isSameAccount = isIntraAccountCopy(copyJobState?.source?.account?.id, copyJobState?.target?.account?.id);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
setValidationCache(new Map<string, boolean>());
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack className="assignPermissionsContainer" tokens={{ childrenGap: 20 }}>
|
||||||
|
<Text variant="medium">
|
||||||
|
{isSameAccount && copyJobState.migrationType === CopyJobMigrationType.Online
|
||||||
|
? ContainerCopyMessages.assignPermissions.intraAccountOnlineDescription(
|
||||||
|
copyJobState?.source?.account?.name || "",
|
||||||
|
)
|
||||||
|
: ContainerCopyMessages.assignPermissions.crossAccountDescription}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{totalSectionsCount === 0 ? (
|
||||||
<ShimmerTree indentLevels={indentLevels} style={{ width: "100%" }} />
|
<ShimmerTree indentLevels={indentLevels} style={{ width: "100%" }} />
|
||||||
) : (
|
) : (
|
||||||
<Accordion className="permissionsAccordion" collapsible openItems={openItems}>
|
<Stack tokens={{ childrenGap: 25 }}>
|
||||||
{permissionSections.map((section) => (
|
{permissionGroups.map((group) => (
|
||||||
<PermissionSection key={section.id} {...section} />
|
<PermissionGroup key={group.id} {...group} />
|
||||||
))}
|
))}
|
||||||
</Accordion>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import { Link, PrimaryButton, Stack } from "@fluentui/react";
|
|||||||
import { DatabaseAccount } from "Contracts/DataModels";
|
import { DatabaseAccount } from "Contracts/DataModels";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { fetchDatabaseAccount } from "Utils/arm/databaseAccountUtils";
|
import { fetchDatabaseAccount } from "Utils/arm/databaseAccountUtils";
|
||||||
|
import { CapabilityNames } from "../../../../../Common/Constants";
|
||||||
|
import LoadingOverlay from "../../../../../Common/LoadingOverlay";
|
||||||
|
import { logError } from "../../../../../Common/Logger";
|
||||||
|
import { update as updateDatabaseAccount } from "../../../../../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
import { getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
import { getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
||||||
@@ -19,8 +23,10 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
const [showRefreshButton, setShowRefreshButton] = React.useState(false);
|
const [showRefreshButton, setShowRefreshButton] = React.useState(false);
|
||||||
const intervalRef = React.useRef<NodeJS.Timeout | null>(null);
|
const intervalRef = React.useRef<NodeJS.Timeout | null>(null);
|
||||||
const timeoutRef = React.useRef<NodeJS.Timeout | null>(null);
|
const timeoutRef = React.useRef<NodeJS.Timeout | null>(null);
|
||||||
const { copyJobState: { source } = {}, setCopyJobState } = useCopyJobContext();
|
const { setContextError, copyJobState: { source } = {}, setCopyJobState } = useCopyJobContext();
|
||||||
const selectedSourceAccount = source?.account;
|
const selectedSourceAccount = source?.account;
|
||||||
|
const sourceAccountCapabilities = selectedSourceAccount?.properties?.capabilities ?? [];
|
||||||
|
|
||||||
const {
|
const {
|
||||||
subscriptionId: sourceSubscriptionId,
|
subscriptionId: sourceSubscriptionId,
|
||||||
resourceGroup: sourceResourceGroup,
|
resourceGroup: sourceResourceGroup,
|
||||||
@@ -38,16 +44,24 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching source account after enabling online copy:", error);
|
const errorMessage =
|
||||||
setLoading(false);
|
error.message || "Error fetching source account after enabling online copy. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/OnlineCopyEnabled.handleFetchAccount");
|
||||||
|
setContextError(errorMessage);
|
||||||
|
clearAccountFetchInterval();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearIntervalAndShowRefresh = () => {
|
const clearAccountFetchInterval = () => {
|
||||||
if (intervalRef.current) {
|
if (intervalRef.current) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
intervalRef.current = null;
|
intervalRef.current = null;
|
||||||
}
|
}
|
||||||
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearIntervalAndShowRefresh = () => {
|
||||||
|
clearAccountFetchInterval();
|
||||||
setShowRefreshButton(true);
|
setShowRefreshButton(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,18 +70,42 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
handleFetchAccount();
|
handleFetchAccount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOnlineCopyEnable = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
setShowRefreshButton(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
||||||
|
properties: {
|
||||||
|
enableAllVersionsAndDeletesChangeFeed: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
||||||
|
properties: {
|
||||||
|
capabilities: [...sourceAccountCapabilities, { name: CapabilityNames.EnableOnlineCopyFeature }],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
intervalRef.current = setInterval(() => {
|
||||||
|
handleFetchAccount();
|
||||||
|
}, 30 * 1000);
|
||||||
|
|
||||||
|
timeoutRef.current = setTimeout(
|
||||||
|
() => {
|
||||||
|
clearIntervalAndShowRefresh();
|
||||||
|
},
|
||||||
|
10 * 60 * 1000,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage = error.message || "Failed to enable online copy feature. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/OnlineCopyEnabled.handleOnlineCopyEnable");
|
||||||
|
setContextError(errorMessage);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
intervalRef.current = setInterval(() => {
|
|
||||||
handleFetchAccount();
|
|
||||||
}, 30 * 1000);
|
|
||||||
|
|
||||||
timeoutRef.current = setTimeout(
|
|
||||||
() => {
|
|
||||||
clearIntervalAndShowRefresh();
|
|
||||||
},
|
|
||||||
15 * 60 * 1000,
|
|
||||||
);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (intervalRef.current) {
|
if (intervalRef.current) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
@@ -82,6 +120,7 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="onlineCopyContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
<Stack className="onlineCopyContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
||||||
|
<LoadingOverlay isLoading={loading} label={ContainerCopyMessages.popoverOverlaySpinnerLabel} />
|
||||||
<Stack.Item className="info-message">
|
<Stack.Item className="info-message">
|
||||||
{ContainerCopyMessages.onlineCopyEnabled.description(source?.account?.name || "")} 
|
{ContainerCopyMessages.onlineCopyEnabled.description(source?.account?.name || "")} 
|
||||||
<Link href={ContainerCopyMessages.onlineCopyEnabled.href} target="_blank" rel="noopener noreferrer">
|
<Link href={ContainerCopyMessages.onlineCopyEnabled.href} target="_blank" rel="noopener noreferrer">
|
||||||
@@ -89,32 +128,7 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
</Stack.Item>
|
</Stack.Item>
|
||||||
<Stack.Item>
|
<Stack.Item>
|
||||||
<pre style={{ backgroundColor: "#f5f5f5", padding: "10px", borderRadius: "4px", overflow: "auto" }}>
|
{showRefreshButton ? (
|
||||||
<code>
|
|
||||||
{`# Set shell variables
|
|
||||||
$resourceGroupName = <azure_resource_group>
|
|
||||||
$accountName = <azure_cosmos_db_account_name>
|
|
||||||
$EnableOnlineContainerCopy = "EnableOnlineContainerCopy"
|
|
||||||
|
|
||||||
# List down existing capabilities of your account
|
|
||||||
$cosmosdb = az cosmosdb show --resource-group $resourceGroupName --name $accountName
|
|
||||||
|
|
||||||
$capabilities = (($cosmosdb | ConvertFrom-Json).capabilities)
|
|
||||||
|
|
||||||
# Append EnableOnlineContainerCopy capability in the list of capabilities
|
|
||||||
$capabilitiesToAdd = @()
|
|
||||||
foreach ($item in $capabilities) {
|
|
||||||
$capabilitiesToAdd += $item.name
|
|
||||||
}
|
|
||||||
$capabilitiesToAdd += $EnableOnlineContainerCopy
|
|
||||||
|
|
||||||
# Update Cosmos DB account
|
|
||||||
az cosmosdb update --capabilities $capabilitiesToAdd -n $accountName -g $resourceGroupName`}
|
|
||||||
</code>
|
|
||||||
</pre>
|
|
||||||
</Stack.Item>
|
|
||||||
{showRefreshButton && (
|
|
||||||
<Stack.Item>
|
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
className="fullWidth"
|
className="fullWidth"
|
||||||
text={ContainerCopyMessages.refreshButtonLabel}
|
text={ContainerCopyMessages.refreshButtonLabel}
|
||||||
@@ -122,8 +136,16 @@ az cosmosdb update --capabilities $capabilitiesToAdd -n $accountName -g $resourc
|
|||||||
onClick={handleRefresh}
|
onClick={handleRefresh}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
</Stack.Item>
|
) : (
|
||||||
)}
|
<PrimaryButton
|
||||||
|
className="fullWidth"
|
||||||
|
text={loading ? "" : ContainerCopyMessages.onlineCopyEnabled.buttonText}
|
||||||
|
{...(loading ? { iconProps: { iconName: "SyncStatusSolid" } } : {})}
|
||||||
|
disabled={loading}
|
||||||
|
onClick={handleOnlineCopyEnable}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack.Item>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Link, PrimaryButton, Stack, Text } from "@fluentui/react";
|
|||||||
import { DatabaseAccount } from "Contracts/DataModels";
|
import { DatabaseAccount } from "Contracts/DataModels";
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { fetchDatabaseAccount } from "Utils/arm/databaseAccountUtils";
|
import { fetchDatabaseAccount } from "Utils/arm/databaseAccountUtils";
|
||||||
|
import LoadingOverlay from "../../../../../Common/LoadingOverlay";
|
||||||
|
import { logError } from "../../../../../Common/Logger";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
import { buildResourceLink, getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
import { buildResourceLink, getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
||||||
@@ -63,23 +65,30 @@ const PointInTimeRestore: React.FC = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching source account after Point-in-Time Restore:", error);
|
const errorMessage =
|
||||||
setLoading(false);
|
error.message || "Error fetching source account after Point-in-Time Restore. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/PointInTimeRestore.handleFetchAccount");
|
||||||
|
clearAccountFetchInterval();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearIntervalAndShowRefresh = () => {
|
const clearAccountFetchInterval = () => {
|
||||||
if (intervalRef.current) {
|
if (intervalRef.current) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
intervalRef.current = null;
|
intervalRef.current = null;
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearIntervalAndShowRefresh = () => {
|
||||||
|
clearAccountFetchInterval();
|
||||||
setShowRefreshButton(true);
|
setShowRefreshButton(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
handleFetchAccount();
|
await handleFetchAccount();
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const openWindowAndMonitor = () => {
|
const openWindowAndMonitor = () => {
|
||||||
@@ -95,12 +104,13 @@ const PointInTimeRestore: React.FC = () => {
|
|||||||
() => {
|
() => {
|
||||||
clearIntervalAndShowRefresh();
|
clearIntervalAndShowRefresh();
|
||||||
},
|
},
|
||||||
15 * 60 * 1000,
|
10 * 60 * 1000,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="pointInTimeRestoreContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
<Stack className="pointInTimeRestoreContainer" tokens={{ childrenGap: 15, padding: "0 0 0 20px" }}>
|
||||||
|
<LoadingOverlay isLoading={loading} label={ContainerCopyMessages.popoverOverlaySpinnerLabel} />
|
||||||
<Stack.Item className="toggle-label">
|
<Stack.Item className="toggle-label">
|
||||||
{ContainerCopyMessages.pointInTimeRestore.description(source.account?.name ?? "")}
|
{ContainerCopyMessages.pointInTimeRestore.description(source.account?.name ?? "")}
|
||||||
{tooltipContent && (
|
{tooltipContent && (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DatabaseAccount } from "Contracts/DataModels";
|
import { DatabaseAccount } from "Contracts/DataModels";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
import { logError } from "../../../../../../Common/Logger";
|
||||||
import { useCopyJobContext } from "../../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../../Context/CopyJobContext";
|
||||||
import { getAccountDetailsFromResourceId } from "../../../../CopyJobUtils";
|
import { getAccountDetailsFromResourceId } from "../../../../CopyJobUtils";
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ interface UseManagedIdentityUpdaterReturn {
|
|||||||
const useManagedIdentity = (
|
const useManagedIdentity = (
|
||||||
updateIdentityFn: UseManagedIdentityUpdaterParams["updateIdentityFn"],
|
updateIdentityFn: UseManagedIdentityUpdaterParams["updateIdentityFn"],
|
||||||
): UseManagedIdentityUpdaterReturn => {
|
): UseManagedIdentityUpdaterReturn => {
|
||||||
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
const { copyJobState, setCopyJobState, setContextError } = useCopyJobContext();
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const handleAddSystemIdentity = useCallback(async (): Promise<void> => {
|
const handleAddSystemIdentity = useCallback(async (): Promise<void> => {
|
||||||
@@ -40,7 +41,9 @@ const useManagedIdentity = (
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error enabling system-assigned managed identity:", error);
|
const errorMessage = error.message || "Error enabling system-assigned managed identity. Please try again later.";
|
||||||
|
logError(errorMessage, "CopyJob/useManagedIdentity.handleAddSystemIdentity");
|
||||||
|
setContextError(errorMessage);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
|||||||
import { CapabilityNames } from "../../../../../../Common/Constants";
|
import { CapabilityNames } from "../../../../../../Common/Constants";
|
||||||
import { fetchRoleAssignments, fetchRoleDefinitions, RoleDefinitionType } from "../../../../../../Utils/arm/RbacUtils";
|
import { fetchRoleAssignments, fetchRoleDefinitions, RoleDefinitionType } from "../../../../../../Utils/arm/RbacUtils";
|
||||||
import ContainerCopyMessages from "../../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../../ContainerCopyMessages";
|
||||||
import { getAccountDetailsFromResourceId } from "../../../../CopyJobUtils";
|
import { getAccountDetailsFromResourceId, getContainerIdentifiers, isIntraAccountCopy } from "../../../../CopyJobUtils";
|
||||||
import {
|
import {
|
||||||
BackupPolicyType,
|
BackupPolicyType,
|
||||||
CopyJobMigrationType,
|
CopyJobMigrationType,
|
||||||
@@ -26,6 +26,13 @@ export interface PermissionSectionConfig {
|
|||||||
validate?: (state: CopyJobContextState) => boolean | Promise<boolean>;
|
validate?: (state: CopyJobContextState) => boolean | Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PermissionGroupConfig {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
sections: PermissionSectionConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
export const SECTION_IDS = {
|
export const SECTION_IDS = {
|
||||||
addManagedIdentity: "addManagedIdentity",
|
addManagedIdentity: "addManagedIdentity",
|
||||||
defaultManagedIdentity: "defaultManagedIdentity",
|
defaultManagedIdentity: "defaultManagedIdentity",
|
||||||
@@ -127,24 +134,81 @@ export function checkTargetHasReaderRoleOnSource(roleDefinitions: RoleDefinition
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the permission sections configuration for the Assign Permissions screen.
|
* Validates sections within a group sequentially.
|
||||||
* Memoizes derived values for performance and decouples logic for testability.
|
|
||||||
*/
|
*/
|
||||||
const usePermissionSections = (state: CopyJobContextState): PermissionSectionConfig[] => {
|
const validateSectionsInGroup = async (
|
||||||
const sourceAccountId = state?.source?.account?.id || "";
|
sections: PermissionSectionConfig[],
|
||||||
const targetAccountId = state?.target?.account?.id || "";
|
state: CopyJobContextState,
|
||||||
|
validationCache: Map<string, boolean>,
|
||||||
|
): Promise<PermissionSectionConfig[]> => {
|
||||||
|
const result: PermissionSectionConfig[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < sections.length; i++) {
|
||||||
|
const section = sections[i];
|
||||||
|
|
||||||
|
if (validationCache.has(section.id) && validationCache.get(section.id) === true) {
|
||||||
|
result.push({ ...section, completed: true });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.validate) {
|
||||||
|
const isValid = await section.validate(state);
|
||||||
|
validationCache.set(section.id, isValid);
|
||||||
|
result.push({ ...section, completed: isValid });
|
||||||
|
|
||||||
|
if (!isValid) {
|
||||||
|
// Mark remaining sections in this group as incomplete
|
||||||
|
for (let j = i + 1; j < sections.length; j++) {
|
||||||
|
result.push({ ...sections[j], completed: false });
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
validationCache.set(section.id, false);
|
||||||
|
result.push({ ...section, completed: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the permission groups configuration for the Assign Permissions screen.
|
||||||
|
* Groups validate independently but sections within each group validate sequentially.
|
||||||
|
*/
|
||||||
|
const usePermissionSections = (state: CopyJobContextState): PermissionGroupConfig[] => {
|
||||||
|
const sourceAccount = getContainerIdentifiers(state.source);
|
||||||
|
const targetAccount = getContainerIdentifiers(state.target);
|
||||||
|
|
||||||
const { validationCache, setValidationCache } = useCopyJobPrerequisitesCache();
|
const { validationCache, setValidationCache } = useCopyJobPrerequisitesCache();
|
||||||
const [permissionSections, setPermissionSections] = useState<PermissionSectionConfig[] | null>(null);
|
const [permissionGroups, setPermissionGroups] = useState<PermissionGroupConfig[] | null>(null);
|
||||||
const isValidatingRef = useRef(false);
|
const isValidatingRef = useRef(false);
|
||||||
|
|
||||||
const sectionToValidate = useMemo(() => {
|
const groupsToValidate = useMemo(() => {
|
||||||
const baseSections = sourceAccountId === targetAccountId ? [] : [...PERMISSION_SECTIONS_CONFIG];
|
const isSameAccount = isIntraAccountCopy(sourceAccount.accountId, targetAccount.accountId);
|
||||||
if (state.migrationType === CopyJobMigrationType.Online) {
|
const commonSections = isSameAccount ? [] : [...PERMISSION_SECTIONS_CONFIG];
|
||||||
return [...baseSections, ...PERMISSION_SECTIONS_FOR_ONLINE_JOBS];
|
const groups: PermissionGroupConfig[] = [];
|
||||||
|
|
||||||
|
if (commonSections.length > 0) {
|
||||||
|
groups.push({
|
||||||
|
id: "commonConfigs",
|
||||||
|
title: ContainerCopyMessages.assignPermissions.commonConfiguration.title,
|
||||||
|
description: ContainerCopyMessages.assignPermissions.commonConfiguration.description,
|
||||||
|
sections: commonSections,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return baseSections;
|
|
||||||
}, [sourceAccountId, targetAccountId, state.migrationType]);
|
if (state.migrationType === CopyJobMigrationType.Online) {
|
||||||
|
groups.push({
|
||||||
|
id: "onlineConfigs",
|
||||||
|
title: ContainerCopyMessages.assignPermissions.onlineConfiguration.title,
|
||||||
|
description: ContainerCopyMessages.assignPermissions.onlineConfiguration.description,
|
||||||
|
sections: [...PERMISSION_SECTIONS_FOR_ONLINE_JOBS],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}, [sourceAccount.accountId, targetAccount.accountId, state.migrationType]);
|
||||||
|
|
||||||
const memoizedValidationCache = useMemo(() => {
|
const memoizedValidationCache = useMemo(() => {
|
||||||
if (state.migrationType === CopyJobMigrationType.Offline) {
|
if (state.migrationType === CopyJobMigrationType.Offline) {
|
||||||
@@ -155,52 +219,39 @@ const usePermissionSections = (state: CopyJobContextState): PermissionSectionCon
|
|||||||
}, [state.migrationType]);
|
}, [state.migrationType]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const validateSections = async () => {
|
const validateGroups = async () => {
|
||||||
if (isValidatingRef.current) {
|
if (isValidatingRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidatingRef.current = true;
|
isValidatingRef.current = true;
|
||||||
const result: PermissionSectionConfig[] = [];
|
|
||||||
const newValidationCache = new Map(memoizedValidationCache);
|
const newValidationCache = new Map(memoizedValidationCache);
|
||||||
|
|
||||||
for (let i = 0; i < sectionToValidate.length; i++) {
|
// Validate all groups independently (in parallel)
|
||||||
const section = sectionToValidate[i];
|
const validatedGroups = await Promise.all(
|
||||||
|
groupsToValidate.map(async (group) => {
|
||||||
|
const validatedSections = await validateSectionsInGroup(group.sections, state, newValidationCache);
|
||||||
|
|
||||||
if (newValidationCache.has(section.id) && newValidationCache.get(section.id) === true) {
|
return {
|
||||||
result.push({ ...section, completed: true });
|
...group,
|
||||||
continue;
|
sections: validatedSections,
|
||||||
}
|
};
|
||||||
if (section.validate) {
|
}),
|
||||||
const isValid = await section.validate(state);
|
);
|
||||||
newValidationCache.set(section.id, isValid);
|
|
||||||
result.push({ ...section, completed: isValid });
|
|
||||||
|
|
||||||
if (!isValid) {
|
|
||||||
for (let j = i + 1; j < sectionToValidate.length; j++) {
|
|
||||||
result.push({ ...sectionToValidate[j], completed: false });
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newValidationCache.set(section.id, false);
|
|
||||||
result.push({ ...section, completed: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setValidationCache(newValidationCache);
|
setValidationCache(newValidationCache);
|
||||||
setPermissionSections(result);
|
setPermissionGroups(validatedGroups);
|
||||||
isValidatingRef.current = false;
|
isValidatingRef.current = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
validateSections();
|
validateGroups();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
isValidatingRef.current = false;
|
isValidatingRef.current = false;
|
||||||
};
|
};
|
||||||
}, [state, sectionToValidate]);
|
}, [state, groupsToValidate]);
|
||||||
|
|
||||||
return permissionSections ?? [];
|
return permissionGroups ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default usePermissionSections;
|
export default usePermissionSections;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import { DefaultButton, PrimaryButton, Stack, Text } from "@fluentui/react";
|
import { DefaultButton, PrimaryButton, Stack, Text } from "@fluentui/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import LoadingOverlay from "../../../../../Common/LoadingOverlay";
|
||||||
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
|
|
||||||
interface PopoverContainerProps {
|
interface PopoverContainerProps {
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
@@ -19,17 +21,13 @@ const PopoverContainer: React.FC<PopoverContainerProps> = React.memo(
|
|||||||
tokens={{ childrenGap: 20 }}
|
tokens={{ childrenGap: 20 }}
|
||||||
style={{ maxWidth: 450 }}
|
style={{ maxWidth: 450 }}
|
||||||
>
|
>
|
||||||
|
<LoadingOverlay isLoading={isLoading} label={ContainerCopyMessages.popoverOverlaySpinnerLabel} />
|
||||||
<Text variant="mediumPlus" style={{ fontWeight: 600 }}>
|
<Text variant="mediumPlus" style={{ fontWeight: 600 }}>
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>{children}</Text>
|
<Text>{children}</Text>
|
||||||
<Stack horizontal tokens={{ childrenGap: 20 }}>
|
<Stack horizontal tokens={{ childrenGap: 20 }}>
|
||||||
<PrimaryButton
|
<PrimaryButton text={"Yes"} onClick={onPrimary} disabled={isLoading} />
|
||||||
text={isLoading ? "" : "Yes"}
|
|
||||||
{...(isLoading ? { iconProps: { iconName: "SyncStatusSolid" } } : {})}
|
|
||||||
onClick={onPrimary}
|
|
||||||
disabled={isLoading}
|
|
||||||
/>
|
|
||||||
<DefaultButton text="No" onClick={onCancel} disabled={isLoading} />
|
<DefaultButton text="No" onClick={onCancel} disabled={isLoading} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Stack, Text } from "@fluentui/react";
|
||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
|
import { useSidePanel } from "hooks/useSidePanel";
|
||||||
|
import { produce } from "immer";
|
||||||
|
import React, { useCallback, useEffect } from "react";
|
||||||
|
import { AddCollectionPanel } from "../../../../Panes/AddCollectionPanel/AddCollectionPanel";
|
||||||
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
|
|
||||||
|
type AddCollectionPanelWrapperProps = {
|
||||||
|
explorer?: Explorer;
|
||||||
|
goBack?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const AddCollectionPanelWrapper: React.FunctionComponent<AddCollectionPanelWrapperProps> = ({ explorer, goBack }) => {
|
||||||
|
const { setCopyJobState } = useCopyJobContext();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const sidePanelStore = useSidePanel.getState();
|
||||||
|
if (sidePanelStore.headerText !== ContainerCopyMessages.createContainerHeading) {
|
||||||
|
sidePanelStore.setHeaderText(ContainerCopyMessages.createContainerHeading);
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
sidePanelStore.setHeaderText(ContainerCopyMessages.createCopyJobPanelTitle);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleAddCollectionSuccess = useCallback(
|
||||||
|
(collectionData: { databaseId: string; collectionId: string }) => {
|
||||||
|
setCopyJobState(
|
||||||
|
produce((state) => {
|
||||||
|
state.target.databaseId = collectionData.databaseId;
|
||||||
|
state.target.containerId = collectionData.collectionId;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
goBack?.();
|
||||||
|
},
|
||||||
|
[goBack],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack className="addCollectionPanelWrapper">
|
||||||
|
<Stack.Item className="addCollectionPanelHeader">
|
||||||
|
<Text>{ContainerCopyMessages.createNewContainerSubHeading}</Text>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item className="addCollectionPanelBody">
|
||||||
|
<AddCollectionPanel explorer={explorer} isCopyJobFlow={true} onSubmitSuccess={handleAddCollectionSuccess} />
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddCollectionPanelWrapper;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useCopyJobContext } from "../../Context/CopyJobContext";
|
||||||
import { useCopyJobNavigation } from "../Utils/useCopyJobNavigation";
|
import { useCopyJobNavigation } from "../Utils/useCopyJobNavigation";
|
||||||
import NavigationControls from "./Components/NavigationControls";
|
import NavigationControls from "./Components/NavigationControls";
|
||||||
|
|
||||||
@@ -12,27 +13,27 @@ const CreateCopyJobScreens: React.FC = () => {
|
|||||||
handlePrevious,
|
handlePrevious,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
primaryBtnText,
|
primaryBtnText,
|
||||||
error,
|
showAddCollectionPanel,
|
||||||
setError,
|
|
||||||
} = useCopyJobNavigation();
|
} = useCopyJobNavigation();
|
||||||
|
const { contextError, setContextError } = useCopyJobContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack verticalAlign="space-between" className="createCopyJobScreensContainer">
|
<Stack verticalAlign="space-between" className="createCopyJobScreensContainer">
|
||||||
<Stack.Item className="createCopyJobScreensContent">
|
<Stack.Item className="createCopyJobScreensContent">
|
||||||
{error && (
|
{contextError && (
|
||||||
<MessageBar
|
<MessageBar
|
||||||
className="createCopyJobErrorMessageBar"
|
className="createCopyJobErrorMessageBar"
|
||||||
messageBarType={MessageBarType.blocked}
|
messageBarType={MessageBarType.blocked}
|
||||||
isMultiline={false}
|
isMultiline={false}
|
||||||
onDismiss={() => setError(null)}
|
onDismiss={() => setContextError(null)}
|
||||||
dismissButtonAriaLabel="Close"
|
dismissButtonAriaLabel="Close"
|
||||||
truncated={true}
|
truncated={true}
|
||||||
overflowButtonAriaLabel="See more"
|
overflowButtonAriaLabel="See more"
|
||||||
>
|
>
|
||||||
{error}
|
{contextError}
|
||||||
</MessageBar>
|
</MessageBar>
|
||||||
)}
|
)}
|
||||||
{currentScreen?.component}
|
{React.cloneElement(currentScreen?.component as React.ReactElement, { showAddCollectionPanel })}
|
||||||
</Stack.Item>
|
</Stack.Item>
|
||||||
<Stack.Item className="createCopyJobScreensFooter">
|
<Stack.Item className="createCopyJobScreensFooter">
|
||||||
<NavigationControls
|
<NavigationControls
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import CopyJobContextProvider from "../../Context/CopyJobContext";
|
import CopyJobContextProvider from "../../Context/CopyJobContext";
|
||||||
import CreateCopyJobScreens from "./CreateCopyJobScreens";
|
import CreateCopyJobScreens from "./CreateCopyJobScreens";
|
||||||
|
|
||||||
const CreateCopyJobScreensProvider = () => {
|
const CreateCopyJobScreensProvider = ({ explorer }: { explorer: Explorer }) => {
|
||||||
return (
|
return (
|
||||||
<CopyJobContextProvider>
|
<CopyJobContextProvider explorer={explorer}>
|
||||||
<CreateCopyJobScreens />
|
<CreateCopyJobScreens />
|
||||||
</CopyJobContextProvider>
|
</CopyJobContextProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { DetailsList, DetailsListLayoutMode, Stack, Text, TextField } from "@fluentui/react";
|
import { DetailsList, DetailsListLayoutMode, Stack, Text, TextField } from "@fluentui/react";
|
||||||
import FieldRow from "Explorer/ContainerCopy/CreateCopyJob/Screens/Components/FieldRow";
|
import React, { useEffect } from "react";
|
||||||
import React from "react";
|
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
|
import { getDefaultJobName } from "../../../CopyJobUtils";
|
||||||
|
import FieldRow from "../Components/FieldRow";
|
||||||
import { getPreviewCopyJobDetailsListColumns } from "./Utils/PreviewCopyJobUtils";
|
import { getPreviewCopyJobDetailsListColumns } from "./Utils/PreviewCopyJobUtils";
|
||||||
|
|
||||||
const PreviewCopyJob: React.FC = () => {
|
const PreviewCopyJob: React.FC = () => {
|
||||||
@@ -16,6 +17,11 @@ const PreviewCopyJob: React.FC = () => {
|
|||||||
targetContainerName: copyJobState.target?.containerId,
|
targetContainerName: copyJobState.target?.containerId,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onJobNameChange(undefined, getDefaultJobName(selectedDatabaseAndContainers));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const jobName = copyJobState.jobName;
|
const jobName = copyJobState.jobName;
|
||||||
|
|
||||||
const onJobNameChange = (_ev?: React.FormEvent, newValue?: string) => {
|
const onJobNameChange = (_ev?: React.FormEvent, newValue?: string) => {
|
||||||
|
|||||||
@@ -27,4 +27,5 @@ export const AccountDropdown: React.FC<AccountDropdownProps> = React.memo(
|
|||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
),
|
),
|
||||||
|
(prev, next) => prev.options.length === next.options.length && prev.selectedKey === next.selectedKey,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,4 +25,5 @@ export const SubscriptionDropdown: React.FC<SubscriptionDropdownProps> = React.m
|
|||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
),
|
),
|
||||||
|
(prev, next) => prev.options.length === next.options.length && prev.selectedKey === next.selectedKey,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { useDropdownOptions, useEventHandlers } from "./Utils/selectAccountUtils
|
|||||||
const SelectAccount = React.memo(() => {
|
const SelectAccount = React.memo(() => {
|
||||||
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
||||||
const selectedSubscriptionId = copyJobState?.source?.subscription?.subscriptionId;
|
const selectedSubscriptionId = copyJobState?.source?.subscription?.subscriptionId;
|
||||||
|
const selectedSourceAccountId = copyJobState?.source?.account?.id;
|
||||||
|
|
||||||
const subscriptions: Subscription[] = useSubscriptions();
|
const subscriptions: Subscription[] = useSubscriptions();
|
||||||
const allAccounts: DatabaseAccount[] = useDatabaseAccounts(selectedSubscriptionId);
|
const allAccounts: DatabaseAccount[] = useDatabaseAccounts(selectedSubscriptionId);
|
||||||
@@ -38,7 +39,7 @@ const SelectAccount = React.memo(() => {
|
|||||||
|
|
||||||
<AccountDropdown
|
<AccountDropdown
|
||||||
options={accountOptions}
|
options={accountOptions}
|
||||||
selectedKey={copyJobState?.source?.account?.id}
|
selectedKey={selectedSourceAccountId}
|
||||||
disabled={!selectedSubscriptionId}
|
disabled={!selectedSubscriptionId}
|
||||||
onChange={(_ev, option) => handleSelectSourceAccount("account", option?.data)}
|
onChange={(_ev, option) => handleSelectSourceAccount("account", option?.data)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from "react";
|
|||||||
import { DatabaseAccount, Subscription } from "../../../../../../Contracts/DataModels";
|
import { DatabaseAccount, Subscription } from "../../../../../../Contracts/DataModels";
|
||||||
import { CopyJobMigrationType } from "../../../../Enums/CopyJobEnums";
|
import { CopyJobMigrationType } from "../../../../Enums/CopyJobEnums";
|
||||||
import { CopyJobContextProviderType, CopyJobContextState, DropdownOptionType } from "../../../../Types/CopyJobTypes";
|
import { CopyJobContextProviderType, CopyJobContextState, DropdownOptionType } from "../../../../Types/CopyJobTypes";
|
||||||
|
import { useCopyJobPrerequisitesCache } from "../../../Utils/useCopyJobPrerequisitesCache";
|
||||||
|
|
||||||
export function useDropdownOptions(
|
export function useDropdownOptions(
|
||||||
subscriptions: Subscription[],
|
subscriptions: Subscription[],
|
||||||
@@ -36,6 +37,7 @@ export function useDropdownOptions(
|
|||||||
type setCopyJobStateType = CopyJobContextProviderType["setCopyJobState"];
|
type setCopyJobStateType = CopyJobContextProviderType["setCopyJobState"];
|
||||||
|
|
||||||
export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
||||||
|
const { setValidationCache } = useCopyJobPrerequisitesCache();
|
||||||
const handleSelectSourceAccount = React.useCallback(
|
const handleSelectSourceAccount = React.useCallback(
|
||||||
(type: "subscription" | "account", data: (Subscription & DatabaseAccount) | undefined) => {
|
(type: "subscription" | "account", data: (Subscription & DatabaseAccount) | undefined) => {
|
||||||
setCopyJobState((prevState: CopyJobContextState) => {
|
setCopyJobState((prevState: CopyJobContextState) => {
|
||||||
@@ -60,8 +62,9 @@ export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
|||||||
}
|
}
|
||||||
return prevState;
|
return prevState;
|
||||||
});
|
});
|
||||||
|
setValidationCache(new Map<string, boolean>());
|
||||||
},
|
},
|
||||||
[setCopyJobState],
|
[setCopyJobState, setValidationCache],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleMigrationTypeChange = React.useCallback(
|
const handleMigrationTypeChange = React.useCallback(
|
||||||
@@ -70,8 +73,9 @@ export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
|||||||
...prevState,
|
...prevState,
|
||||||
migrationType: checked ? CopyJobMigrationType.Offline : CopyJobMigrationType.Online,
|
migrationType: checked ? CopyJobMigrationType.Offline : CopyJobMigrationType.Online,
|
||||||
}));
|
}));
|
||||||
|
setValidationCache(new Map<string, boolean>());
|
||||||
},
|
},
|
||||||
[setCopyJobState],
|
[setCopyJobState, setValidationCache],
|
||||||
);
|
);
|
||||||
|
|
||||||
return { handleSelectSourceAccount, handleMigrationTypeChange };
|
return { handleSelectSourceAccount, handleMigrationTypeChange };
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ import { DatabaseContainerSection } from "./components/DatabaseContainerSection"
|
|||||||
import { dropDownChangeHandler } from "./Events/DropDownChangeHandler";
|
import { dropDownChangeHandler } from "./Events/DropDownChangeHandler";
|
||||||
import { useMemoizedSourceAndTargetData } from "./memoizedData";
|
import { useMemoizedSourceAndTargetData } from "./memoizedData";
|
||||||
|
|
||||||
const SelectSourceAndTargetContainers = () => {
|
type SelectSourceAndTargetContainers = {
|
||||||
|
showAddCollectionPanel?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SelectSourceAndTargetContainers = ({ showAddCollectionPanel }: SelectSourceAndTargetContainers) => {
|
||||||
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
const { copyJobState, setCopyJobState } = useCopyJobContext();
|
||||||
const { source, target, sourceDbParams, sourceContainerParams, targetDbParams, targetContainerParams } =
|
const { source, target, sourceDbParams, sourceContainerParams, targetDbParams, targetContainerParams } =
|
||||||
useMemoizedSourceAndTargetData(copyJobState);
|
useMemoizedSourceAndTargetData(copyJobState);
|
||||||
@@ -62,6 +66,7 @@ const SelectSourceAndTargetContainers = () => {
|
|||||||
selectedContainer={target?.containerId}
|
selectedContainer={target?.containerId}
|
||||||
containerDisabled={!target?.databaseId}
|
containerDisabled={!target?.databaseId}
|
||||||
containerOnChange={onDropdownChange("targetContainer")}
|
containerOnChange={onDropdownChange("targetContainer")}
|
||||||
|
handleOnDemandCreateContainer={showAddCollectionPanel}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Dropdown, Stack } from "@fluentui/react";
|
import { ActionButton, Dropdown, Stack } from "@fluentui/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ContainerCopyMessages from "../../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../../ContainerCopyMessages";
|
||||||
import { DatabaseContainerSectionProps } from "../../../../Types/CopyJobTypes";
|
import { DatabaseContainerSectionProps } from "../../../../Types/CopyJobTypes";
|
||||||
@@ -14,6 +14,7 @@ export const DatabaseContainerSection = ({
|
|||||||
selectedContainer,
|
selectedContainer,
|
||||||
containerDisabled,
|
containerDisabled,
|
||||||
containerOnChange,
|
containerOnChange,
|
||||||
|
handleOnDemandCreateContainer,
|
||||||
}: DatabaseContainerSectionProps) => (
|
}: DatabaseContainerSectionProps) => (
|
||||||
<Stack tokens={{ childrenGap: 15 }} className="databaseContainerSection">
|
<Stack tokens={{ childrenGap: 15 }} className="databaseContainerSection">
|
||||||
<label className="subHeading">{heading}</label>
|
<label className="subHeading">{heading}</label>
|
||||||
@@ -29,15 +30,22 @@ export const DatabaseContainerSection = ({
|
|||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
<FieldRow label={ContainerCopyMessages.containerDropdownLabel}>
|
<FieldRow label={ContainerCopyMessages.containerDropdownLabel}>
|
||||||
<Dropdown
|
<Stack>
|
||||||
placeholder={ContainerCopyMessages.containerDropdownPlaceholder}
|
<Dropdown
|
||||||
ariaLabel={ContainerCopyMessages.containerDropdownLabel}
|
placeholder={ContainerCopyMessages.containerDropdownPlaceholder}
|
||||||
options={containerOptions}
|
ariaLabel={ContainerCopyMessages.containerDropdownLabel}
|
||||||
required
|
options={containerOptions}
|
||||||
disabled={!!containerDisabled}
|
required
|
||||||
selectedKey={selectedContainer}
|
disabled={!!containerDisabled}
|
||||||
onChange={containerOnChange}
|
selectedKey={selectedContainer}
|
||||||
/>
|
onChange={containerOnChange}
|
||||||
|
/>
|
||||||
|
{handleOnDemandCreateContainer && (
|
||||||
|
<ActionButton className="create-container-link-btn" onClick={() => handleOnDemandCreateContainer()}>
|
||||||
|
{ContainerCopyMessages.createContainerButtonLabel}
|
||||||
|
</ActionButton>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useCallback, useMemo, useReducer, useState } from "react";
|
|||||||
import { useSidePanel } from "../../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../../hooks/useSidePanel";
|
||||||
import { submitCreateCopyJob } from "../../Actions/CopyJobActions";
|
import { submitCreateCopyJob } from "../../Actions/CopyJobActions";
|
||||||
import { useCopyJobContext } from "../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../Context/CopyJobContext";
|
||||||
|
import { getContainerIdentifiers, isIntraAccountCopy } from "../../CopyJobUtils";
|
||||||
import { CopyJobMigrationType } from "../../Enums/CopyJobEnums";
|
import { CopyJobMigrationType } from "../../Enums/CopyJobEnums";
|
||||||
import { useCopyJobPrerequisitesCache } from "./useCopyJobPrerequisitesCache";
|
import { useCopyJobPrerequisitesCache } from "./useCopyJobPrerequisitesCache";
|
||||||
import { SCREEN_KEYS, useCreateCopyJobScreensList } from "./useCreateCopyJobScreensList";
|
import { SCREEN_KEYS, useCreateCopyJobScreensList } from "./useCreateCopyJobScreensList";
|
||||||
@@ -33,12 +34,15 @@ function navigationReducer(state: NavigationState, action: Action): NavigationSt
|
|||||||
|
|
||||||
export function useCopyJobNavigation() {
|
export function useCopyJobNavigation() {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const { copyJobState, resetCopyJobState, setContextError } = useCopyJobContext();
|
||||||
const { copyJobState, resetCopyJobState } = useCopyJobContext();
|
|
||||||
const screens = useCreateCopyJobScreensList();
|
|
||||||
const { validationCache: cache } = useCopyJobPrerequisitesCache();
|
const { validationCache: cache } = useCopyJobPrerequisitesCache();
|
||||||
const [state, dispatch] = useReducer(navigationReducer, { screenHistory: [SCREEN_KEYS.SelectAccount] });
|
const [state, dispatch] = useReducer(navigationReducer, { screenHistory: [SCREEN_KEYS.SelectAccount] });
|
||||||
|
|
||||||
|
const handlePrevious = useCallback(() => {
|
||||||
|
dispatch({ type: "PREVIOUS" });
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
|
const screens = useCreateCopyJobScreensList(handlePrevious);
|
||||||
const currentScreenKey = state.screenHistory[state.screenHistory.length - 1];
|
const currentScreenKey = state.screenHistory[state.screenHistory.length - 1];
|
||||||
const currentScreen = screens.find((screen) => screen.key === currentScreenKey);
|
const currentScreen = screens.find((screen) => screen.key === currentScreenKey);
|
||||||
|
|
||||||
@@ -51,7 +55,9 @@ export function useCopyJobNavigation() {
|
|||||||
}, [currentScreen.key, copyJobState, cache, isLoading]);
|
}, [currentScreen.key, copyJobState, cache, isLoading]);
|
||||||
|
|
||||||
const primaryBtnText = useMemo(() => {
|
const primaryBtnText = useMemo(() => {
|
||||||
if (currentScreenKey === SCREEN_KEYS.PreviewCopyJob) {
|
if (currentScreenKey === SCREEN_KEYS.CreateCollection) {
|
||||||
|
return "Create";
|
||||||
|
} else if (currentScreenKey === SCREEN_KEYS.PreviewCopyJob) {
|
||||||
return "Copy";
|
return "Copy";
|
||||||
}
|
}
|
||||||
return "Next";
|
return "Next";
|
||||||
@@ -65,24 +71,13 @@ export function useCopyJobNavigation() {
|
|||||||
useSidePanel.getState().closeSidePanel();
|
useSidePanel.getState().closeSidePanel();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getContainerIdentifiers = (container: typeof copyJobState.source | typeof copyJobState.target) => ({
|
|
||||||
accountId: container?.account?.id || "",
|
|
||||||
databaseId: container?.databaseId || "",
|
|
||||||
containerId: container?.containerId || "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const isSameAccount = (
|
|
||||||
sourceIds: ReturnType<typeof getContainerIdentifiers>,
|
|
||||||
targetIds: ReturnType<typeof getContainerIdentifiers>,
|
|
||||||
) => sourceIds.accountId === targetIds.accountId;
|
|
||||||
|
|
||||||
const areContainersIdentical = () => {
|
const areContainersIdentical = () => {
|
||||||
const { source, target } = copyJobState;
|
const { source, target } = copyJobState;
|
||||||
const sourceIds = getContainerIdentifiers(source);
|
const sourceIds = getContainerIdentifiers(source);
|
||||||
const targetIds = getContainerIdentifiers(target);
|
const targetIds = getContainerIdentifiers(target);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
isSameAccount(sourceIds, targetIds) &&
|
isIntraAccountCopy(sourceIds.accountId, targetIds.accountId) &&
|
||||||
sourceIds.databaseId === targetIds.databaseId &&
|
sourceIds.databaseId === targetIds.databaseId &&
|
||||||
sourceIds.containerId === targetIds.containerId
|
sourceIds.containerId === targetIds.containerId
|
||||||
);
|
);
|
||||||
@@ -90,9 +85,10 @@ export function useCopyJobNavigation() {
|
|||||||
|
|
||||||
const shouldNotShowPermissionScreen = () => {
|
const shouldNotShowPermissionScreen = () => {
|
||||||
const { source, target, migrationType } = copyJobState;
|
const { source, target, migrationType } = copyJobState;
|
||||||
|
const sourceIds = getContainerIdentifiers(source);
|
||||||
|
const targetIds = getContainerIdentifiers(target);
|
||||||
return (
|
return (
|
||||||
migrationType === CopyJobMigrationType.Offline &&
|
migrationType === CopyJobMigrationType.Offline && isIntraAccountCopy(sourceIds.accountId, targetIds.accountId)
|
||||||
isSameAccount(getContainerIdentifiers(source), getContainerIdentifiers(target))
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,19 +101,40 @@ export function useCopyJobNavigation() {
|
|||||||
error instanceof Error
|
error instanceof Error
|
||||||
? error.message || "Failed to create copy job. Please try again later."
|
? error.message || "Failed to create copy job. Please try again later."
|
||||||
: "Failed to create copy job. Please try again later.";
|
: "Failed to create copy job. Please try again later.";
|
||||||
setError(errorMessage);
|
setContextError(errorMessage);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAddCollectionPanelSubmit = () => {
|
||||||
|
const form = document.getElementById("panelContainer") as HTMLFormElement;
|
||||||
|
if (form) {
|
||||||
|
const submitEvent = new Event("submit", {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
});
|
||||||
|
form.dispatchEvent(submitEvent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showAddCollectionPanel = useCallback(() => {
|
||||||
|
dispatch({ type: "NEXT", nextScreen: SCREEN_KEYS.CreateCollection });
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
const handlePrimary = useCallback(() => {
|
const handlePrimary = useCallback(() => {
|
||||||
|
if (currentScreenKey === SCREEN_KEYS.CreateCollection) {
|
||||||
|
handleAddCollectionPanelSubmit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (currentScreenKey === SCREEN_KEYS.SelectSourceAndTargetContainers && areContainersIdentical()) {
|
if (currentScreenKey === SCREEN_KEYS.SelectSourceAndTargetContainers && areContainersIdentical()) {
|
||||||
setError("Source and destination containers cannot be the same. Please select different containers to proceed.");
|
setContextError(
|
||||||
|
"Source and destination containers cannot be the same. Please select different containers to proceed.",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setError(null);
|
setContextError(null);
|
||||||
const transitions = {
|
const transitions = {
|
||||||
[SCREEN_KEYS.SelectAccount]: shouldNotShowPermissionScreen()
|
[SCREEN_KEYS.SelectAccount]: shouldNotShowPermissionScreen()
|
||||||
? SCREEN_KEYS.SelectSourceAndTargetContainers
|
? SCREEN_KEYS.SelectSourceAndTargetContainers
|
||||||
@@ -134,10 +151,6 @@ export function useCopyJobNavigation() {
|
|||||||
}
|
}
|
||||||
}, [currentScreenKey, copyJobState, areContainersIdentical, handleCopyJobSubmission]);
|
}, [currentScreenKey, copyJobState, areContainersIdentical, handleCopyJobSubmission]);
|
||||||
|
|
||||||
const handlePrevious = useCallback(() => {
|
|
||||||
dispatch({ type: "PREVIOUS" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentScreen,
|
currentScreen,
|
||||||
isPrimaryDisabled,
|
isPrimaryDisabled,
|
||||||
@@ -145,8 +158,7 @@ export function useCopyJobNavigation() {
|
|||||||
handlePrimary,
|
handlePrimary,
|
||||||
handlePrevious,
|
handlePrevious,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
|
showAddCollectionPanel,
|
||||||
primaryBtnText,
|
primaryBtnText,
|
||||||
error,
|
|
||||||
setError,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useCopyJobContext } from "../../Context/CopyJobContext";
|
||||||
import { CopyJobContextState } from "../../Types/CopyJobTypes";
|
import { CopyJobContextState } from "../../Types/CopyJobTypes";
|
||||||
import AssignPermissions from "../Screens/AssignPermissions/AssignPermissions";
|
import AssignPermissions from "../Screens/AssignPermissions/AssignPermissions";
|
||||||
|
import AddCollectionPanelWrapper from "../Screens/CreateContainer/AddCollectionPanelWrapper";
|
||||||
import PreviewCopyJob from "../Screens/PreviewCopyJob/PreviewCopyJob";
|
import PreviewCopyJob from "../Screens/PreviewCopyJob/PreviewCopyJob";
|
||||||
import SelectAccount from "../Screens/SelectAccount/SelectAccount";
|
import SelectAccount from "../Screens/SelectAccount/SelectAccount";
|
||||||
import SelectSourceAndTargetContainers from "../Screens/SelectSourceAndTargetContainers/SelectSourceAndTargetContainers";
|
import SelectSourceAndTargetContainers from "../Screens/SelectSourceAndTargetContainers/SelectSourceAndTargetContainers";
|
||||||
|
|
||||||
const SCREEN_KEYS = {
|
const SCREEN_KEYS = {
|
||||||
|
CreateCollection: "CreateCollection",
|
||||||
SelectAccount: "SelectAccount",
|
SelectAccount: "SelectAccount",
|
||||||
SelectSourceAndTargetContainers: "SelectSourceAndTargetContainers",
|
SelectSourceAndTargetContainers: "SelectSourceAndTargetContainers",
|
||||||
PreviewCopyJob: "PreviewCopyJob",
|
PreviewCopyJob: "PreviewCopyJob",
|
||||||
@@ -23,7 +26,9 @@ type Screen = {
|
|||||||
validations: Validation[];
|
validations: Validation[];
|
||||||
};
|
};
|
||||||
|
|
||||||
function useCreateCopyJobScreensList() {
|
function useCreateCopyJobScreensList(goBack: () => void): Screen[] {
|
||||||
|
const { explorer } = useCopyJobContext();
|
||||||
|
|
||||||
return React.useMemo<Screen[]>(
|
return React.useMemo<Screen[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -50,13 +55,18 @@ function useCreateCopyJobScreensList() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: SCREEN_KEYS.CreateCollection,
|
||||||
|
component: <AddCollectionPanelWrapper explorer={explorer} goBack={goBack} />,
|
||||||
|
validations: [],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: SCREEN_KEYS.PreviewCopyJob,
|
key: SCREEN_KEYS.PreviewCopyJob,
|
||||||
component: <PreviewCopyJob />,
|
component: <PreviewCopyJob />,
|
||||||
validations: [
|
validations: [
|
||||||
{
|
{
|
||||||
validate: (state: CopyJobContextState) =>
|
validate: (state: CopyJobContextState) =>
|
||||||
!!(typeof state?.jobName === "string" && state?.jobName && /^[a-zA-Z0-9-.]+$/.test(state?.jobName)),
|
!!(typeof state?.jobName === "string" && state?.jobName && /^[a-zA-Z0-9-._]+$/.test(state?.jobName)),
|
||||||
message: "Please enter a job name to proceed",
|
message: "Please enter a job name to proceed",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -80,7 +90,7 @@ function useCreateCopyJobScreensList() {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[],
|
[explorer],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,14 @@ interface CopyJobActionMenuProps {
|
|||||||
|
|
||||||
const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick }) => {
|
const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick }) => {
|
||||||
const [updatingJobAction, setUpdatingJobAction] = React.useState<{ jobName: string; action: string } | null>(null);
|
const [updatingJobAction, setUpdatingJobAction] = React.useState<{ jobName: string; action: string } | null>(null);
|
||||||
if ([CopyJobStatusType.Completed, CopyJobStatusType.Cancelled].includes(job.Status)) {
|
if (
|
||||||
|
[
|
||||||
|
CopyJobStatusType.Completed,
|
||||||
|
CopyJobStatusType.Cancelled,
|
||||||
|
CopyJobStatusType.Failed,
|
||||||
|
CopyJobStatusType.Faulted,
|
||||||
|
].includes(job.Status)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +62,7 @@ const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick
|
|||||||
[CopyJobStatusType.InProgress, CopyJobStatusType.Running, CopyJobStatusType.Partitioning].includes(job.Status)
|
[CopyJobStatusType.InProgress, CopyJobStatusType.Running, CopyJobStatusType.Partitioning].includes(job.Status)
|
||||||
) {
|
) {
|
||||||
const filteredItems = baseItems.filter((item) => item.key !== CopyJobActions.resume);
|
const filteredItems = baseItems.filter((item) => item.key !== CopyJobActions.resume);
|
||||||
if (job.Mode === CopyJobMigrationType.Online) {
|
if ((job.Mode ?? "").toLowerCase() === CopyJobMigrationType.Online) {
|
||||||
filteredItems.push({
|
filteredItems.push({
|
||||||
key: CopyJobActions.complete,
|
key: CopyJobActions.complete,
|
||||||
text: ContainerCopyMessages.MonitorJobs.Actions.complete,
|
text: ContainerCopyMessages.MonitorJobs.Actions.complete,
|
||||||
@@ -67,7 +74,7 @@ const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick
|
|||||||
return filteredItems;
|
return filteredItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([CopyJobStatusType.Failed, CopyJobStatusType.Faulted, CopyJobStatusType.Skipped].includes(job.Status)) {
|
if ([CopyJobStatusType.Skipped].includes(job.Status)) {
|
||||||
return baseItems.filter((item) => item.key === CopyJobActions.resume);
|
return baseItems.filter((item) => item.key === CopyJobActions.resume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
import { ActionButton, Image } from "@fluentui/react";
|
import { ActionButton, Image } from "@fluentui/react";
|
||||||
import React, { useCallback } from "react";
|
import Explorer from "Explorer/Explorer";
|
||||||
|
import React from "react";
|
||||||
import CopyJobIcon from "../../../../../images/ContainerCopy/copy-jobs.svg";
|
import CopyJobIcon from "../../../../../images/ContainerCopy/copy-jobs.svg";
|
||||||
import * as Actions from "../../Actions/CopyJobActions";
|
import * as Actions from "../../Actions/CopyJobActions";
|
||||||
import ContainerCopyMessages from "../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../ContainerCopyMessages";
|
||||||
|
|
||||||
interface CopyJobsNotFoundProps {}
|
interface CopyJobsNotFoundProps {
|
||||||
|
explorer: Explorer;
|
||||||
|
}
|
||||||
|
|
||||||
const CopyJobsNotFound: React.FC<CopyJobsNotFoundProps> = () => {
|
const CopyJobsNotFound: React.FC<CopyJobsNotFoundProps> = ({ explorer }) => {
|
||||||
const handleCreateCopyJob = useCallback(Actions.openCreateCopyJobPanel, []);
|
|
||||||
return (
|
return (
|
||||||
<div className="notFoundContainer flexContainer centerContent">
|
<div className="notFoundContainer flexContainer centerContent">
|
||||||
<Image src={CopyJobIcon} alt={ContainerCopyMessages.noCopyJobsTitle} width={100} height={100} />
|
<Image src={CopyJobIcon} alt={ContainerCopyMessages.noCopyJobsTitle} width={100} height={100} />
|
||||||
<h4 className="noCopyJobsMessage">{ContainerCopyMessages.noCopyJobsTitle}</h4>
|
<h4 className="noCopyJobsMessage">{ContainerCopyMessages.noCopyJobsTitle}</h4>
|
||||||
<ActionButton allowDisabledFocus className="createCopyJobButton" onClick={handleCreateCopyJob}>
|
<ActionButton
|
||||||
|
allowDisabledFocus
|
||||||
|
className="createCopyJobButton"
|
||||||
|
onClick={Actions.openCreateCopyJobPanel.bind(null, explorer)}
|
||||||
|
>
|
||||||
{ContainerCopyMessages.createCopyJobButtonText}
|
{ContainerCopyMessages.createCopyJobButtonText}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
||||||
import ShimmerTree, { IndentLevel } from "Common/ShimmerTree/ShimmerTree";
|
import ShimmerTree, { IndentLevel } from "Common/ShimmerTree/ShimmerTree";
|
||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
import React, { forwardRef, useEffect, useImperativeHandle } from "react";
|
import React, { forwardRef, useEffect, useImperativeHandle } from "react";
|
||||||
import { getCopyJobs, updateCopyJobStatus } from "../Actions/CopyJobActions";
|
import { getCopyJobs, updateCopyJobStatus } from "../Actions/CopyJobActions";
|
||||||
import { convertToCamelCase } from "../CopyJobUtils";
|
import { convertToCamelCase } from "../CopyJobUtils";
|
||||||
@@ -11,13 +12,15 @@ import CopyJobsList from "./Components/CopyJobsList";
|
|||||||
|
|
||||||
const FETCH_INTERVAL_MS = 30 * 1000;
|
const FETCH_INTERVAL_MS = 30 * 1000;
|
||||||
|
|
||||||
interface MonitorCopyJobsProps {}
|
interface MonitorCopyJobsProps {
|
||||||
|
explorer: Explorer;
|
||||||
|
}
|
||||||
|
|
||||||
export interface MonitorCopyJobsRef {
|
export interface MonitorCopyJobsRef {
|
||||||
refreshJobList: () => void;
|
refreshJobList: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MonitorCopyJobs = forwardRef<MonitorCopyJobsRef, MonitorCopyJobsProps>((_props, ref) => {
|
const MonitorCopyJobs = forwardRef<MonitorCopyJobsRef, MonitorCopyJobsProps>(({ explorer }, ref) => {
|
||||||
const [loading, setLoading] = React.useState(true);
|
const [loading, setLoading] = React.useState(true);
|
||||||
const [error, setError] = React.useState<string | null>(null);
|
const [error, setError] = React.useState<string | null>(null);
|
||||||
const [jobs, setJobs] = React.useState<CopyJobType[]>([]);
|
const [jobs, setJobs] = React.useState<CopyJobType[]>([]);
|
||||||
@@ -96,15 +99,15 @@ const MonitorCopyJobs = forwardRef<MonitorCopyJobsRef, MonitorCopyJobsProps>((_p
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const memoizedJobsList = React.useMemo(() => {
|
const renderJobsList = () => {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (jobs.length > 0) {
|
if (jobs.length > 0) {
|
||||||
return <CopyJobsList jobs={jobs} handleActionClick={handleActionClick} />;
|
return <CopyJobsList jobs={jobs} handleActionClick={handleActionClick} />;
|
||||||
}
|
}
|
||||||
return <CopyJobsNotFound />;
|
return <CopyJobsNotFound explorer={explorer} />;
|
||||||
}, [jobs, loading, handleActionClick]);
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="monitorCopyJobs flexContainer">
|
<Stack className="monitorCopyJobs flexContainer">
|
||||||
@@ -114,7 +117,7 @@ const MonitorCopyJobs = forwardRef<MonitorCopyJobsRef, MonitorCopyJobsProps>((_p
|
|||||||
{error}
|
{error}
|
||||||
</MessageBar>
|
</MessageBar>
|
||||||
)}
|
)}
|
||||||
{memoizedJobsList}
|
{renderJobsList()}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Explorer from "../../Explorer";
|
|||||||
import { CopyJobMigrationType, CopyJobStatusType } from "../Enums/CopyJobEnums";
|
import { CopyJobMigrationType, CopyJobStatusType } from "../Enums/CopyJobEnums";
|
||||||
|
|
||||||
export interface ContainerCopyProps {
|
export interface ContainerCopyProps {
|
||||||
container: Explorer;
|
explorer: Explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CopyJobCommandBarBtnType = {
|
export type CopyJobCommandBarBtnType = {
|
||||||
@@ -48,6 +48,7 @@ export interface DatabaseContainerSectionProps {
|
|||||||
selectedContainer: string;
|
selectedContainer: string;
|
||||||
containerDisabled?: boolean;
|
containerDisabled?: boolean;
|
||||||
containerOnChange: (ev: React.FormEvent<HTMLDivElement>, option: DropdownOptionType) => void;
|
containerOnChange: (ev: React.FormEvent<HTMLDivElement>, option: DropdownOptionType) => void;
|
||||||
|
handleOnDemandCreateContainer?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CopyJobContextState {
|
export interface CopyJobContextState {
|
||||||
@@ -73,11 +74,14 @@ export interface CopyJobFlowType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CopyJobContextProviderType {
|
export interface CopyJobContextProviderType {
|
||||||
|
contextError: string | null;
|
||||||
|
setContextError: React.Dispatch<React.SetStateAction<string | null>>;
|
||||||
flow: CopyJobFlowType;
|
flow: CopyJobFlowType;
|
||||||
setFlow: React.Dispatch<React.SetStateAction<CopyJobFlowType>>;
|
setFlow: React.Dispatch<React.SetStateAction<CopyJobFlowType>>;
|
||||||
copyJobState: CopyJobContextState | null;
|
copyJobState: CopyJobContextState | null;
|
||||||
setCopyJobState: React.Dispatch<React.SetStateAction<CopyJobContextState>>;
|
setCopyJobState: React.Dispatch<React.SetStateAction<CopyJobContextState>>;
|
||||||
resetCopyJobState: () => void;
|
resetCopyJobState: () => void;
|
||||||
|
explorer?: Explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CopyJobType = {
|
export type CopyJobType = {
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
.createCopyJobScreensContainer {
|
.createCopyJobScreensContainer {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 1em 1.5em;
|
padding: 1em 1.5em;
|
||||||
|
|
||||||
|
.pointInTimeRestoreContainer, .onlineCopyContainer {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -59,6 +63,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.popover-container {
|
.popover-container {
|
||||||
|
border-radius: 6px;
|
||||||
button[disabled] {
|
button[disabled] {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
@@ -66,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
.foreground {
|
.foreground {
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
background-color: white;
|
background-color: #f9f9f9;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||||
transform: translate(0%, -9%);
|
transform: translate(0%, -9%);
|
||||||
@@ -75,6 +80,24 @@
|
|||||||
.createCopyJobErrorMessageBar {
|
.createCopyJobErrorMessageBar {
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
.create-container-link-btn {
|
||||||
|
padding: 0;
|
||||||
|
height: 25px;
|
||||||
|
color: @LinkColor;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create collection panel */
|
||||||
|
.panelFormWrapper .panelMainContent {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.createCopyJobScreensFooter {
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitorCopyJobs {
|
.monitorCopyJobs {
|
||||||
@@ -118,8 +141,9 @@
|
|||||||
|
|
||||||
.jobNameLink {
|
.jobNameLink {
|
||||||
color: @LinkColor;
|
color: @LinkColor;
|
||||||
text-decoration: underline;
|
text-overflow: ellipsis;
|
||||||
cursor: pointer;
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export interface AddCollectionPanelProps {
|
|||||||
explorer: Explorer;
|
explorer: Explorer;
|
||||||
databaseId?: string;
|
databaseId?: string;
|
||||||
isQuickstart?: boolean;
|
isQuickstart?: boolean;
|
||||||
|
isCopyJobFlow?: boolean;
|
||||||
|
onSubmitSuccess?: (collectionData: { databaseId: string; collectionId: string }) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DefaultVectorEmbeddingPolicy: DataModels.VectorEmbeddingPolicy = {
|
export const DefaultVectorEmbeddingPolicy: DataModels.VectorEmbeddingPolicy = {
|
||||||
@@ -975,7 +977,9 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PanelFooterComponent buttonLabel="OK" isButtonDisabled={this.state.isThroughputCapExceeded} />
|
{!this.props.isCopyJobFlow && (
|
||||||
|
<PanelFooterComponent buttonLabel="OK" isButtonDisabled={this.state.isThroughputCapExceeded} />
|
||||||
|
)}
|
||||||
|
|
||||||
{this.state.isExecuting && (
|
{this.state.isExecuting && (
|
||||||
<div>
|
<div>
|
||||||
@@ -1415,8 +1419,13 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({ isExecuting: false });
|
this.setState({ isExecuting: false });
|
||||||
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
|
||||||
useSidePanel.getState().closeSidePanel();
|
if (this.props.isCopyJobFlow && this.props.onSubmitSuccess) {
|
||||||
|
this.props.onSubmitSuccess({ databaseId, collectionId });
|
||||||
|
} else {
|
||||||
|
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
||||||
|
useSidePanel.getState().closeSidePanel();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage: string = getErrorMessage(error);
|
const errorMessage: string = getErrorMessage(error);
|
||||||
this.setState({ isExecuting: false, errorMessage, showErrorDetails: true });
|
this.setState({ isExecuting: false, errorMessage, showErrorDetails: true });
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ import { updateUserContext } from "../../../UserContext";
|
|||||||
import { SettingsPane } from "./SettingsPane";
|
import { SettingsPane } from "./SettingsPane";
|
||||||
|
|
||||||
describe("Settings Pane", () => {
|
describe("Settings Pane", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
updateUserContext({
|
||||||
|
sessionId: "1234-5678",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should render Default properly", () => {
|
it("should render Default properly", () => {
|
||||||
const wrapper = shallow(<SettingsPane explorer={null} />);
|
const wrapper = shallow(<SettingsPane explorer={null} />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
|
||||||
const explorerVersion = configContext.gitSha;
|
const explorerVersion = configContext.gitSha;
|
||||||
|
const sessionId: string = userContext.sessionId;
|
||||||
const isEmulator = configContext.platform === Platform.Emulator;
|
const isEmulator = configContext.platform === Platform.Emulator;
|
||||||
const shouldShowQueryPageOptions = userContext.apiType === "SQL";
|
const shouldShowQueryPageOptions = userContext.apiType === "SQL";
|
||||||
const showRetrySettings =
|
const showRetrySettings =
|
||||||
@@ -1227,6 +1228,12 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
<div>{explorerVersion}</div>
|
<div>{explorerVersion}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="settingsSection">
|
||||||
|
<div className="settingsSectionPart">
|
||||||
|
<div className="settingsSectionLabel">Session ID</div>
|
||||||
|
<div>{sessionId}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</RightPaneForm>
|
</RightPaneForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -649,6 +649,22 @@ exports[`Settings Pane should render Default properly 1`] = `
|
|||||||
<div />
|
<div />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
className="settingsSection"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="settingsSectionPart"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="settingsSectionLabel"
|
||||||
|
>
|
||||||
|
Session ID
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
1234-5678
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</RightPaneForm>
|
</RightPaneForm>
|
||||||
`;
|
`;
|
||||||
@@ -958,6 +974,22 @@ exports[`Settings Pane should render Gremlin properly 1`] = `
|
|||||||
<div />
|
<div />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
className="settingsSection"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="settingsSectionPart"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="settingsSectionLabel"
|
||||||
|
>
|
||||||
|
Session ID
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
1234-5678
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</RightPaneForm>
|
</RightPaneForm>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
query,
|
query,
|
||||||
paginationToken,
|
paginationToken,
|
||||||
}),
|
}),
|
||||||
beforeSend: this.setAuthorizationHeader as any,
|
beforeSend: this.setCommonHeaders as any,
|
||||||
cache: false,
|
cache: false,
|
||||||
});
|
});
|
||||||
shouldNotify &&
|
shouldNotify &&
|
||||||
@@ -440,7 +440,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
keyspaceId: collection.databaseId,
|
keyspaceId: collection.databaseId,
|
||||||
tableId: collection.id(),
|
tableId: collection.id(),
|
||||||
}),
|
}),
|
||||||
beforeSend: this.setAuthorizationHeader as any,
|
beforeSend: this.setCommonHeaders as any,
|
||||||
cache: false,
|
cache: false,
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
@@ -482,7 +482,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
keyspaceId: collection.databaseId,
|
keyspaceId: collection.databaseId,
|
||||||
tableId: collection.id(),
|
tableId: collection.id(),
|
||||||
}),
|
}),
|
||||||
beforeSend: this.setAuthorizationHeader as any,
|
beforeSend: this.setCommonHeaders as any,
|
||||||
cache: false,
|
cache: false,
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
@@ -518,7 +518,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
resourceId: resourceId,
|
resourceId: resourceId,
|
||||||
query: query,
|
query: query,
|
||||||
}),
|
}),
|
||||||
beforeSend: this.setAuthorizationHeader as any,
|
beforeSend: this.setCommonHeaders as any,
|
||||||
cache: false,
|
cache: false,
|
||||||
}).then(
|
}).then(
|
||||||
(data: any) => {
|
(data: any) => {
|
||||||
@@ -547,7 +547,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
return cassandraEndpoint;
|
return cassandraEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setAuthorizationHeader: (xhr: XMLHttpRequest) => boolean = (xhr: XMLHttpRequest): boolean => {
|
private setCommonHeaders: (xhr: XMLHttpRequest) => boolean = (xhr: XMLHttpRequest): boolean => {
|
||||||
const authorizationHeaderMetadata: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
const authorizationHeaderMetadata: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||||
xhr.setRequestHeader(authorizationHeaderMetadata.header, authorizationHeaderMetadata.token);
|
xhr.setRequestHeader(authorizationHeaderMetadata.header, authorizationHeaderMetadata.token);
|
||||||
|
|
||||||
@@ -555,6 +555,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
xhr.setRequestHeader(Constants.HttpHeaders.entraIdToken, userContext.aadToken);
|
xhr.setRequestHeader(Constants.HttpHeaders.entraIdToken, userContext.aadToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xhr.setRequestHeader(Constants.HttpHeaders.sessionId, userContext.sessionId);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { OpenTab } from "Contracts/ActionContracts";
|
import { OpenTab } from "Contracts/ActionContracts";
|
||||||
import { KeyboardActionGroup, clearKeyboardActionGroup } from "KeyboardShortcuts";
|
import { KeyboardActionGroup, clearKeyboardActionGroup } from "KeyboardShortcuts";
|
||||||
|
import { substringUtf } from "Utils/StringUtils";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as ThemeUtility from "../../Common/ThemeUtility";
|
import * as ThemeUtility from "../../Common/ThemeUtility";
|
||||||
@@ -154,13 +155,13 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
const db = this.database?.id();
|
const db = this.database?.id();
|
||||||
if (coll) {
|
if (coll) {
|
||||||
if (coll.length > 8) {
|
if (coll.length > 8) {
|
||||||
return coll.slice(0, 5) + "…" + options.title;
|
return substringUtf(coll, 0, 5) + "…" + options.title;
|
||||||
} else {
|
} else {
|
||||||
return coll + "." + options.title;
|
return coll + "." + options.title;
|
||||||
}
|
}
|
||||||
} else if (db) {
|
} else if (db) {
|
||||||
if (db.length > 8) {
|
if (db.length > 8) {
|
||||||
return db.slice(0, 5) + "…" + options.title;
|
return substringUtf(db, 0, 5) + "…" + options.title;
|
||||||
} else {
|
} else {
|
||||||
return db + "." + options.title;
|
return db + "." + options.title;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ const App: React.FunctionComponent = () => {
|
|||||||
<KeyboardShortcutRoot>
|
<KeyboardShortcutRoot>
|
||||||
<div className="flexContainer" aria-hidden="false" data-test="DataExplorerRoot">
|
<div className="flexContainer" aria-hidden="false" data-test="DataExplorerRoot">
|
||||||
{userContext.features.enableContainerCopy && userContext.apiType === "SQL" ? (
|
{userContext.features.enableContainerCopy && userContext.apiType === "SQL" ? (
|
||||||
<ContainerCopyPanel container={explorer} />
|
<ContainerCopyPanel explorer={explorer} />
|
||||||
) : (
|
) : (
|
||||||
<DivExplorer explorer={explorer} />
|
<DivExplorer explorer={explorer} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Action } from "Shared/Telemetry/TelemetryConstants";
|
|||||||
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
|
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
|
||||||
import { useCarousel } from "hooks/useCarousel";
|
import { useCarousel } from "hooks/useCarousel";
|
||||||
import { usePostgres } from "hooks/usePostgres";
|
import { usePostgres } from "hooks/usePostgres";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { AuthType } from "./AuthType";
|
import { AuthType } from "./AuthType";
|
||||||
import { DatabaseAccount } from "./Contracts/DataModels";
|
import { DatabaseAccount } from "./Contracts/DataModels";
|
||||||
import { SubscriptionType } from "./Contracts/SubscriptionType";
|
import { SubscriptionType } from "./Contracts/SubscriptionType";
|
||||||
@@ -118,6 +119,7 @@ export interface UserContext {
|
|||||||
readonly dataPlaneRbacEnabled?: boolean;
|
readonly dataPlaneRbacEnabled?: boolean;
|
||||||
readonly refreshCosmosClient?: boolean;
|
readonly refreshCosmosClient?: boolean;
|
||||||
throughputBucketsEnabled?: boolean;
|
throughputBucketsEnabled?: boolean;
|
||||||
|
readonly sessionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra" | "Postgres" | "VCoreMongo";
|
export type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra" | "Postgres" | "VCoreMongo";
|
||||||
@@ -135,6 +137,7 @@ const userContext: UserContext = {
|
|||||||
features,
|
features,
|
||||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||||
collectionCreationDefaults: CollectionCreationDefaults,
|
collectionCreationDefaults: CollectionCreationDefaults,
|
||||||
|
sessionId: uuidv4(), // Default sessionId - will be overwritten if provided by host
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isAccountNewerThanThresholdInMs(createdAt: string, threshold: number) {
|
export function isAccountNewerThanThresholdInMs(createdAt: string, threshold: number) {
|
||||||
|
|||||||
@@ -26,5 +26,22 @@ describe("StringUtils", () => {
|
|||||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString("");
|
const transformedString: string | undefined = StringUtils.stripSpacesFromString("");
|
||||||
expect(transformedString).toBe("");
|
expect(transformedString).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return the right number of characters regardless of bytes used per character", () => {
|
||||||
|
// Tried to use a sample of characters across the range for each of the individual byte lengths
|
||||||
|
const ascii = "!,n~!,n~!,n~";
|
||||||
|
const twoByteCharacters = "Āā߿܀Āā߿܀Āā߿܀";
|
||||||
|
const threeByteCharacters = "ࠀ倀ꀀࠀ倀ꀀࠀ倀ꀀ";
|
||||||
|
const fourByteCharacters = "𐀀𐔀𐨀𐿶𐀀𐔀𐨀𐿶𐀀𐔀𐨀𐿶";
|
||||||
|
// Used a random character generator for each of the different byte-lengths of characters for the mixed tests
|
||||||
|
const mixedByteSizes = "Yח䙶𫶾eԚ疿𱺿]߉ꗫ𢆤*ɉ貸𪡑";
|
||||||
|
|
||||||
|
expect(StringUtils.substringUtf(ascii, 0, 5)).toBe("!,n~!");
|
||||||
|
expect(StringUtils.substringUtf(twoByteCharacters, 0, 5)).toBe("Āā߿܀Ā");
|
||||||
|
expect(StringUtils.substringUtf(threeByteCharacters, 0, 5)).toBe("ࠀ倀ꀀࠀ");
|
||||||
|
expect(StringUtils.substringUtf(fourByteCharacters, 0, 5)).toBe("𐀀𐔀𐨀𐿶𐀀");
|
||||||
|
expect(StringUtils.substringUtf(mixedByteSizes, 0, 5)).toBe("Yח䙶𫶾e");
|
||||||
|
expect(StringUtils.substringUtf(mixedByteSizes, 4, 4)).toBe("eԚ疿𱺿");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,3 +17,58 @@ export function endsWith(stringToTest: string, suffix: string): boolean {
|
|||||||
export function startsWith(stringToTest: string, prefix: string): boolean {
|
export function startsWith(stringToTest: string, prefix: string): boolean {
|
||||||
return stringToTest.indexOf(prefix) === 0;
|
return stringToTest.indexOf(prefix) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the input number of characters from a desired string but takes into account characters encoded with different byte sizes.
|
||||||
|
* @param text The text from which to return the subset
|
||||||
|
* @param startChar The starting character from @param text (zero-based)
|
||||||
|
* @param numChars The number of characters to return starting from @param startChar
|
||||||
|
* @returns The resulting slice of characters
|
||||||
|
*/
|
||||||
|
export const substringUtf = (text: string, startChar: number, numChars: number) => {
|
||||||
|
const encoded = new TextEncoder().encode(text);
|
||||||
|
|
||||||
|
let currentChar = 0;
|
||||||
|
let currentByte = 0;
|
||||||
|
let startByte = 0;
|
||||||
|
for (; currentChar < startChar + numChars; ) {
|
||||||
|
if (currentChar === startChar) {
|
||||||
|
startByte = currentByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Unicode is utf encoded using 1, 2, 3, or 4 bytes
|
||||||
|
In a byte array, we know how many bytes the character is encoded based on the first byte because it
|
||||||
|
was developed such that the first byte's range never occurs in any other byte. Subsequent bytes are
|
||||||
|
always within 128 and 191. So in binary it breaks down like this:
|
||||||
|
1 byte: 0xxxxxxx
|
||||||
|
2 bytes: 110xxxxx 10xxxxxx
|
||||||
|
3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
|
||||||
|
4 bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
*/
|
||||||
|
switch (true) {
|
||||||
|
// The originall ASCII set is between 0 (00000000) and 127 (01111111) and those only take up one byte
|
||||||
|
case encoded[currentByte] >= 0 && encoded[currentByte] <= 127:
|
||||||
|
currentByte++;
|
||||||
|
break;
|
||||||
|
// But if the first byte is within 192 (11000000) and 223 (11011111) then we know the character is two bytes:
|
||||||
|
case encoded[currentByte] >= 192 && encoded[currentByte] <= 223:
|
||||||
|
currentByte = currentByte + 2;
|
||||||
|
break;
|
||||||
|
// If the first byte is anything within 224 (11100000) and 239 (11101111) then the character is three bytes
|
||||||
|
case encoded[currentByte] >= 224 && encoded[currentByte] <= 239:
|
||||||
|
currentByte = currentByte + 3;
|
||||||
|
break;
|
||||||
|
// If the first byte is anything within 240 (11110000) and 247 (11110111) then the character is four bytes
|
||||||
|
case encoded[currentByte] >= 240 && encoded[currentByte] <= 247:
|
||||||
|
currentByte = currentByte + 4;
|
||||||
|
break;
|
||||||
|
// Anything past is an error for now
|
||||||
|
default:
|
||||||
|
throw new Error("Unrecognized character");
|
||||||
|
}
|
||||||
|
currentChar++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TextDecoder().decode(encoded.slice(startByte, currentByte));
|
||||||
|
};
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
|||||||
userContext.features.phoenixNotebooks = true;
|
userContext.features.phoenixNotebooks = true;
|
||||||
userContext.features.phoenixFeatures = true;
|
userContext.features.phoenixFeatures = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let explorer: Explorer;
|
let explorer: Explorer;
|
||||||
if (platform === Platform.Hosted) {
|
if (platform === Platform.Hosted) {
|
||||||
explorer = await configureHosted();
|
explorer = await configureHosted();
|
||||||
@@ -927,6 +928,7 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
collectionCreationDefaults: inputs.defaultCollectionThroughput,
|
collectionCreationDefaults: inputs.defaultCollectionThroughput,
|
||||||
isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription,
|
isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription,
|
||||||
feedbackPolicies: inputs.feedbackPolicies,
|
feedbackPolicies: inputs.feedbackPolicies,
|
||||||
|
...(inputs.sessionId && { sessionId: inputs.sessionId }), // Remove conditional once Portal sends sessionId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (inputs.isPostgresAccount) {
|
if (inputs.isPostgresAccount) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface SidePanelState {
|
|||||||
hasConsole: boolean;
|
hasConsole: boolean;
|
||||||
panelContent?: JSX.Element;
|
panelContent?: JSX.Element;
|
||||||
headerText?: string;
|
headerText?: string;
|
||||||
|
setHeaderText: (headerText: string) => void;
|
||||||
openSidePanel: (headerText: string, panelContent: JSX.Element, panelWidth?: string, onClose?: () => void) => void;
|
openSidePanel: (headerText: string, panelContent: JSX.Element, panelWidth?: string, onClose?: () => void) => void;
|
||||||
closeSidePanel: () => void;
|
closeSidePanel: () => void;
|
||||||
setPanelHasConsole: (hasConsole: boolean) => void;
|
setPanelHasConsole: (hasConsole: boolean) => void;
|
||||||
@@ -15,6 +16,7 @@ export const useSidePanel: UseStore<SidePanelState> = create((set) => ({
|
|||||||
isOpen: false,
|
isOpen: false,
|
||||||
panelWidth: "440px",
|
panelWidth: "440px",
|
||||||
hasConsole: true,
|
hasConsole: true,
|
||||||
|
setHeaderText: (headerText: string) => set((state) => ({ ...state, headerText })),
|
||||||
setPanelHasConsole: (hasConsole: boolean) => set((state) => ({ ...state, hasConsole })),
|
setPanelHasConsole: (hasConsole: boolean) => set((state) => ({ ...state, hasConsole })),
|
||||||
openSidePanel: (headerText, panelContent, panelWidth = "440px") =>
|
openSidePanel: (headerText, panelContent, panelWidth = "440px") =>
|
||||||
set((state) => ({ ...state, headerText, panelContent, panelWidth, isOpen: true })),
|
set((state) => ({ ...state, headerText, panelContent, panelWidth, isOpen: true })),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ 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) {
|
||||||
// Unfortunately Mongo does not provide a timestamp in ARM. There is no way to tell how old the DB is other thn encoding it in the ID :(
|
// Unfortunately Mongo does not provide a timestamp in ARM. There is no way to tell how old the DB is other thn encoding it in the ID :(
|
||||||
const timestamp = Number(database.name.split("-")[1]);
|
const timestamp = Number(database.name.split("_").pop());
|
||||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||||
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: ${friendlyTime(Date.now() - timestamp)}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user