Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Contracts/DataExplorerMessagesContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type DataExploreMessageV3 =
| {
type: FabricMessageTypes.OpenSettings;
settingsId: string;
}
| {
type: FabricMessageTypes.RestoreContainer;
params: [];
};
export interface GetCosmosTokenMessageOptions {
verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/FabricMessageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum FabricMessageTypes {
GetAccessToken = "GetAccessToken",
Ready = "Ready",
OpenSettings = "OpenSettings",
RestoreContainer = "RestoreContainer",
}

export interface AuthorizationToken {
Expand Down
14 changes: 13 additions & 1 deletion src/Explorer/ContextMenuButtonFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
AddGlobalSecondaryIndexPanelProps,
} from "Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel";
import { useDatabases } from "Explorer/useDatabases";
import { isFabric, isFabricNative } from "Platform/Fabric/FabricUtil";
import { isFabric, isFabricNative, openRestoreContainerDialog } from "Platform/Fabric/FabricUtil";
import { Action } from "Shared/Telemetry/TelemetryConstants";
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
import { ReactTabKind, useTabs } from "hooks/useTabs";
Expand Down Expand Up @@ -35,6 +35,7 @@ import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger";
import UserDefinedFunction from "./Tree/UserDefinedFunction";
import { useSelectedNode } from "./useSelectedNode";
import { extractFeatures } from "../Platform/Hosted/extractFeatures";

export interface CollectionContextMenuButtonParams {
databaseId: string;
Expand All @@ -60,6 +61,17 @@ export const createDatabaseContextMenu = (container: Explorer, databaseId: strin
},
];

if (isFabric() && !userContext.fabricContext?.isReadOnly) {
const features = extractFeatures();
if (features?.enableRestoreContainer) {
items.push({
iconSrc: AddCollectionIcon,
onClick: () => openRestoreContainerDialog(),
label: `Restore ${getCollectionName()}`,
});
}
}

if (!isFabricNative() && (userContext.apiType !== "Tables" || userContext.features.enableSDKoperations)) {
items.push({
iconSrc: DeleteDatabaseIcon,
Expand Down
6 changes: 6 additions & 0 deletions src/Platform/Fabric/FabricUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ const requestAndStoreAccessToken = async (): Promise<void> => {
});
};

export const openRestoreContainerDialog = (): void => {
if (configContext.platform === Platform.Fabric) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we use isFabricNative() instead?

sendCachedDataMessage(FabricMessageTypes.RestoreContainer, []);
}
};

/**
* Check token validity and schedule a refresh if necessary
* @param tokenTimestamp
Expand Down
2 changes: 2 additions & 0 deletions src/Platform/Hosted/extractFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type Features = {
readonly enablePriorityBasedExecution: boolean;
readonly disableConnectionStringLogin: boolean;
readonly enableCloudShell: boolean;
readonly enableRestoreContainer: boolean; // only for Fabric

// can be set via both flight and feature flag
autoscaleDefault: boolean;
Expand Down Expand Up @@ -111,6 +112,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"),
enablePriorityBasedExecution: "true" === get("enableprioritybasedexecution"),
disableConnectionStringLogin: "true" === get("disableconnectionstringlogin"),
enableRestoreContainer: "true" === get("enablerestorecontainer"),
enableCloudShell: true,
};
}
Expand Down
Loading