Addressed PR comments

This commit is contained in:
Srinath Narayanan
2021-01-18 16:21:31 -08:00
parent d17508cc27
commit 385c9f216f
5 changed files with 12 additions and 26 deletions

View File

@@ -24,11 +24,6 @@ export const regionDropdownInfo: Info = {
message: "More regions can be added in the future."
};
export const delay = (ms: number): Promise<void> => {
console.log("delay called");
return new Promise(resolve => setTimeout(resolve, ms));
};
const onDbThroughputChange = (currentState: Map<string, InputType>, newValue: InputType): Map<string, InputType> => {
currentState.set("dbThroughput", newValue);
currentState.set("collectionThroughput", newValue);
@@ -36,7 +31,6 @@ const onDbThroughputChange = (currentState: Map<string, InputType>, newValue: In
};
const initializeMaxThroughput = async (): Promise<number> => {
await delay(2000);
return 10000;
};
@@ -76,7 +70,6 @@ export default class SelfServeExample extends SelfServeBaseClass {
in the SessionStorage.
*/
public onSubmit = async (currentValues: Map<string, InputType>): Promise<void> => {
await delay(1000);
SessionStorageUtility.setEntry("regions", currentValues.get("regions")?.toString());
SessionStorageUtility.setEntry("enableLogging", currentValues.get("enableLogging")?.toString());
SessionStorageUtility.setEntry("accountName", currentValues.get("accountName")?.toString());
@@ -100,7 +93,6 @@ export default class SelfServeExample extends SelfServeBaseClass {
for these fields. These are then set when the changes are submitted.
*/
public initialize = async (): Promise<Map<string, InputType>> => {
await delay(1000);
const defaults = new Map<string, InputType>();
defaults.set("regions", SessionStorageUtility.getEntry("regions"));
defaults.set("enableLogging", SessionStorageUtility.getEntry("enableLogging") === "true");

View File

@@ -33,17 +33,17 @@ export interface ChoiceInputOptions extends InputOptionsBase {
type InputOptions = NumberInputOptions | StringInputOptions | BooleanInputOptions | ChoiceInputOptions;
function isNumberInputOptions(inputOptions: InputOptions): inputOptions is NumberInputOptions {
const isNumberInputOptions = (inputOptions: InputOptions): inputOptions is NumberInputOptions => {
return "min" in inputOptions;
}
};
function isBooleanInputOptions(inputOptions: InputOptions): inputOptions is BooleanInputOptions {
const isBooleanInputOptions = (inputOptions: InputOptions): inputOptions is BooleanInputOptions => {
return "trueLabel" in inputOptions;
}
};
function isChoiceInputOptions(inputOptions: InputOptions): inputOptions is ChoiceInputOptions {
const isChoiceInputOptions = (inputOptions: InputOptions): inputOptions is ChoiceInputOptions => {
return "choices" in inputOptions;
}
};
const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
return (target, property) => {

View File

@@ -105,17 +105,16 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
currentValues = currentValues.set(key, initialValues.get(key));
baselineValues = baselineValues.set(key, initialValues.get(key));
}
this.setState({ currentValues: currentValues, baselineValues: baselineValues, isRefreshing: false });
this.setState({ currentValues, baselineValues, isRefreshing: false });
};
public discard = (): void => {
console.log("discarding");
let { currentValues } = this.state;
const { baselineValues } = this.state;
for (const key of baselineValues.keys()) {
currentValues = currentValues.set(key, baselineValues.get(key));
}
this.setState({ currentValues: currentValues });
this.setState({ currentValues });
};
private initializeSmartUiNode = async (currentNode: Node): Promise<void> => {

View File

@@ -20,6 +20,6 @@ export class SelfServeLoadingComponentAdapter implements ReactAdapter {
}
private triggerRender() {
window.requestAnimationFrame(() => this.parameters(Date.now()));
window.requestAnimationFrame(() => this.renderComponent());
}
}

View File

@@ -82,10 +82,8 @@ export const addPropertyToMap = <T extends keyof CommonInputTypes, K extends Com
descriptorName: string,
descriptorValue: K
): void => {
let context = Reflect.getMetadata(className, target) as Map<string, CommonInputTypes>;
if (!context) {
context = new Map<string, CommonInputTypes>();
}
const context =
(Reflect.getMetadata(className, target) as Map<string, CommonInputTypes>) ?? new Map<string, CommonInputTypes>();
updateContextWithDecorator(context, propertyName, className, descriptorName, descriptorValue);
Reflect.defineMetadata(className, context, target);
};
@@ -104,10 +102,7 @@ export const updateContextWithDecorator = <T extends keyof CommonInputTypes, K e
throw new Error(`@SmartUi should be the first decorator for the class '${className}'.`);
}
let propertyObject = context.get(propertyName);
if (!propertyObject) {
propertyObject = { id: propertyName };
}
const propertyObject = context.get(propertyName) ?? { id: propertyName };
if (getValue(descriptorKey, propertyObject) && descriptorKey !== "type" && descriptorKey !== "dataFieldName") {
throw new Error(