mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-15 01:37:37 +01:00
Fixing errors
This commit is contained in:
@@ -105,11 +105,11 @@ export const PartitionKeyComponent: React.FC<PartitionKeyComponentProps> = ({
|
|||||||
const textSubHeadingStyle1 = {
|
const textSubHeadingStyle1 = {
|
||||||
root: { color: "var(--colorNeutralForeground1)" },
|
root: { color: "var(--colorNeutralForeground1)" },
|
||||||
};
|
};
|
||||||
const startPollingforUpdate = (currentJob: DataTransferJobGetResults) => {
|
const startPollingforUpdate = async (currentJob: DataTransferJobGetResults) => {
|
||||||
if (isCurrentJobInProgress(currentJob)) {
|
if (isCurrentJobInProgress(currentJob)) {
|
||||||
const jobName = currentJob?.properties?.jobName;
|
const jobName = currentJob?.properties?.jobName;
|
||||||
try {
|
try {
|
||||||
pollDataTransferJob(
|
await pollDataTransferJob(
|
||||||
jobName,
|
jobName,
|
||||||
userContext.subscriptionId,
|
userContext.subscriptionId,
|
||||||
userContext.resourceGroup,
|
userContext.resourceGroup,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
ChoiceGroup,
|
|
||||||
DefaultButton,
|
DefaultButton,
|
||||||
DirectionalHint,
|
DirectionalHint,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
@@ -15,8 +14,9 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
TooltipHost,
|
TooltipHost,
|
||||||
} from "@fluentui/react";
|
} from "@fluentui/react";
|
||||||
import { CapabilityNames } from "Common/Constants";
|
import MarkdownRender from "@nteract/markdown";
|
||||||
import * as Constants from "Common/Constants";
|
import * as Constants from "Common/Constants";
|
||||||
|
import { CapabilityNames } from "Common/Constants";
|
||||||
import { handleError } from "Common/ErrorHandlingUtils";
|
import { handleError } from "Common/ErrorHandlingUtils";
|
||||||
import LoadingOverlay from "Common/LoadingOverlay";
|
import LoadingOverlay from "Common/LoadingOverlay";
|
||||||
import { logError } from "Common/Logger";
|
import { logError } from "Common/Logger";
|
||||||
@@ -24,13 +24,13 @@ import { createCollection } from "Common/dataAccess/createCollection";
|
|||||||
import { DataTransferParams, initiateDataTransfer } from "Common/dataAccess/dataTransfers";
|
import { DataTransferParams, initiateDataTransfer } from "Common/dataAccess/dataTransfers";
|
||||||
import * as DataModels from "Contracts/DataModels";
|
import * as DataModels from "Contracts/DataModels";
|
||||||
import * as ViewModels from "Contracts/ViewModels";
|
import * as ViewModels from "Contracts/ViewModels";
|
||||||
|
import { BackupPolicyType, CopyJobMigrationType } from "Explorer/ContainerCopy/Enums/CopyJobEnums";
|
||||||
import {
|
import {
|
||||||
getPartitionKeyName,
|
getPartitionKeyName,
|
||||||
getPartitionKeyPlaceHolder,
|
getPartitionKeyPlaceHolder,
|
||||||
getPartitionKeySubtext,
|
getPartitionKeySubtext,
|
||||||
getPartitionKeyTooltipText,
|
getPartitionKeyTooltipText,
|
||||||
} from "Explorer/Controls/Settings/SettingsUtils";
|
} from "Explorer/Controls/Settings/SettingsUtils";
|
||||||
import { BackupPolicyType, CopyJobMigrationType } from "Explorer/ContainerCopy/Enums/CopyJobEnums";
|
|
||||||
import Explorer from "Explorer/Explorer";
|
import Explorer from "Explorer/Explorer";
|
||||||
import { RightPaneForm } from "Explorer/Panes/RightPaneForm/RightPaneForm";
|
import { RightPaneForm } from "Explorer/Panes/RightPaneForm/RightPaneForm";
|
||||||
import { useDatabases } from "Explorer/useDatabases";
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
@@ -98,7 +98,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
const [isExecuting, setIsExecuting] = React.useState<boolean>(false);
|
const [isExecuting, setIsExecuting] = React.useState<boolean>(false);
|
||||||
const [subPartitionKeys, setSubPartitionKeys] = React.useState<string[]>([]);
|
const [subPartitionKeys, setSubPartitionKeys] = React.useState<string[]>([]);
|
||||||
const [partitionKey, setPartitionKey] = React.useState<string>();
|
const [partitionKey, setPartitionKey] = React.useState<string>();
|
||||||
const [migrationType, setMigrationType] = React.useState<CopyJobMigrationType>(CopyJobMigrationType.Offline);
|
const [onlineMode, setOnlineMode] = React.useState<boolean>(false);
|
||||||
|
|
||||||
// Pane-local account state for tracking prerequisite enablement
|
// Pane-local account state for tracking prerequisite enablement
|
||||||
const [localAccount, setLocalAccount] = React.useState<DataModels.DatabaseAccount>(userContext.databaseAccount);
|
const [localAccount, setLocalAccount] = React.useState<DataModels.DatabaseAccount>(userContext.databaseAccount);
|
||||||
@@ -108,7 +108,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
const pitrEnabled = checkPitrEnabled(localAccount);
|
const pitrEnabled = checkPitrEnabled(localAccount);
|
||||||
const onlineCopyFeatureEnabled = checkOnlineCopyEnabled(localAccount);
|
const onlineCopyFeatureEnabled = checkOnlineCopyEnabled(localAccount);
|
||||||
const onlinePrerequisitesMet = pitrEnabled && onlineCopyFeatureEnabled;
|
const onlinePrerequisitesMet = pitrEnabled && onlineCopyFeatureEnabled;
|
||||||
const isOnlineMode = migrationType === CopyJobMigrationType.Online;
|
|
||||||
|
|
||||||
const accountName = localAccount?.name ?? "";
|
const accountName = localAccount?.name ?? "";
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
@@ -242,7 +241,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
setFormError("Choose an existing container");
|
setFormError("Choose an existing container");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isOnlineMode && !onlinePrerequisitesMet) {
|
if (onlineMode && !onlinePrerequisitesMet) {
|
||||||
setFormError("Online migration prerequisites must be enabled before proceeding.");
|
setFormError("Online migration prerequisites must be enabled before proceeding.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -250,7 +249,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getModeForApi = (): "Offline" | "Online" => {
|
const getModeForApi = (): "Offline" | "Online" => {
|
||||||
return migrationType === CopyJobMigrationType.Online ? "Online" : "Offline";
|
return onlineMode ? "Online" : "Offline";
|
||||||
};
|
};
|
||||||
|
|
||||||
const createDataTransferJob = async () => {
|
const createDataTransferJob = async () => {
|
||||||
@@ -300,7 +299,10 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
return !!selectedDatabase?.offer();
|
return !!selectedDatabase?.offer();
|
||||||
};
|
};
|
||||||
|
|
||||||
const isSubmitDisabled = isOnlineMode && !onlinePrerequisitesMet;
|
const isSubmitDisabled = onlineMode && !onlinePrerequisitesMet;
|
||||||
|
|
||||||
|
const migrationTypeLowercase = getModeForApi().toLowerCase() as keyof typeof Keys.containerCopy.migrationType;
|
||||||
|
const migrationTypeContent = Keys.containerCopy.migrationType[migrationTypeLowercase];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RightPaneForm
|
<RightPaneForm
|
||||||
@@ -327,27 +329,43 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
<Text className="panelTextBold" variant="small" style={{ marginBottom: 4 }}>
|
<Text className="panelTextBold" variant="small" style={{ marginBottom: 4 }}>
|
||||||
Migration type
|
Migration type
|
||||||
</Text>
|
</Text>
|
||||||
<ChoiceGroup
|
<Stack className="panelGroupSpacing" horizontal verticalAlign="center">
|
||||||
data-test="migration-type-choice"
|
<div role="radiogroup">
|
||||||
selectedKey={migrationType}
|
<input
|
||||||
options={migrationTypeOptions}
|
className="panelRadioBtn"
|
||||||
onChange={(_ev, option) => {
|
checked={!onlineMode}
|
||||||
if (option) {
|
aria-label="Offline mode"
|
||||||
setMigrationType(option.key as CopyJobMigrationType);
|
aria-checked={!onlineMode}
|
||||||
}
|
name="migrationType"
|
||||||
}}
|
type="radio"
|
||||||
ariaLabelledBy="migrationTypeChoiceGroup"
|
role="radio"
|
||||||
styles={choiceGroupStyles}
|
id="migrationTypeOffline"
|
||||||
/>
|
tabIndex={0}
|
||||||
{migrationType && (
|
onChange={() => setOnlineMode(false)}
|
||||||
|
/>
|
||||||
|
<span className="panelRadioBtnLabel">Offline mode</span>
|
||||||
|
|
||||||
|
<input
|
||||||
|
className="panelRadioBtn"
|
||||||
|
checked={onlineMode}
|
||||||
|
aria-label="Online mode"
|
||||||
|
aria-checked={onlineMode}
|
||||||
|
name="migrationType"
|
||||||
|
type="radio"
|
||||||
|
role="radio"
|
||||||
|
tabIndex={0}
|
||||||
|
onChange={() => setOnlineMode(true)}
|
||||||
|
/>
|
||||||
|
<span className="panelRadioBtnLabel">Online mode</span>
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
{migrationTypeContent && (
|
||||||
<Text
|
<Text
|
||||||
variant="small"
|
variant="small"
|
||||||
style={{ color: "var(--colorNeutralForeground1)", marginTop: 4 }}
|
style={{ color: "var(--colorNeutralForeground1)", marginTop: 4 }}
|
||||||
data-test={`migration-type-description-${migrationType}`}
|
data-test={`migration-type-description-${migrationTypeLowercase}`}
|
||||||
>
|
>
|
||||||
{migrationType === CopyJobMigrationType.Offline
|
<MarkdownRender source={t(migrationTypeContent.description)} linkTarget="_blank" />
|
||||||
? t(Keys.containerCopy.migrationType.offline.description)
|
|
||||||
: t(Keys.containerCopy.migrationType.online.description)}
|
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -623,7 +641,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Online prerequisites section */}
|
{/* Online prerequisites section */}
|
||||||
{isOnlineMode && (
|
{onlineMode && (
|
||||||
<Stack data-test="online-prerequisites-section" tokens={{ childrenGap: 10 }}>
|
<Stack data-test="online-prerequisites-section" tokens={{ childrenGap: 10 }}>
|
||||||
<LoadingOverlay isLoading={isEnablingPrerequisite} label={prerequisiteLoaderMessage} />
|
<LoadingOverlay isLoading={isEnablingPrerequisite} label={prerequisiteLoaderMessage} />
|
||||||
<Text className="panelTextBold" variant="small">
|
<Text className="panelTextBold" variant="small">
|
||||||
|
|||||||
Reference in New Issue
Block a user