mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-07 11:36:47 +00:00
* 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
100 lines
3.2 KiB
TypeScript
100 lines
3.2 KiB
TypeScript
import { IsDisplayable, OnChange, Values } from "../Decorators";
|
|
import {
|
|
ChoiceItem,
|
|
DescriptionType,
|
|
InputType,
|
|
NumberUiType,
|
|
OnSaveResult,
|
|
RefreshResult,
|
|
SelfServeBaseClass,
|
|
SmartUiInput,
|
|
} from "../SelfServeTypes";
|
|
import { refreshDedicatedGatewayProvisioning } from "./SqlX.rp";
|
|
|
|
const onEnableDedicatedGatewayChange = (
|
|
newValue: InputType,
|
|
currentState: Map<string, SmartUiInput>
|
|
): Map<string, SmartUiInput> => {
|
|
const sku = currentState.get("sku");
|
|
const instances = currentState.get("instances");
|
|
const isSkuHidden = newValue === undefined || !(newValue as boolean);
|
|
currentState.set("enableDedicatedGateway", { value: newValue });
|
|
currentState.set("sku", { value: sku.value, hidden: isSkuHidden });
|
|
currentState.set("instances", { value: instances.value, hidden: isSkuHidden });
|
|
return currentState;
|
|
};
|
|
|
|
const getSkus = async (): Promise<ChoiceItem[]> => {
|
|
// TODO: get SKUs from getRegionSpecificSkus() RP call and return array of {label:..., key:...}.
|
|
throw new Error("getSkus not implemented.");
|
|
};
|
|
|
|
const getInstancesMin = async (): Promise<number> => {
|
|
// TODO: get SKUs from getRegionSpecificSkus() RP call and return array of {label:..., key:...}.
|
|
throw new Error("getInstancesMin not implemented.");
|
|
};
|
|
|
|
const getInstancesMax = async (): Promise<number> => {
|
|
// TODO: get SKUs from getRegionSpecificSkus() RP call and return array of {label:..., key:...}.
|
|
throw new Error("getInstancesMax not implemented.");
|
|
};
|
|
|
|
const validate = (currentValues: Map<string, SmartUiInput>): void => {
|
|
// TODO: add cusom validation logic to be called before Saving the data.
|
|
throw new Error(`validate not implemented. No. of properties to validate: ${currentValues.size}`);
|
|
};
|
|
|
|
@IsDisplayable()
|
|
export default class SqlX extends SelfServeBaseClass {
|
|
public onRefresh = async (): Promise<RefreshResult> => {
|
|
return refreshDedicatedGatewayProvisioning();
|
|
};
|
|
|
|
public onSave = async (currentValues: Map<string, SmartUiInput>): Promise<OnSaveResult> => {
|
|
validate(currentValues);
|
|
// TODO: add pre processing logic before calling the updateDedicatedGatewayProvisioning() RP call.
|
|
throw new Error(`onSave not implemented. No. of properties to save: ${currentValues.size}`);
|
|
};
|
|
|
|
public initialize = async (): Promise<Map<string, SmartUiInput>> => {
|
|
// TODO: get initialization data from initializeDedicatedGatewayProvisioning() RP call.
|
|
throw new Error("onSave not implemented");
|
|
};
|
|
|
|
@Values({
|
|
description: {
|
|
textTKey: "Provisioning dedicated gateways for SqlX accounts.",
|
|
type: DescriptionType.Text,
|
|
link: {
|
|
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
|
textTKey: "Learn more about dedicated gateway.",
|
|
},
|
|
},
|
|
})
|
|
description: string;
|
|
|
|
@OnChange(onEnableDedicatedGatewayChange)
|
|
@Values({
|
|
labelTKey: "Dedicated Gateway",
|
|
trueLabelTKey: "Enable",
|
|
falseLabelTKey: "Disable",
|
|
})
|
|
enableDedicatedGateway: boolean;
|
|
|
|
@Values({
|
|
labelTKey: "SKUs",
|
|
choices: getSkus,
|
|
placeholderTKey: "Select SKUs",
|
|
})
|
|
sku: ChoiceItem;
|
|
|
|
@Values({
|
|
labelTKey: "Number of instances",
|
|
min: getInstancesMin,
|
|
max: getInstancesMax,
|
|
step: 1,
|
|
uiType: NumberUiType.Spinner,
|
|
})
|
|
instances: number;
|
|
}
|