Added className to SelfServeBaseClass (#627)
* Added className to SelfServeBaseClass * addressed PR comments * addressed PR comments * fixed lint errors
This commit is contained in:
parent
4f22d308b3
commit
d2423f28dc
|
@ -41,13 +41,15 @@ const getDescriptor = async (selfServeType: SelfServeType): Promise<SelfServeDes
|
|||
switch (selfServeType) {
|
||||
case SelfServeType.example: {
|
||||
const SelfServeExample = await import(/* webpackChunkName: "SelfServeExample" */ "./Example/SelfServeExample");
|
||||
await loadTranslations("SelfServeExample");
|
||||
return new SelfServeExample.default().toSelfServeDescriptor();
|
||||
const selfServeExample = new SelfServeExample.default();
|
||||
await loadTranslations(selfServeExample.constructor.name);
|
||||
return selfServeExample.toSelfServeDescriptor();
|
||||
}
|
||||
case SelfServeType.sqlx: {
|
||||
const SqlX = await import(/* webpackChunkName: "SqlX" */ "./SqlX/SqlX");
|
||||
await loadTranslations("SqlX");
|
||||
return new SqlX.default().toSelfServeDescriptor();
|
||||
const sqlX = new SqlX.default();
|
||||
await loadTranslations(sqlX.constructor.name);
|
||||
return sqlX.toSelfServeDescriptor();
|
||||
}
|
||||
default:
|
||||
return undefined;
|
||||
|
|
|
@ -89,6 +89,8 @@ export abstract class SelfServeBaseClass {
|
|||
selfServeDescriptor.initialize = this.initialize;
|
||||
selfServeDescriptor.onSave = this.onSave;
|
||||
selfServeDescriptor.onRefresh = this.onRefresh;
|
||||
selfServeDescriptor.root.id = className;
|
||||
|
||||
return selfServeDescriptor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,6 @@ describe("SelfServeUtils", () => {
|
|||
]);
|
||||
const expectedDescriptor = {
|
||||
root: {
|
||||
id: "TestClass",
|
||||
children: [
|
||||
{
|
||||
id: "dbThroughput",
|
||||
|
@ -270,7 +269,7 @@ describe("SelfServeUtils", () => {
|
|||
"invalidRegions",
|
||||
],
|
||||
};
|
||||
const descriptor = mapToSmartUiDescriptor("TestClass", context);
|
||||
const descriptor = mapToSmartUiDescriptor(context);
|
||||
expect(descriptor).toEqual(expectedDescriptor);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -112,21 +112,18 @@ export const updateContextWithDecorator = <T extends keyof DecoratorProperties,
|
|||
|
||||
export const buildSmartUiDescriptor = (className: string, target: unknown): void => {
|
||||
const context = Reflect.getMetadata(className, target) as Map<string, DecoratorProperties>;
|
||||
const smartUiDescriptor = mapToSmartUiDescriptor(className, context);
|
||||
const smartUiDescriptor = mapToSmartUiDescriptor(context);
|
||||
Reflect.defineMetadata(className, smartUiDescriptor, target);
|
||||
};
|
||||
|
||||
export const mapToSmartUiDescriptor = (
|
||||
className: string,
|
||||
context: Map<string, DecoratorProperties>
|
||||
): SelfServeDescriptor => {
|
||||
export const mapToSmartUiDescriptor = (context: Map<string, DecoratorProperties>): SelfServeDescriptor => {
|
||||
const inputNames: string[] = [];
|
||||
const root = context.get("root");
|
||||
context.delete("root");
|
||||
|
||||
const smartUiDescriptor: SelfServeDescriptor = {
|
||||
root: {
|
||||
id: className,
|
||||
id: undefined,
|
||||
info: undefined,
|
||||
children: [],
|
||||
},
|
||||
|
|
|
@ -177,7 +177,7 @@ export default class SqlX extends SelfServeBaseClass {
|
|||
currentValues: Map<string, SmartUiInput>,
|
||||
baselineValues: Map<string, SmartUiInput>
|
||||
): Promise<OnSaveResult> => {
|
||||
selfServeTrace({ selfServeClassName: "SqlX" });
|
||||
selfServeTrace({ selfServeClassName: this.constructor.name });
|
||||
|
||||
const dedicatedGatewayCurrentlyEnabled = currentValues.get("enableDedicatedGateway")?.value as boolean;
|
||||
const dedicatedGatewayOriginallyEnabled = baselineValues.get("enableDedicatedGateway")?.value as boolean;
|
||||
|
|
Loading…
Reference in New Issue