mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-08 12:07:06 +00:00
Compare commits
9 Commits
users/aisa
...
user/bchou
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57c51f462a | ||
|
|
337379b180 | ||
|
|
eabc0e85c5 | ||
|
|
5df45c0861 | ||
|
|
a9cc819534 | ||
|
|
b1b72cd293 | ||
|
|
5a0f016cdf | ||
|
|
fb4b2e3fe7 | ||
|
|
a537d958ca |
@@ -44,8 +44,8 @@ export const getDatabaseEndpoint = (apiType: ApiType): string => {
|
|||||||
return "gremlinDatabases";
|
return "gremlinDatabases";
|
||||||
case "Tables":
|
case "Tables":
|
||||||
return "tables";
|
return "tables";
|
||||||
default:
|
|
||||||
case "SQL":
|
case "SQL":
|
||||||
|
default:
|
||||||
return "sqlDatabases";
|
return "sqlDatabases";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -58,8 +58,8 @@ export const getCollectionEndpoint = (apiType: ApiType): string => {
|
|||||||
return "tables";
|
return "tables";
|
||||||
case "Gremlin":
|
case "Gremlin":
|
||||||
return "graphs";
|
return "graphs";
|
||||||
default:
|
|
||||||
case "SQL":
|
case "SQL":
|
||||||
|
default:
|
||||||
return "containers";
|
return "containers";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
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;
|
||||||
@@ -73,6 +73,7 @@ export interface DatabaseAccountExtendedProperties {
|
|||||||
publicNetworkAccess?: string;
|
publicNetworkAccess?: string;
|
||||||
enablePriorityBasedExecution?: boolean;
|
enablePriorityBasedExecution?: boolean;
|
||||||
vcoreMongoEndpoint?: string;
|
vcoreMongoEndpoint?: string;
|
||||||
|
enableAllVersionsAndDeletesChangeFeed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DatabaseAccountResponseLocation {
|
export interface DatabaseAccountResponseLocation {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
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 { logError } from "../../../Common/Logger";
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
extractErrorMessage,
|
extractErrorMessage,
|
||||||
formatUTCDateTime,
|
formatUTCDateTime,
|
||||||
getAccountDetailsFromResourceId,
|
getAccountDetailsFromResourceId,
|
||||||
|
isIntraAccountCopy,
|
||||||
} from "../CopyJobUtils";
|
} from "../CopyJobUtils";
|
||||||
import CreateCopyJobScreensProvider from "../CreateCopyJob/Screens/CreateCopyJobScreensProvider";
|
import CreateCopyJobScreensProvider from "../CreateCopyJob/Screens/CreateCopyJobScreensProvider";
|
||||||
import { CopyJobActions, CopyJobStatusType } from "../Enums/CopyJobEnums";
|
import { CopyJobActions, CopyJobStatusType } from "../Enums/CopyJobEnums";
|
||||||
@@ -29,12 +31,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",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -74,7 +76,6 @@ export const getCopyJobs = async (): Promise<CopyJobType[]> => {
|
|||||||
}
|
}
|
||||||
copyJobsAbortController = null;
|
copyJobsAbortController = null;
|
||||||
|
|
||||||
/* added a lower bound to "0" and upper bound to "100" */
|
|
||||||
const calculateCompletionPercentage = (processed: number, total: number): number => {
|
const calculateCompletionPercentage = (processed: number, total: number): number => {
|
||||||
if (
|
if (
|
||||||
typeof processed !== "number" ||
|
typeof processed !== "number" ||
|
||||||
@@ -138,11 +139,12 @@ export const submitCreateCopyJob = async (state: CopyJobContextState, onSuccess:
|
|||||||
const { subscriptionId, resourceGroup, accountName } = getAccountDetailsFromResourceId(
|
const { subscriptionId, resourceGroup, accountName } = getAccountDetailsFromResourceId(
|
||||||
userContext.databaseAccount?.id || "",
|
userContext.databaseAccount?.id || "",
|
||||||
);
|
);
|
||||||
|
const isSameAccount = isIntraAccountCopy(source?.account?.id, target?.account?.id);
|
||||||
const body = {
|
const body = {
|
||||||
properties: {
|
properties: {
|
||||||
source: {
|
source: {
|
||||||
component: "CosmosDBSql",
|
component: "CosmosDBSql",
|
||||||
remoteAccountName: source?.account?.name,
|
...(isSameAccount ? {} : { accountName: source?.account?.name }),
|
||||||
databaseName: source?.databaseId,
|
databaseName: source?.databaseId,
|
||||||
containerName: source?.containerId,
|
containerName: source?.containerId,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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",
|
||||||
@@ -52,11 +55,22 @@ export default {
|
|||||||
"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) =>
|
intraAccountOnlineDescription: (accountName: string) =>
|
||||||
`Follow the steps below to enable online copy on your "${accountName}" account.`,
|
`Follow the steps below to enable online copy on your "${accountName}" account.`,
|
||||||
|
crossAccountConfiguration: {
|
||||||
|
title: "Cross-account container copy",
|
||||||
|
description: (sourceAccount: string, destinationAccount: string) =>
|
||||||
|
`Please follow the instruction below to grant requisite permissions to copy data from "${sourceAccount}" to "${destinationAccount}".`,
|
||||||
|
},
|
||||||
|
onlineConfiguration: {
|
||||||
|
title: "Online container copy",
|
||||||
|
description: (accountName: string) =>
|
||||||
|
`Please follow the instructions below to enable online copy on your "${accountName}" account.`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
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:
|
||||||
@@ -117,10 +131,17 @@ export default {
|
|||||||
},
|
},
|
||||||
onlineCopyEnabled: {
|
onlineCopyEnabled: {
|
||||||
title: "Online copy enabled",
|
title: "Online copy enabled",
|
||||||
description: (accountName: string) => `Enable Online copy on "${accountName}".`,
|
description: (accountName: string) =>
|
||||||
|
`Enable online container copy by clicking the button below on your "${accountName}" account.`,
|
||||||
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",
|
||||||
|
validateAllVersionsAndDeletesChangeFeedSpinnerLabel:
|
||||||
|
"Validating All versions and deletes change feed mode (preview)...",
|
||||||
|
enablingAllVersionsAndDeletesChangeFeedSpinnerLabel:
|
||||||
|
"Enabling All versions and deletes change feed mode (preview)...",
|
||||||
|
enablingOnlineCopySpinnerLabel: (accountName: string) =>
|
||||||
|
`Enabling online copy on your "${accountName}" account ...`,
|
||||||
},
|
},
|
||||||
MonitorJobs: {
|
MonitorJobs: {
|
||||||
Columns: {
|
Columns: {
|
||||||
|
|||||||
@@ -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 { Subscription } from "Contracts/DataModels";
|
||||||
|
import Explorer from "Explorer/Explorer";
|
||||||
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: "",
|
||||||
},
|
},
|
||||||
@@ -53,6 +58,7 @@ const CopyJobContextProvider: React.FC<CopyJobContextProviderProps> = (props) =>
|
|||||||
flow,
|
flow,
|
||||||
setFlow,
|
setFlow,
|
||||||
resetCopyJobState,
|
resetCopyJobState,
|
||||||
|
explorer: props.explorer,
|
||||||
};
|
};
|
||||||
|
|
||||||
return <CopyJobContext.Provider value={contextValue}>{props.children}</CopyJobContext.Provider>;
|
return <CopyJobContext.Provider value={contextValue}>{props.children}</CopyJobContext.Provider>;
|
||||||
|
|||||||
@@ -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/";
|
||||||
|
|
||||||
@@ -115,6 +115,14 @@ export function getAccountDetailsFromResourceId(accountId: string | undefined) {
|
|||||||
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 {
|
export function isIntraAccountCopy(sourceAccountId: string | undefined, targetAccountId: string | undefined): boolean {
|
||||||
const sourceAccountDetails = getAccountDetailsFromResourceId(sourceAccountId);
|
const sourceAccountDetails = getAccountDetailsFromResourceId(sourceAccountId);
|
||||||
const targetAccountDetails = getAccountDetailsFromResourceId(targetAccountId);
|
const targetAccountDetails = getAccountDetailsFromResourceId(targetAccountId);
|
||||||
@@ -124,3 +132,39 @@ export function isIntraAccountCopy(sourceAccountId: string | undefined, targetAc
|
|||||||
sourceAccountDetails?.accountName === targetAccountDetails?.accountName
|
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,5 @@
|
|||||||
import { Link, Stack, Text, Toggle } from "@fluentui/react";
|
import { Link, Stack, Text, Toggle } from "@fluentui/react";
|
||||||
import React, { useCallback } from "react";
|
import React from "react";
|
||||||
import { logError } from "../../../../../Common/Logger";
|
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";
|
||||||
@@ -25,7 +25,7 @@ const AddReadPermissionToDefaultIdentity: React.FC<AddReadPermissionToDefaultIde
|
|||||||
const { copyJobState, setCopyJobState, setContextError } = useCopyJobContext();
|
const { copyJobState, setCopyJobState, setContextError } = useCopyJobContext();
|
||||||
const [readPermissionAssigned, onToggle] = useToggle(false);
|
const [readPermissionAssigned, onToggle] = useToggle(false);
|
||||||
|
|
||||||
const handleAddReadPermission = useCallback(async () => {
|
const handleAddReadPermission = async () => {
|
||||||
const { source, target } = copyJobState;
|
const { source, target } = copyJobState;
|
||||||
const selectedSourceAccount = source?.account;
|
const selectedSourceAccount = source?.account;
|
||||||
try {
|
try {
|
||||||
@@ -53,10 +53,9 @@ const AddReadPermissionToDefaultIdentity: React.FC<AddReadPermissionToDefaultIde
|
|||||||
error.message || "Error assigning read permission to default identity. Please try again later.";
|
error.message || "Error assigning read permission to default identity. Please try again later.";
|
||||||
logError(errorMessage, "CopyJob/AddReadPermissionToDefaultIdentity.handleAddReadPermission");
|
logError(errorMessage, "CopyJob/AddReadPermissionToDefaultIdentity.handleAddReadPermission");
|
||||||
setContextError(errorMessage);
|
setContextError(errorMessage);
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [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" }}>
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
|||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
import { isIntraAccountCopy } from "../../../CopyJobUtils";
|
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}>
|
||||||
@@ -30,43 +31,92 @@ const PermissionSection: React.FC<PermissionSectionConfig> = ({ id, title, Compo
|
|||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
);
|
);
|
||||||
|
|
||||||
const AssignPermissions = () => {
|
const PermissionGroup: React.FC<PermissionGroupConfig> = ({ id, title, description, sections }) => {
|
||||||
const { copyJobState } = useCopyJobContext();
|
|
||||||
const permissionSections = usePermissionSections(copyJobState);
|
|
||||||
const [openItems, setOpenItems] = React.useState<string[]>([]);
|
const [openItems, setOpenItems] = React.useState<string[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const firstIncompleteSection = sections.find((section) => !section.completed);
|
||||||
|
const nextOpenItems = firstIncompleteSection ? [firstIncompleteSection.id] : [];
|
||||||
|
if (JSON.stringify(openItems) !== JSON.stringify(nextOpenItems)) {
|
||||||
|
setOpenItems(nextOpenItems);
|
||||||
|
}
|
||||||
|
}, [sections]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
tokens={{ childrenGap: 15 }}
|
||||||
|
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[]>(
|
const indentLevels = React.useMemo<IndentLevel[]>(
|
||||||
() => Array(copyJobState.migrationType === CopyJobMigrationType.Online ? 5 : 3).fill({ level: 0, width: "100%" }),
|
() => 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);
|
const isSameAccount = isIntraAccountCopy(copyJobState?.source?.account?.id, copyJobState?.target?.account?.id);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const firstIncompleteSection = permissionSections.find((section) => !section.completed);
|
return () => {
|
||||||
const nextOpenItems = firstIncompleteSection ? [firstIncompleteSection.id] : [];
|
setValidationCache(new Map<string, boolean>());
|
||||||
if (JSON.stringify(openItems) !== JSON.stringify(nextOpenItems)) {
|
};
|
||||||
setOpenItems(nextOpenItems);
|
}, []);
|
||||||
}
|
|
||||||
}, [permissionSections]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="assignPermissionsContainer" tokens={{ childrenGap: 15 }}>
|
<Stack className="assignPermissionsContainer" tokens={{ childrenGap: 20 }}>
|
||||||
<span>
|
{/* <Text variant="medium">{ContainerCopyMessages.assignPermissions.crossAccountDescription}</Text> */}
|
||||||
|
<Text variant="medium">
|
||||||
{isSameAccount && copyJobState.migrationType === CopyJobMigrationType.Online
|
{isSameAccount && copyJobState.migrationType === CopyJobMigrationType.Online
|
||||||
? ContainerCopyMessages.assignPermissions.intraAccountOnlineDescription(
|
? ContainerCopyMessages.assignPermissions.intraAccountOnlineDescription(
|
||||||
copyJobState?.source?.account?.name || "",
|
copyJobState?.source?.account?.name || "",
|
||||||
)
|
)
|
||||||
: ContainerCopyMessages.assignPermissions.crossAccountDescription}
|
: ContainerCopyMessages.assignPermissions.crossAccountDescription}
|
||||||
</span>
|
</Text>
|
||||||
{permissionSections?.length === 0 ? (
|
|
||||||
|
{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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Link, PrimaryButton, Stack } from "@fluentui/react";
|
import { Link, PrimaryButton, Stack } from "@fluentui/react";
|
||||||
import { CapabilityNames } from "Common/Constants";
|
|
||||||
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 { logError } from "../../../../../Common/Logger";
|
||||||
import { update as updateDatabaseAccount } from "../../../../../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { update as updateDatabaseAccount } from "../../../../../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
@@ -19,6 +20,7 @@ const validatorFn: AccountValidatorFn = (prev: DatabaseAccount, next: DatabaseAc
|
|||||||
|
|
||||||
const OnlineCopyEnabled: React.FC = () => {
|
const OnlineCopyEnabled: React.FC = () => {
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
|
const [loaderMessage, setLoaderMessage] = React.useState("");
|
||||||
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);
|
||||||
@@ -74,12 +76,21 @@ const OnlineCopyEnabled: React.FC = () => {
|
|||||||
setShowRefreshButton(false);
|
setShowRefreshButton(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoaderMessage(ContainerCopyMessages.onlineCopyEnabled.validateAllVersionsAndDeletesChangeFeedSpinnerLabel);
|
||||||
|
const sourAccountBeforeUpdate = await fetchDatabaseAccount(
|
||||||
|
sourceSubscriptionId,
|
||||||
|
sourceResourceGroup,
|
||||||
|
sourceAccountName,
|
||||||
|
);
|
||||||
|
if (!sourAccountBeforeUpdate?.properties.enableAllVersionsAndDeletesChangeFeed) {
|
||||||
|
setLoaderMessage(ContainerCopyMessages.onlineCopyEnabled.enablingAllVersionsAndDeletesChangeFeedSpinnerLabel);
|
||||||
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
||||||
properties: {
|
properties: {
|
||||||
enableAllVersionsAndDeletesChangeFeed: true,
|
enableAllVersionsAndDeletesChangeFeed: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
setLoaderMessage(ContainerCopyMessages.onlineCopyEnabled.enablingOnlineCopySpinnerLabel(sourceAccountName));
|
||||||
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
await updateDatabaseAccount(sourceSubscriptionId, sourceResourceGroup, sourceAccountName, {
|
||||||
properties: {
|
properties: {
|
||||||
capabilities: [...sourceAccountCapabilities, { name: CapabilityNames.EnableOnlineCopyFeature }],
|
capabilities: [...sourceAccountCapabilities, { name: CapabilityNames.EnableOnlineCopyFeature }],
|
||||||
@@ -119,6 +130,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={loaderMessage} />
|
||||||
<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">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ 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 { logError } from "../../../../../Common/Logger";
|
||||||
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
@@ -84,9 +85,10 @@ const PointInTimeRestore: React.FC = () => {
|
|||||||
setShowRefreshButton(true);
|
setShowRefreshButton(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
handleFetchAccount();
|
await handleFetchAccount();
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const openWindowAndMonitor = () => {
|
const openWindowAndMonitor = () => {
|
||||||
@@ -108,6 +110,7 @@ const PointInTimeRestore: React.FC = () => {
|
|||||||
|
|
||||||
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 && (
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ const useManagedIdentity = (
|
|||||||
const errorMessage = error.message || "Error enabling system-assigned managed identity. Please try again later.";
|
const errorMessage = error.message || "Error enabling system-assigned managed identity. Please try again later.";
|
||||||
logError(errorMessage, "CopyJob/useManagedIdentity.handleAddSystemIdentity");
|
logError(errorMessage, "CopyJob/useManagedIdentity.handleAddSystemIdentity");
|
||||||
setContextError(errorMessage);
|
setContextError(errorMessage);
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [copyJobState, updateIdentityFn, setCopyJobState]);
|
}, [updateIdentityFn]);
|
||||||
|
|
||||||
return { loading, handleAddSystemIdentity };
|
return { loading, handleAddSystemIdentity };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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, isIntraAccountCopy } 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,26 +134,86 @@ 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 isSameAccount = isIntraAccountCopy(sourceAccountId, targetAccountId);
|
const isSameAccount = isIntraAccountCopy(sourceAccount.accountId, targetAccount.accountId);
|
||||||
|
const crossAccountSections = isSameAccount ? [] : [...PERMISSION_SECTIONS_CONFIG];
|
||||||
|
const groups: PermissionGroupConfig[] = [];
|
||||||
|
const sourceAccountName = state.source?.account?.name || "";
|
||||||
|
const targetAccountName = state.target?.account?.name || "";
|
||||||
|
|
||||||
const baseSections = isSameAccount ? [] : [...PERMISSION_SECTIONS_CONFIG];
|
if (crossAccountSections.length > 0) {
|
||||||
if (state.migrationType === CopyJobMigrationType.Online) {
|
groups.push({
|
||||||
return [...baseSections, ...PERMISSION_SECTIONS_FOR_ONLINE_JOBS];
|
id: "crossAccountConfigs",
|
||||||
|
title: ContainerCopyMessages.assignPermissions.crossAccountConfiguration.title,
|
||||||
|
description: ContainerCopyMessages.assignPermissions.crossAccountConfiguration.description(
|
||||||
|
sourceAccountName,
|
||||||
|
targetAccountName,
|
||||||
|
),
|
||||||
|
sections: crossAccountSections,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
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(sourceAccountName),
|
||||||
|
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) {
|
||||||
@@ -157,52 +224,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;
|
||||||
@@ -13,6 +13,7 @@ const CreateCopyJobScreens: React.FC = () => {
|
|||||||
handlePrevious,
|
handlePrevious,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
primaryBtnText,
|
primaryBtnText,
|
||||||
|
showAddCollectionPanel,
|
||||||
} = useCopyJobNavigation();
|
} = useCopyJobNavigation();
|
||||||
const { contextError, setContextError } = useCopyJobContext();
|
const { contextError, setContextError } = useCopyJobContext();
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ const CreateCopyJobScreens: React.FC = () => {
|
|||||||
{contextError}
|
{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)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,25 +11,19 @@ export function useDropdownOptions(
|
|||||||
subscriptionOptions: DropdownOptionType[];
|
subscriptionOptions: DropdownOptionType[];
|
||||||
accountOptions: DropdownOptionType[];
|
accountOptions: DropdownOptionType[];
|
||||||
} {
|
} {
|
||||||
const subscriptionOptions = React.useMemo(
|
const subscriptionOptions =
|
||||||
() =>
|
|
||||||
subscriptions?.map((sub) => ({
|
subscriptions?.map((sub) => ({
|
||||||
key: sub.subscriptionId,
|
key: sub.subscriptionId,
|
||||||
text: sub.displayName,
|
text: sub.displayName,
|
||||||
data: sub,
|
data: sub,
|
||||||
})) || [],
|
})) || [];
|
||||||
[subscriptions],
|
|
||||||
);
|
|
||||||
|
|
||||||
const accountOptions = React.useMemo(
|
const accountOptions =
|
||||||
() =>
|
|
||||||
accounts?.map((account) => ({
|
accounts?.map((account) => ({
|
||||||
key: account.id,
|
key: account.id,
|
||||||
text: account.name,
|
text: account.name,
|
||||||
data: account,
|
data: account,
|
||||||
})) || [],
|
})) || [];
|
||||||
[accounts],
|
|
||||||
);
|
|
||||||
|
|
||||||
return { subscriptionOptions, accountOptions };
|
return { subscriptionOptions, accountOptions };
|
||||||
}
|
}
|
||||||
@@ -38,8 +32,10 @@ type setCopyJobStateType = CopyJobContextProviderType["setCopyJobState"];
|
|||||||
|
|
||||||
export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
||||||
const { setValidationCache } = useCopyJobPrerequisitesCache();
|
const { setValidationCache } = useCopyJobPrerequisitesCache();
|
||||||
const handleSelectSourceAccount = React.useCallback(
|
const handleSelectSourceAccount = (
|
||||||
(type: "subscription" | "account", data: (Subscription & DatabaseAccount) | undefined) => {
|
type: "subscription" | "account",
|
||||||
|
data: (Subscription & DatabaseAccount) | undefined,
|
||||||
|
) => {
|
||||||
setCopyJobState((prevState: CopyJobContextState) => {
|
setCopyJobState((prevState: CopyJobContextState) => {
|
||||||
if (type === "subscription") {
|
if (type === "subscription") {
|
||||||
return {
|
return {
|
||||||
@@ -63,20 +59,15 @@ export function useEventHandlers(setCopyJobState: setCopyJobStateType) {
|
|||||||
return prevState;
|
return prevState;
|
||||||
});
|
});
|
||||||
setValidationCache(new Map<string, boolean>());
|
setValidationCache(new Map<string, boolean>());
|
||||||
},
|
};
|
||||||
[setCopyJobState, setValidationCache],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleMigrationTypeChange = React.useCallback(
|
const handleMigrationTypeChange = React.useCallback((_ev?: React.FormEvent<HTMLElement>, checked?: boolean) => {
|
||||||
(_ev?: React.FormEvent<HTMLElement>, checked?: boolean) => {
|
|
||||||
setCopyJobState((prevState: CopyJobContextState) => ({
|
setCopyJobState((prevState: CopyJobContextState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
migrationType: checked ? CopyJobMigrationType.Offline : CopyJobMigrationType.Online,
|
migrationType: checked ? CopyJobMigrationType.Offline : CopyJobMigrationType.Online,
|
||||||
}));
|
}));
|
||||||
setValidationCache(new Map<string, boolean>());
|
setValidationCache(new Map<string, boolean>());
|
||||||
},
|
}, []);
|
||||||
[setCopyJobState, setValidationCache],
|
|
||||||
);
|
|
||||||
|
|
||||||
return { handleSelectSourceAccount, handleMigrationTypeChange };
|
return { handleSelectSourceAccount, handleMigrationTypeChange };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,36 +7,44 @@ import ContainerCopyMessages from "../../../ContainerCopyMessages";
|
|||||||
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
import { useCopyJobContext } from "../../../Context/CopyJobContext";
|
||||||
import { DatabaseContainerSection } from "./components/DatabaseContainerSection";
|
import { DatabaseContainerSection } from "./components/DatabaseContainerSection";
|
||||||
import { dropDownChangeHandler } from "./Events/DropDownChangeHandler";
|
import { dropDownChangeHandler } from "./Events/DropDownChangeHandler";
|
||||||
import { useMemoizedSourceAndTargetData } from "./memoizedData";
|
import { useSourceAndTargetData } 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);
|
useSourceAndTargetData(copyJobState);
|
||||||
|
|
||||||
const sourceDatabases = useDatabases(...sourceDbParams) || [];
|
if (!source) {
|
||||||
const sourceContainers = useDataContainers(...sourceContainerParams) || [];
|
return null;
|
||||||
const targetDatabases = useDatabases(...targetDbParams) || [];
|
}
|
||||||
const targetContainers = useDataContainers(...targetContainerParams) || [];
|
|
||||||
|
const sourceDatabases = useDatabases(...sourceDbParams);
|
||||||
|
const sourceContainers = useDataContainers(...sourceContainerParams);
|
||||||
|
const targetDatabases = useDatabases(...targetDbParams);
|
||||||
|
const targetContainers = useDataContainers(...targetContainerParams);
|
||||||
|
|
||||||
const sourceDatabaseOptions = React.useMemo(
|
const sourceDatabaseOptions = React.useMemo(
|
||||||
() => sourceDatabases.map((db: DatabaseModel) => ({ key: db.name, text: db.name, data: db })),
|
() => sourceDatabases?.map((db: DatabaseModel) => ({ key: db.name, text: db.name, data: db })) || [],
|
||||||
[sourceDatabases],
|
[sourceDatabases],
|
||||||
);
|
);
|
||||||
const sourceContainerOptions = React.useMemo(
|
const sourceContainerOptions = React.useMemo(
|
||||||
() => sourceContainers.map((c: DatabaseModel) => ({ key: c.name, text: c.name, data: c })),
|
() => sourceContainers?.map((c: DatabaseModel) => ({ key: c.name, text: c.name, data: c })) || [],
|
||||||
[sourceContainers],
|
[sourceContainers],
|
||||||
);
|
);
|
||||||
const targetDatabaseOptions = React.useMemo(
|
const targetDatabaseOptions = React.useMemo(
|
||||||
() => targetDatabases.map((db: DatabaseModel) => ({ key: db.name, text: db.name, data: db })),
|
() => targetDatabases?.map((db: DatabaseModel) => ({ key: db.name, text: db.name, data: db })) || [],
|
||||||
[targetDatabases],
|
[targetDatabases],
|
||||||
);
|
);
|
||||||
const targetContainerOptions = React.useMemo(
|
const targetContainerOptions = React.useMemo(
|
||||||
() => targetContainers.map((c: DatabaseModel) => ({ key: c.name, text: c.name, data: c })),
|
() => targetContainers?.map((c: DatabaseModel) => ({ key: c.name, text: c.name, data: c })) || [],
|
||||||
[targetContainers],
|
[targetContainers],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onDropdownChange = React.useCallback(dropDownChangeHandler(setCopyJobState), [setCopyJobState]);
|
const onDropdownChange = dropDownChangeHandler(setCopyJobState);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="selectSourceAndTargetContainers" tokens={{ childrenGap: 25 }}>
|
<Stack className="selectSourceAndTargetContainers" tokens={{ childrenGap: 25 }}>
|
||||||
@@ -62,6 +70,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,6 +30,7 @@ export const DatabaseContainerSection = ({
|
|||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
<FieldRow label={ContainerCopyMessages.containerDropdownLabel}>
|
<FieldRow label={ContainerCopyMessages.containerDropdownLabel}>
|
||||||
|
<Stack>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
placeholder={ContainerCopyMessages.containerDropdownPlaceholder}
|
placeholder={ContainerCopyMessages.containerDropdownPlaceholder}
|
||||||
ariaLabel={ContainerCopyMessages.containerDropdownLabel}
|
ariaLabel={ContainerCopyMessages.containerDropdownLabel}
|
||||||
@@ -38,6 +40,12 @@ export const DatabaseContainerSection = ({
|
|||||||
selectedKey={selectedContainer}
|
selectedKey={selectedContainer}
|
||||||
onChange={containerOnChange}
|
onChange={containerOnChange}
|
||||||
/>
|
/>
|
||||||
|
{handleOnDemandCreateContainer && (
|
||||||
|
<ActionButton className="create-container-link-btn" onClick={() => handleOnDemandCreateContainer()}>
|
||||||
|
{ContainerCopyMessages.createContainerButtonLabel}
|
||||||
|
</ActionButton>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import React from "react";
|
|
||||||
import { getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
import { getAccountDetailsFromResourceId } from "../../../CopyJobUtils";
|
||||||
import { CopyJobContextState, DatabaseParams, DataContainerParams } from "../../../Types/CopyJobTypes";
|
import { CopyJobContextState, DatabaseParams, DataContainerParams } from "../../../Types/CopyJobTypes";
|
||||||
|
|
||||||
export function useMemoizedSourceAndTargetData(copyJobState: CopyJobContextState) {
|
export function useSourceAndTargetData(copyJobState: CopyJobContextState) {
|
||||||
const { source, target } = copyJobState ?? {};
|
const { source, target } = copyJobState ?? {};
|
||||||
const selectedSourceAccount = source?.account;
|
const selectedSourceAccount = source?.account;
|
||||||
const selectedTargetAccount = target?.account;
|
const selectedTargetAccount = target?.account;
|
||||||
@@ -17,27 +16,22 @@ export function useMemoizedSourceAndTargetData(copyJobState: CopyJobContextState
|
|||||||
accountName: targetAccountName,
|
accountName: targetAccountName,
|
||||||
} = getAccountDetailsFromResourceId(selectedTargetAccount?.id);
|
} = getAccountDetailsFromResourceId(selectedTargetAccount?.id);
|
||||||
|
|
||||||
const sourceDbParams = React.useMemo(
|
const sourceDbParams = [sourceSubscriptionId, sourceResourceGroup, sourceAccountName, "SQL"] as DatabaseParams;
|
||||||
() => [sourceSubscriptionId, sourceResourceGroup, sourceAccountName, "SQL"] as DatabaseParams,
|
const sourceContainerParams = [
|
||||||
[sourceSubscriptionId, sourceResourceGroup, sourceAccountName],
|
sourceSubscriptionId,
|
||||||
);
|
sourceResourceGroup,
|
||||||
|
sourceAccountName,
|
||||||
const sourceContainerParams = React.useMemo(
|
source?.databaseId,
|
||||||
() =>
|
"SQL",
|
||||||
[sourceSubscriptionId, sourceResourceGroup, sourceAccountName, source?.databaseId, "SQL"] as DataContainerParams,
|
] as DataContainerParams;
|
||||||
[sourceSubscriptionId, sourceResourceGroup, sourceAccountName, source?.databaseId],
|
const targetDbParams = [targetSubscriptionId, targetResourceGroup, targetAccountName, "SQL"] as DatabaseParams;
|
||||||
);
|
const targetContainerParams = [
|
||||||
|
targetSubscriptionId,
|
||||||
const targetDbParams = React.useMemo(
|
targetResourceGroup,
|
||||||
() => [targetSubscriptionId, targetResourceGroup, targetAccountName, "SQL"] as DatabaseParams,
|
targetAccountName,
|
||||||
[targetSubscriptionId, targetResourceGroup, targetAccountName],
|
target?.databaseId,
|
||||||
);
|
"SQL",
|
||||||
|
] as DataContainerParams;
|
||||||
const targetContainerParams = React.useMemo(
|
|
||||||
() =>
|
|
||||||
[targetSubscriptionId, targetResourceGroup, targetAccountName, target?.databaseId, "SQL"] as DataContainerParams,
|
|
||||||
[targetSubscriptionId, targetResourceGroup, targetAccountName, target?.databaseId],
|
|
||||||
);
|
|
||||||
|
|
||||||
return { source, target, sourceDbParams, sourceContainerParams, targetDbParams, targetContainerParams };
|
return { source, target, sourceDbParams, sourceContainerParams, targetDbParams, targetContainerParams };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +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 { isIntraAccountCopy } from "../../CopyJobUtils";
|
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";
|
||||||
@@ -35,10 +35,14 @@ function navigationReducer(state: NavigationState, action: Action): NavigationSt
|
|||||||
export function useCopyJobNavigation() {
|
export function useCopyJobNavigation() {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { copyJobState, resetCopyJobState, setContextError } = useCopyJobContext();
|
const { copyJobState, resetCopyJobState, setContextError } = 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,12 +71,6 @@ 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 areContainersIdentical = () => {
|
const areContainersIdentical = () => {
|
||||||
const { source, target } = copyJobState;
|
const { source, target } = copyJobState;
|
||||||
const sourceIds = getContainerIdentifiers(source);
|
const sourceIds = getContainerIdentifiers(source);
|
||||||
@@ -107,7 +107,26 @@ export function useCopyJobNavigation() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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()) {
|
||||||
setContextError(
|
setContextError(
|
||||||
"Source and destination containers cannot be the same. Please select different containers to proceed.",
|
"Source and destination containers cannot be the same. Please select different containers to proceed.",
|
||||||
@@ -132,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,
|
||||||
@@ -143,6 +158,7 @@ export function useCopyJobNavigation() {
|
|||||||
handlePrimary,
|
handlePrimary,
|
||||||
handlePrevious,
|
handlePrevious,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
|
showAddCollectionPanel,
|
||||||
primaryBtnText,
|
primaryBtnText,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { FontIcon, getTheme, mergeStyles, mergeStyleSets, Spinner, SpinnerSize, Stack, Text } from "@fluentui/react";
|
import { FontIcon, getTheme, mergeStyles, mergeStyleSets, Spinner, SpinnerSize, Stack, Text } from "@fluentui/react";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ContainerCopyMessages from "../../ContainerCopyMessages";
|
import ContainerCopyMessages from "../../ContainerCopyMessages";
|
||||||
import { CopyJobStatusType } from "../../Enums/CopyJobEnums";
|
import { CopyJobStatusType } from "../../Enums/CopyJobEnums";
|
||||||
@@ -34,7 +35,11 @@ const iconMap: Partial<Record<CopyJobStatusType, string>> = {
|
|||||||
[CopyJobStatusType.Completed]: "CompletedSolid",
|
[CopyJobStatusType.Completed]: "CompletedSolid",
|
||||||
};
|
};
|
||||||
|
|
||||||
const CopyJobStatusWithIcon: React.FC<{ status: CopyJobStatusType }> = ({ status }) => {
|
export interface CopyJobStatusWithIconProps {
|
||||||
|
status: CopyJobStatusType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CopyJobStatusWithIcon: React.FC<CopyJobStatusWithIconProps> = React.memo(({ status }) => {
|
||||||
const statusText = ContainerCopyMessages.MonitorJobs.Status[status] || "Unknown";
|
const statusText = ContainerCopyMessages.MonitorJobs.Status[status] || "Unknown";
|
||||||
|
|
||||||
const isSpinnerStatus = [
|
const isSpinnerStatus = [
|
||||||
@@ -57,6 +62,11 @@ const CopyJobStatusWithIcon: React.FC<{ status: CopyJobStatusType }> = ({ status
|
|||||||
<Text>{statusText}</Text>
|
<Text>{statusText}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
CopyJobStatusWithIcon.displayName = "CopyJobStatusWithIcon";
|
||||||
|
CopyJobStatusWithIcon.propTypes = {
|
||||||
|
status: PropTypes.oneOf(Object.values(CopyJobStatusType)).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CopyJobStatusWithIcon;
|
export default CopyJobStatusWithIcon;
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
import { ActionButton, Image } from "@fluentui/react";
|
import { ActionButton, Image } from "@fluentui/react";
|
||||||
import React, { useCallback } from "react";
|
import Explorer from "Explorer/Explorer";
|
||||||
|
import React, { memo } 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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CopyJobsNotFound;
|
export default memo(CopyJobsNotFound);
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
/* eslint-disable react/prop-types */
|
||||||
import {
|
import {
|
||||||
ConstrainMode,
|
ConstrainMode,
|
||||||
DetailsListLayoutMode,
|
DetailsListLayoutMode,
|
||||||
DetailsRow,
|
DetailsRow,
|
||||||
IColumn,
|
IColumn,
|
||||||
|
IDetailsRowProps,
|
||||||
ScrollablePane,
|
ScrollablePane,
|
||||||
ScrollbarVisibility,
|
ScrollbarVisibility,
|
||||||
ShimmeredDetailsList,
|
ShimmeredDetailsList,
|
||||||
@@ -58,22 +60,19 @@ const CopyJobsList: React.FC<CopyJobsListProps> = ({ jobs, handleActionClick, pa
|
|||||||
setStartIndex(0);
|
setStartIndex(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: IColumn[] = React.useMemo(
|
const columns: IColumn[] = getColumns(handleSort, handleActionClick, sortedColumnKey, isSortedDescending);
|
||||||
() => getColumns(handleSort, handleActionClick, sortedColumnKey, isSortedDescending),
|
|
||||||
[handleSort, handleActionClick, sortedColumnKey, isSortedDescending],
|
|
||||||
);
|
|
||||||
|
|
||||||
const _handleRowClick = React.useCallback((job: CopyJobType) => {
|
const _handleRowClick = (job: CopyJobType) => {
|
||||||
openCopyJobDetailsPanel(job);
|
openCopyJobDetailsPanel(job);
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
const _onRenderRow = React.useCallback((props: any) => {
|
const _onRenderRow = (props: IDetailsRowProps) => {
|
||||||
return (
|
return (
|
||||||
<div onClick={_handleRowClick.bind(null, props.item)}>
|
<div onClick={_handleRowClick.bind(null, props.item)}>
|
||||||
<DetailsRow {...props} styles={{ root: { cursor: "pointer" } }} />
|
<DetailsRow {...props} styles={{ root: { cursor: "pointer" } }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={styles.container}>
|
<div style={styles.container}>
|
||||||
|
|||||||
@@ -1,31 +1,33 @@
|
|||||||
/* 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, isEqual } from "../CopyJobUtils";
|
||||||
import { CopyJobStatusType } from "../Enums/CopyJobEnums";
|
import { CopyJobStatusType } from "../Enums/CopyJobEnums";
|
||||||
import CopyJobsNotFound from "../MonitorCopyJobs/Components/CopyJobs.NotFound";
|
import CopyJobsNotFound from "../MonitorCopyJobs/Components/CopyJobs.NotFound";
|
||||||
import { CopyJobType, JobActionUpdatorType } from "../Types/CopyJobTypes";
|
import { CopyJobType, JobActionUpdatorType } from "../Types/CopyJobTypes";
|
||||||
import CopyJobsList from "./Components/CopyJobsList";
|
import CopyJobsList from "./Components/CopyJobsList";
|
||||||
|
|
||||||
const FETCH_INTERVAL_MS = 30 * 1000;
|
const FETCH_INTERVAL_MS = 30 * 1000;
|
||||||
|
const SHIMMER_INDENT_LEVELS: IndentLevel[] = Array(7).fill({ level: 0, width: "100%" });
|
||||||
|
|
||||||
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[]>([]);
|
||||||
const isUpdatingRef = React.useRef(false);
|
const isUpdatingRef = React.useRef(false);
|
||||||
const isFirstFetchRef = React.useRef(true);
|
const isFirstFetchRef = React.useRef(true);
|
||||||
|
|
||||||
const indentLevels = React.useMemo<IndentLevel[]>(() => Array(7).fill({ level: 0, width: "100%" }), []);
|
|
||||||
|
|
||||||
const fetchJobs = React.useCallback(async () => {
|
const fetchJobs = React.useCallback(async () => {
|
||||||
if (isUpdatingRef.current) {
|
if (isUpdatingRef.current) {
|
||||||
return;
|
return;
|
||||||
@@ -38,8 +40,7 @@ const MonitorCopyJobs = forwardRef<MonitorCopyJobsRef, MonitorCopyJobsProps>((_p
|
|||||||
|
|
||||||
const response = await getCopyJobs();
|
const response = await getCopyJobs();
|
||||||
setJobs((prevJobs) => {
|
setJobs((prevJobs) => {
|
||||||
const isSame = JSON.stringify(prevJobs) === JSON.stringify(response);
|
return isEqual(prevJobs, response) ? prevJobs : response;
|
||||||
return isSame ? prevJobs : response;
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error.message || "Failed to load copy jobs. Please try again later.");
|
setError(error.message || "Failed to load copy jobs. Please try again later.");
|
||||||
@@ -96,25 +97,27 @@ 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">
|
||||||
{loading && <ShimmerTree indentLevels={indentLevels} style={{ width: "100%", padding: "1rem 2.5rem" }} />}
|
{loading && (
|
||||||
|
<ShimmerTree indentLevels={SHIMMER_INDENT_LEVELS} style={{ width: "100%", padding: "1rem 2.5rem" }} />
|
||||||
|
)}
|
||||||
{error && (
|
{error && (
|
||||||
<MessageBar messageBarType={MessageBarType.error} isMultiline={false} onDismiss={() => setError(null)}>
|
<MessageBar messageBarType={MessageBarType.error} isMultiline={false} onDismiss={() => setError(null)}>
|
||||||
{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 {
|
||||||
@@ -80,6 +81,7 @@ export interface CopyJobContextProviderType {
|
|||||||
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 = {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
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>
|
||||||
|
|
||||||
|
{!this.props.isCopyJobFlow && (
|
||||||
<PanelFooterComponent buttonLabel="OK" isButtonDisabled={this.state.isThroughputCapExceeded} />
|
<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 });
|
||||||
|
|
||||||
|
if (this.props.isCopyJobFlow && this.props.onSubmitSuccess) {
|
||||||
|
this.props.onSubmitSuccess({ databaseId, collectionId });
|
||||||
|
} else {
|
||||||
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
||||||
useSidePanel.getState().closeSidePanel();
|
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 });
|
||||||
|
|||||||
@@ -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} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { DatabaseAccount } from "Contracts/DataModels";
|
|||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
import { buildArmUrl } from "Utils/arm/armUtils";
|
import { buildArmUrl } from "Utils/arm/armUtils";
|
||||||
|
|
||||||
const apiVersion = "2025-04-15";
|
const apiVersion = "2025-05-01-preview";
|
||||||
export type FetchAccountDetailsParams = {
|
export type FetchAccountDetailsParams = {
|
||||||
subscriptionId: string;
|
subscriptionId: string;
|
||||||
resourceGroupName: string;
|
resourceGroupName: string;
|
||||||
|
|||||||
@@ -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 })),
|
||||||
|
|||||||
Reference in New Issue
Block a user