mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-10 13:08:20 +00:00
Added more selfserve changes (#443)
* exposed baselineValues * added getOnSaveNotification * disable UI when onSave is taking place * added optional polling * Added portal notifications * minor edits * added label for description * Added correlationids and polling of refresh * added label tooltip * removed ClassInfo decorator * Added dynamic decription * added info and warninf types for description * promise retry changes * compile errors fixed * merged sqlxEdits * undid sqlx changes * added completed notification * passed retryInterval in notif options * added polling on landing on the page * edits for error display * added link generation * addressed PR comments * modified test * fixed compilation error
This commit is contained in:
committed by
GitHub
parent
c1b74266eb
commit
ecdc41ada9
@@ -1,4 +1,3 @@
|
||||
import { MessageBarType } from "office-ui-fabric-react";
|
||||
import "reflect-metadata";
|
||||
import {
|
||||
Node,
|
||||
@@ -15,8 +14,9 @@ import {
|
||||
SelfServeDescriptor,
|
||||
SmartUiInput,
|
||||
StringInput,
|
||||
SelfServeNotificationType,
|
||||
RefreshParams,
|
||||
} from "./SelfServeTypes";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export enum SelfServeType {
|
||||
// No self serve type passed, launch explorer
|
||||
@@ -28,6 +28,14 @@ export enum SelfServeType {
|
||||
sqlx = "sqlx",
|
||||
}
|
||||
|
||||
export enum BladeType {
|
||||
SqlKeys = "keys",
|
||||
MongoKeys = "mongoDbKeys",
|
||||
CassandraKeys = "cassandraDbKeys",
|
||||
GremlinKeys = "keys",
|
||||
TableKeys = "tableKeys",
|
||||
}
|
||||
|
||||
export interface DecoratorProperties {
|
||||
id: string;
|
||||
info?: (() => Promise<Info>) | Info;
|
||||
@@ -44,9 +52,13 @@ export interface DecoratorProperties {
|
||||
uiType?: string;
|
||||
errorMessage?: string;
|
||||
description?: (() => Promise<Description>) | Description;
|
||||
onChange?: (currentState: Map<string, SmartUiInput>, newValue: InputType) => Map<string, SmartUiInput>;
|
||||
onSave?: (currentValues: Map<string, SmartUiInput>) => Promise<void>;
|
||||
initialize?: () => Promise<Map<string, SmartUiInput>>;
|
||||
isDynamicDescription?: boolean;
|
||||
refreshParams?: RefreshParams;
|
||||
onChange?: (
|
||||
newValue: InputType,
|
||||
currentState: Map<string, SmartUiInput>,
|
||||
baselineValues: ReadonlyMap<string, SmartUiInput>
|
||||
) => Map<string, SmartUiInput>;
|
||||
}
|
||||
|
||||
const setValue = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
||||
@@ -83,7 +95,7 @@ export const updateContextWithDecorator = <T extends keyof DecoratorProperties,
|
||||
descriptorValue: K
|
||||
): void => {
|
||||
if (!(context instanceof Map)) {
|
||||
throw new Error(`@SmartUi should be the first decorator for the class '${className}'.`);
|
||||
throw new Error(`@IsDisplayable should be the first decorator for the class '${className}'.`);
|
||||
}
|
||||
|
||||
const propertyObject = context.get(propertyName) ?? { id: propertyName };
|
||||
@@ -108,16 +120,17 @@ export const mapToSmartUiDescriptor = (
|
||||
className: string,
|
||||
context: Map<string, DecoratorProperties>
|
||||
): SelfServeDescriptor => {
|
||||
const inputNames: string[] = [];
|
||||
const root = context.get("root");
|
||||
context.delete("root");
|
||||
const inputNames: string[] = [];
|
||||
|
||||
const smartUiDescriptor: SelfServeDescriptor = {
|
||||
root: {
|
||||
id: className,
|
||||
info: root?.info,
|
||||
info: undefined,
|
||||
children: [],
|
||||
},
|
||||
refreshParams: root?.refreshParams,
|
||||
};
|
||||
|
||||
while (context.size > 0) {
|
||||
@@ -155,7 +168,10 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
|
||||
}
|
||||
return value as NumberInput;
|
||||
case "string":
|
||||
if (value.description) {
|
||||
if (value.description || value.isDynamicDescription) {
|
||||
if (value.description && value.isDynamicDescription) {
|
||||
value.errorMessage = `dynamic descriptions should not have defaults set here.`;
|
||||
}
|
||||
return value as DescriptionDisplay;
|
||||
}
|
||||
if (!value.labelTKey) {
|
||||
@@ -175,13 +191,9 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getMessageBarType = (type: SelfServeNotificationType): MessageBarType => {
|
||||
switch (type) {
|
||||
case SelfServeNotificationType.info:
|
||||
return MessageBarType.info;
|
||||
case SelfServeNotificationType.warning:
|
||||
return MessageBarType.warning;
|
||||
case SelfServeNotificationType.error:
|
||||
return MessageBarType.error;
|
||||
}
|
||||
export const generateBladeLink = (blade: BladeType): string => {
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroupName = userContext.resourceGroup;
|
||||
const databaseAccountName = userContext.databaseAccount.name;
|
||||
return `www.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDb/databaseAccounts/${databaseAccountName}/${blade}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user