mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
feat: Send message to Fabric when container is updated (via settings, created or deleted) (#2221)
* Send message to Fabric when container is updated (via settings, created or deleted). * Fix format --------- Co-authored-by: Laurent Nguyen <languye@microsoft.com>
This commit is contained in:
parent
569e5ed1fc
commit
909957a9a1
@ -1,4 +1,6 @@
|
|||||||
import { ContainerRequest, ContainerResponse, DatabaseRequest, DatabaseResponse, RequestOptions } from "@azure/cosmos";
|
import { ContainerRequest, ContainerResponse, DatabaseRequest, DatabaseResponse, RequestOptions } from "@azure/cosmos";
|
||||||
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import { isFabricNative } from "Platform/Fabric/FabricUtil";
|
import { isFabricNative } from "Platform/Fabric/FabricUtil";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
@ -43,6 +45,14 @@ export const createCollection = async (params: DataModels.CreateCollectionParams
|
|||||||
}
|
}
|
||||||
|
|
||||||
logConsoleInfo(`Successfully created container ${params.collectionId}`);
|
logConsoleInfo(`Successfully created container ${params.collectionId}`);
|
||||||
|
|
||||||
|
if (isFabricNative()) {
|
||||||
|
sendMessage({
|
||||||
|
type: FabricMessageTypes.ContainerUpdated,
|
||||||
|
params: { updateType: "created" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "CreateCollection", `Error while creating container ${params.collectionId}`);
|
handleError(error, "CreateCollection", `Error while creating container ${params.collectionId}`);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import { isFabric } from "Platform/Fabric/FabricUtil";
|
import { isFabric } from "Platform/Fabric/FabricUtil";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
@ -19,6 +21,11 @@ export async function deleteCollection(databaseId: string, collectionId: string)
|
|||||||
await client().database(databaseId).container(collectionId).delete();
|
await client().database(databaseId).container(collectionId).delete();
|
||||||
}
|
}
|
||||||
logConsoleInfo(`Successfully deleted container ${collectionId}`);
|
logConsoleInfo(`Successfully deleted container ${collectionId}`);
|
||||||
|
|
||||||
|
sendMessage({
|
||||||
|
type: FabricMessageTypes.ContainerUpdated,
|
||||||
|
params: { updateType: "deleted" },
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "DeleteCollection", `Error while deleting container ${collectionId}`);
|
handleError(error, "DeleteCollection", `Error while deleting container ${collectionId}`);
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { FabricMessageTypes } from "./FabricMessageTypes";
|
import { FabricMessageTypes } from "./FabricMessageTypes";
|
||||||
|
import { MessageTypes } from "./MessageTypes";
|
||||||
|
|
||||||
// This is the current version of these messages
|
// This is the current version of these messages
|
||||||
export const DATA_EXPLORER_RPC_VERSION = "3";
|
export const DATA_EXPLORER_RPC_VERSION = "3";
|
||||||
@ -19,9 +20,32 @@ export type DataExploreMessageV3 =
|
|||||||
type: FabricMessageTypes.GetAllResourceTokens;
|
type: FabricMessageTypes.GetAllResourceTokens;
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: FabricMessageTypes.GetAccessToken;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: MessageTypes.TelemetryInfo;
|
||||||
|
data: {
|
||||||
|
action: string;
|
||||||
|
actionModifier: string;
|
||||||
|
data: unknown;
|
||||||
|
timestamp: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
type: FabricMessageTypes.OpenSettings;
|
type: FabricMessageTypes.OpenSettings;
|
||||||
settingsId: string;
|
params: [{ settingsId?: "About" | "Connection" }];
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: FabricMessageTypes.RestoreContainer;
|
||||||
|
params: [];
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: FabricMessageTypes.ContainerUpdated;
|
||||||
|
params: {
|
||||||
|
updateType: "created" | "deleted" | "settings";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export interface GetCosmosTokenMessageOptions {
|
export interface GetCosmosTokenMessageOptions {
|
||||||
verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
||||||
|
@ -7,6 +7,8 @@ export enum FabricMessageTypes {
|
|||||||
GetAccessToken = "GetAccessToken",
|
GetAccessToken = "GetAccessToken",
|
||||||
Ready = "Ready",
|
Ready = "Ready",
|
||||||
OpenSettings = "OpenSettings",
|
OpenSettings = "OpenSettings",
|
||||||
|
RestoreContainer = "RestoreContainer",
|
||||||
|
ContainerUpdated = "ContainerUpdated",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthorizationToken {
|
export interface AuthorizationToken {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { IPivotItemProps, IPivotProps, Pivot, PivotItem } from "@fluentui/react";
|
import { IPivotItemProps, IPivotProps, Pivot, PivotItem } from "@fluentui/react";
|
||||||
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import {
|
import {
|
||||||
ComputedPropertiesComponent,
|
ComputedPropertiesComponent,
|
||||||
ComputedPropertiesComponentProps,
|
ComputedPropertiesComponentProps,
|
||||||
@ -431,6 +433,15 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
this.props.settingsTab.isExecuting(false);
|
this.props.settingsTab.isExecuting(false);
|
||||||
|
|
||||||
|
// Send message to Fabric no matter success or failure.
|
||||||
|
// In case of failure, saveCollectionSettings might have partially succeeded and Fabric needs to refresh
|
||||||
|
if (isFabricNative() && this.isCollectionSettingsTab) {
|
||||||
|
sendMessage({
|
||||||
|
type: FabricMessageTypes.ContainerUpdated,
|
||||||
|
params: { updateType: "settings" },
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user