mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-14 17:27:30 +01:00
Added more Self Serve functionalities (#401)
* added recursion and inition decorators * working version * added todo comment and removed console.log * Added Recursive add * removed type requirement * proper resolution of promises * added custom element and base class * Made selfServe standalone page * Added custom renderer as async type * Added overall defaults * added inital open from data explorer * removed landingpage * added feature for self serve type * renamed sqlx->example and added invalid type * Added comments for Example * removed unnecessary changes * Resolved PR comments Added tests Moved onSubmt and initialize inside base class Moved testExplorer to separate folder made fields of SelfServe Class non static * fixed lint errors * fixed compilation errors * Removed reactbinding changes * renamed dropdown -> choice * Added SelfServeComponent * Addressed PR comments * added toggle, visibility, text display,commandbar * added sqlx example * added onRefrssh * formatting changes * rmoved radioswitch display * updated smartui tests * Added more tests * onSubmit -> onSave * Resolved PR comments
This commit is contained in:
committed by
GitHub
parent
b0b973b21a
commit
49bf8c60db
@@ -0,0 +1,33 @@
|
||||
import { RefreshResult } from "../SelfServeTypes";
|
||||
|
||||
export interface DedicatedGatewayResponse {
|
||||
sku: string;
|
||||
instances: number;
|
||||
}
|
||||
|
||||
export const getRegionSpecificMinInstances = async (): Promise<number> => {
|
||||
// TODO: write RP call to get min number of instances needed for this region
|
||||
throw new Error("getRegionSpecificMinInstances not implemented");
|
||||
};
|
||||
|
||||
export const getRegionSpecificMaxInstances = async (): Promise<number> => {
|
||||
// TODO: write RP call to get max number of instances needed for this region
|
||||
throw new Error("getRegionSpecificMaxInstances not implemented");
|
||||
};
|
||||
|
||||
export const updateDedicatedGatewayProvisioning = async (sku: string, instances: number): Promise<void> => {
|
||||
// TODO: write RP call to update dedicated gateway provisioning
|
||||
throw new Error(
|
||||
`updateDedicatedGatewayProvisioning not implemented. Parameters- sku: ${sku}, instances:${instances}`
|
||||
);
|
||||
};
|
||||
|
||||
export const initializeDedicatedGatewayProvisioning = async (): Promise<DedicatedGatewayResponse> => {
|
||||
// TODO: write RP call to initialize UI for dedicated gateway provisioning
|
||||
throw new Error("initializeDedicatedGatewayProvisioning not implemented");
|
||||
};
|
||||
|
||||
export const refreshDedicatedGatewayProvisioning = async (): Promise<RefreshResult> => {
|
||||
// TODO: write RP call to check if dedicated gateway update has gone through
|
||||
throw new Error("refreshDedicatedGatewayProvisioning not implemented");
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
import { IsDisplayable, OnChange, Values } from "../Decorators";
|
||||
import {
|
||||
ChoiceItem,
|
||||
InputType,
|
||||
NumberUiType,
|
||||
RefreshResult,
|
||||
SelfServeBaseClass,
|
||||
SelfServeNotification,
|
||||
SmartUiInput,
|
||||
} from "../SelfServeTypes";
|
||||
import { refreshDedicatedGatewayProvisioning } from "./SqlX.rp";
|
||||
|
||||
const onEnableDedicatedGatewayChange = (
|
||||
currentState: Map<string, SmartUiInput>,
|
||||
newValue: InputType
|
||||
): 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<SelfServeNotification> => {
|
||||
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: {
|
||||
text: "Provisioning dedicated gateways for SqlX accounts.",
|
||||
link: {
|
||||
href: "https://docs.microsoft.com/en-us/azure/cosmos-db/introduction",
|
||||
text: "Learn more about dedicated gateway.",
|
||||
},
|
||||
},
|
||||
})
|
||||
description: string;
|
||||
|
||||
@OnChange(onEnableDedicatedGatewayChange)
|
||||
@Values({
|
||||
label: "Dedicated Gateway",
|
||||
trueLabel: "Enable",
|
||||
falseLabel: "Disable",
|
||||
})
|
||||
enableDedicatedGateway: boolean;
|
||||
|
||||
@Values({
|
||||
label: "SKUs",
|
||||
choices: getSkus,
|
||||
placeholder: "Select SKUs",
|
||||
})
|
||||
sku: ChoiceItem;
|
||||
|
||||
@Values({
|
||||
label: "Number of instances",
|
||||
min: getInstancesMin,
|
||||
max: getInstancesMax,
|
||||
step: 1,
|
||||
uiType: NumberUiType.Spinner,
|
||||
})
|
||||
instances: number;
|
||||
}
|
||||
Reference in New Issue
Block a user