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