Fabric Home App Dev button opens Fabric UX extension Settings Connection tab

This commit is contained in:
Laurent Nguyen 2025-04-29 14:31:56 +02:00
parent 274c85d2de
commit e220e0e74b
4 changed files with 18 additions and 5 deletions

View File

@ -18,10 +18,13 @@ export type DataExploreMessageV3 =
| { | {
type: FabricMessageTypes.GetAllResourceTokens; type: FabricMessageTypes.GetAllResourceTokens;
id: string; id: string;
}
| {
type: FabricMessageTypes.OpenSettings;
params: [{ settingsId?: "About" | "Connection" }];
}; };
export interface GetCosmosTokenMessageOptions {
export type GetCosmosTokenMessageOptions = {
verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"; verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
resourceType: "" | "dbs" | "colls" | "docs" | "sprocs" | "pkranges"; resourceType: "" | "dbs" | "colls" | "docs" | "sprocs" | "pkranges";
resourceId: string; resourceId: string;
}; }

View File

@ -6,6 +6,7 @@ export enum FabricMessageTypes {
GetAllResourceTokens = "GetAllResourceTokens", GetAllResourceTokens = "GetAllResourceTokens",
GetAccessToken = "GetAccessToken", GetAccessToken = "GetAccessToken",
Ready = "Ready", Ready = "Ready",
OpenSettings = "OpenSettings",
} }
export interface AuthorizationToken { export interface AuthorizationToken {

View File

@ -5,7 +5,7 @@ import { Link, makeStyles, tokens } from "@fluentui/react-components";
import { DocumentAddRegular, LinkMultipleRegular } from "@fluentui/react-icons"; import { DocumentAddRegular, LinkMultipleRegular } from "@fluentui/react-icons";
import { SampleDataImportDialog } from "Explorer/SplashScreen/SampleDataImportDialog"; import { SampleDataImportDialog } from "Explorer/SplashScreen/SampleDataImportDialog";
import { CosmosFluentProvider } from "Explorer/Theme/ThemeUtil"; import { CosmosFluentProvider } from "Explorer/Theme/ThemeUtil";
import { isFabricNative } from "Platform/Fabric/FabricUtil"; import { isFabricNative, openSettingsConnectionTab } from "Platform/Fabric/FabricUtil";
import * as React from "react"; import * as React from "react";
import { userContext } from "UserContext"; import { userContext } from "UserContext";
import CosmosDbBlackIcon from "../../../images/CosmosDB_black.svg"; import CosmosDbBlackIcon from "../../../images/CosmosDB_black.svg";
@ -146,7 +146,7 @@ export const FabricHomeScreen: React.FC<SplashScreenProps> = (props: SplashScree
title: "App development", title: "App development",
description: "Start here to use an SDK to build your apps", description: "Start here to use an SDK to build your apps",
icon: <LinkMultipleRegular />, icon: <LinkMultipleRegular />,
onClick: () => window.open("https://aka.ms/cosmosdbfabricsdk", "_blank"), onClick: () => openSettingsConnectionTab(),
}, },
]; ];

View File

@ -128,6 +128,15 @@ export const checkDatabaseResourceTokensValidity = (tokenTimestamp: number): voi
} }
}; };
/**
* Open the connection tab in the settings page of the Fabric UX extension
*/
export const openSettingsConnectionTab = (): void => {
if (configContext.platform === Platform.Fabric) {
sendCachedDataMessage(FabricMessageTypes.OpenSettings, [{ settingsId: "Connection" }]);
}
};
export const isFabric = (): boolean => configContext.platform === Platform.Fabric; export const isFabric = (): boolean => configContext.platform === Platform.Fabric;
export const isFabricMirroredKey = (): boolean => export const isFabricMirroredKey = (): boolean =>
isFabric() && userContext.fabricContext?.artifactType === CosmosDbArtifactType.MIRRORED_KEY; isFabric() && userContext.fabricContext?.artifactType === CosmosDbArtifactType.MIRRORED_KEY;