mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-22 18:32:00 +00:00
Prettier 2.0 (#393)
This commit is contained in:
@@ -2,13 +2,13 @@ import { Info } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||
import { addPropertyToMap, buildSmartUiDescriptor } from "./SelfServeUtils";
|
||||
|
||||
export const IsDisplayable = (): ClassDecorator => {
|
||||
return target => {
|
||||
return (target) => {
|
||||
buildSmartUiDescriptor(target.name, target.prototype);
|
||||
};
|
||||
};
|
||||
|
||||
export const ClassInfo = (info: (() => Promise<Info>) | Info): ClassDecorator => {
|
||||
return target => {
|
||||
return (target) => {
|
||||
addPropertyToMap(target.prototype, "root", target.name, "info", info);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -7,21 +7,21 @@ import { SessionStorageUtility } from "../../Shared/StorageUtility";
|
||||
export enum Regions {
|
||||
NorthCentralUS = "NCUS",
|
||||
WestUS = "WUS",
|
||||
EastUS2 = "EUS2"
|
||||
EastUS2 = "EUS2",
|
||||
}
|
||||
|
||||
export const regionDropdownItems: ChoiceItem[] = [
|
||||
{ label: "North Central US", key: Regions.NorthCentralUS },
|
||||
{ label: "West US", key: Regions.WestUS },
|
||||
{ label: "East US 2", key: Regions.EastUS2 }
|
||||
{ label: "East US 2", key: Regions.EastUS2 },
|
||||
];
|
||||
|
||||
export const selfServeExampleInfo: Info = {
|
||||
message: "This is a self serve class"
|
||||
message: "This is a self serve class",
|
||||
};
|
||||
|
||||
export const regionDropdownInfo: Info = {
|
||||
message: "More regions can be added in the future."
|
||||
message: "More regions can be added in the future.",
|
||||
};
|
||||
|
||||
const onDbThroughputChange = (currentState: Map<string, InputType>, newValue: InputType): Map<string, InputType> => {
|
||||
@@ -124,13 +124,13 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
||||
@Values({
|
||||
label: "Enable Logging",
|
||||
trueLabel: "Enable",
|
||||
falseLabel: "Disable"
|
||||
falseLabel: "Disable",
|
||||
})
|
||||
enableLogging: boolean;
|
||||
|
||||
@Values({
|
||||
label: "Account Name",
|
||||
placeholder: "Enter the account name"
|
||||
placeholder: "Enter the account name",
|
||||
})
|
||||
accountName: string;
|
||||
|
||||
@@ -152,7 +152,7 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
||||
min: 400,
|
||||
max: initializeMaxThroughput,
|
||||
step: 100,
|
||||
uiType: UiType.Slider
|
||||
uiType: UiType.Slider,
|
||||
})
|
||||
dbThroughput: number;
|
||||
|
||||
@@ -161,7 +161,7 @@ export default class SelfServeExample extends SelfServeBaseClass {
|
||||
min: 400,
|
||||
max: initializeMaxThroughput,
|
||||
step: 100,
|
||||
uiType: UiType.Spinner
|
||||
uiType: UiType.Spinner,
|
||||
})
|
||||
collectionThroughput: number;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ describe("SelfServeComponent", () => {
|
||||
const defaultValues = new Map<string, InputType>([
|
||||
["throughput", "450"],
|
||||
["analyticalStore", "false"],
|
||||
["database", "db2"]
|
||||
["database", "db2"],
|
||||
]);
|
||||
const initializeMock = jest.fn(async () => defaultValues);
|
||||
const onSubmitMock = jest.fn(async () => {
|
||||
@@ -24,8 +24,8 @@ describe("SelfServeComponent", () => {
|
||||
message: "Start at $24/mo per database",
|
||||
link: {
|
||||
href: "https://aka.ms/azure-cosmos-db-pricing",
|
||||
text: "More Details"
|
||||
}
|
||||
text: "More Details",
|
||||
},
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -38,16 +38,16 @@ describe("SelfServeComponent", () => {
|
||||
max: 500,
|
||||
step: 10,
|
||||
defaultValue: 400,
|
||||
uiType: UiType.Spinner
|
||||
}
|
||||
uiType: UiType.Spinner,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "containerId",
|
||||
input: {
|
||||
label: "Container id",
|
||||
dataFieldName: "containerId",
|
||||
type: "string"
|
||||
}
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "analyticalStore",
|
||||
@@ -57,8 +57,8 @@ describe("SelfServeComponent", () => {
|
||||
falseLabel: "Disabled",
|
||||
defaultValue: true,
|
||||
dataFieldName: "analyticalStore",
|
||||
type: "boolean"
|
||||
}
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "database",
|
||||
@@ -69,13 +69,13 @@ describe("SelfServeComponent", () => {
|
||||
choices: [
|
||||
{ label: "Database 1", key: "db1" },
|
||||
{ label: "Database 2", key: "db2" },
|
||||
{ label: "Database 3", key: "db3" }
|
||||
{ label: "Database 3", key: "db3" },
|
||||
],
|
||||
defaultKey: "db2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
defaultKey: "db2",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const verifyDefaultsSet = (currentValues: Map<string, InputType>): void => {
|
||||
@@ -88,7 +88,7 @@ describe("SelfServeComponent", () => {
|
||||
|
||||
it("should render", async () => {
|
||||
const wrapper = shallow(<SelfServeComponent descriptor={exampleData} />);
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
// initialize() should be called and defaults should be set when component is mounted
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
SmartUiComponent,
|
||||
UiType,
|
||||
SmartUiDescriptor,
|
||||
Info
|
||||
Info,
|
||||
} from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||
|
||||
export interface BaseInput {
|
||||
@@ -80,7 +80,7 @@ export class SelfServeComponent extends React.Component<SelfServeComponentProps,
|
||||
root: this.props.descriptor,
|
||||
currentValues: new Map(),
|
||||
baselineValues: new Map(),
|
||||
isRefreshing: false
|
||||
isRefreshing: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
CommonInputTypes,
|
||||
mapToSmartUiDescriptor,
|
||||
SelfServeBaseClass,
|
||||
updateContextWithDecorator
|
||||
updateContextWithDecorator,
|
||||
} from "./SelfServeUtils";
|
||||
import { InputType, UiType } from "./../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||
|
||||
@@ -63,8 +63,8 @@ describe("SelfServeUtils", () => {
|
||||
min: 1,
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: UiType.Slider
|
||||
}
|
||||
uiType: UiType.Slider,
|
||||
},
|
||||
],
|
||||
[
|
||||
"collThroughput",
|
||||
@@ -76,8 +76,8 @@ describe("SelfServeUtils", () => {
|
||||
min: 1,
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: UiType.Spinner
|
||||
}
|
||||
uiType: UiType.Spinner,
|
||||
},
|
||||
],
|
||||
[
|
||||
"invalidThroughput",
|
||||
@@ -90,8 +90,8 @@ describe("SelfServeUtils", () => {
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: UiType.Spinner,
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input"
|
||||
}
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input",
|
||||
},
|
||||
],
|
||||
[
|
||||
"collName",
|
||||
@@ -100,8 +100,8 @@ describe("SelfServeUtils", () => {
|
||||
dataFieldName: "collName",
|
||||
type: "string",
|
||||
label: "Coll Name",
|
||||
placeholder: "placeholder text"
|
||||
}
|
||||
placeholder: "placeholder text",
|
||||
},
|
||||
],
|
||||
[
|
||||
"enableLogging",
|
||||
@@ -111,8 +111,8 @@ describe("SelfServeUtils", () => {
|
||||
type: "boolean",
|
||||
label: "Enable Logging",
|
||||
trueLabel: "Enable",
|
||||
falseLabel: "Disable"
|
||||
}
|
||||
falseLabel: "Disable",
|
||||
},
|
||||
],
|
||||
[
|
||||
"invalidEnableLogging",
|
||||
@@ -121,8 +121,8 @@ describe("SelfServeUtils", () => {
|
||||
dataFieldName: "invalidEnableLogging",
|
||||
type: "boolean",
|
||||
label: "Invalid Enable Logging",
|
||||
placeholder: "placeholder text"
|
||||
}
|
||||
placeholder: "placeholder text",
|
||||
},
|
||||
],
|
||||
[
|
||||
"regions",
|
||||
@@ -134,9 +134,9 @@ describe("SelfServeUtils", () => {
|
||||
choices: [
|
||||
{ label: "South West US", key: "SWUS" },
|
||||
{ label: "North Central US", key: "NCUS" },
|
||||
{ label: "East US 2", key: "EUS2" }
|
||||
]
|
||||
}
|
||||
{ label: "East US 2", key: "EUS2" },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
"invalidRegions",
|
||||
@@ -145,9 +145,9 @@ describe("SelfServeUtils", () => {
|
||||
dataFieldName: "invalidRegions",
|
||||
type: "object",
|
||||
label: "Invalid Regions",
|
||||
placeholder: "placeholder text"
|
||||
}
|
||||
]
|
||||
placeholder: "placeholder text",
|
||||
},
|
||||
],
|
||||
]);
|
||||
const expectedDescriptor = {
|
||||
root: {
|
||||
@@ -163,9 +163,9 @@ describe("SelfServeUtils", () => {
|
||||
min: 1,
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: "Slider"
|
||||
uiType: "Slider",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "collThroughput",
|
||||
@@ -177,9 +177,9 @@ describe("SelfServeUtils", () => {
|
||||
min: 1,
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: "Spinner"
|
||||
uiType: "Spinner",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "invalidThroughput",
|
||||
@@ -192,9 +192,9 @@ describe("SelfServeUtils", () => {
|
||||
max: 5,
|
||||
step: 1,
|
||||
uiType: "Spinner",
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidThroughput'."
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidThroughput'.",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "collName",
|
||||
@@ -203,9 +203,9 @@ describe("SelfServeUtils", () => {
|
||||
dataFieldName: "collName",
|
||||
type: "string",
|
||||
label: "Coll Name",
|
||||
placeholder: "placeholder text"
|
||||
placeholder: "placeholder text",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "enableLogging",
|
||||
@@ -215,9 +215,9 @@ describe("SelfServeUtils", () => {
|
||||
type: "boolean",
|
||||
label: "Enable Logging",
|
||||
trueLabel: "Enable",
|
||||
falseLabel: "Disable"
|
||||
falseLabel: "Disable",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "invalidEnableLogging",
|
||||
@@ -227,9 +227,9 @@ describe("SelfServeUtils", () => {
|
||||
type: "boolean",
|
||||
label: "Invalid Enable Logging",
|
||||
placeholder: "placeholder text",
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidEnableLogging'."
|
||||
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidEnableLogging'.",
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "regions",
|
||||
@@ -241,10 +241,10 @@ describe("SelfServeUtils", () => {
|
||||
choices: [
|
||||
{ label: "South West US", key: "SWUS" },
|
||||
{ label: "North Central US", key: "NCUS" },
|
||||
{ label: "East US 2", key: "EUS2" }
|
||||
]
|
||||
{ label: "East US 2", key: "EUS2" },
|
||||
],
|
||||
},
|
||||
children: [] as Node[]
|
||||
children: [] as Node[],
|
||||
},
|
||||
{
|
||||
id: "invalidRegions",
|
||||
@@ -254,11 +254,11 @@ describe("SelfServeUtils", () => {
|
||||
type: "object",
|
||||
label: "Invalid Regions",
|
||||
placeholder: "placeholder text",
|
||||
errorMessage: "label and choices are required for Choice input 'invalidRegions'."
|
||||
errorMessage: "label and choices are required for Choice input 'invalidRegions'.",
|
||||
},
|
||||
children: [] as Node[]
|
||||
}
|
||||
]
|
||||
children: [] as Node[],
|
||||
},
|
||||
],
|
||||
},
|
||||
inputNames: [
|
||||
"dbThroughput",
|
||||
@@ -268,8 +268,8 @@ describe("SelfServeUtils", () => {
|
||||
"enableLogging",
|
||||
"invalidEnableLogging",
|
||||
"regions",
|
||||
"invalidRegions"
|
||||
]
|
||||
"invalidRegions",
|
||||
],
|
||||
};
|
||||
const descriptor = mapToSmartUiDescriptor(context);
|
||||
expect(descriptor).toEqual(expectedDescriptor);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
NumberInput,
|
||||
StringInput,
|
||||
Node,
|
||||
AnyInput
|
||||
AnyInput,
|
||||
} from "./SelfServeComponent";
|
||||
|
||||
export enum SelfServeType {
|
||||
@@ -16,7 +16,7 @@ export enum SelfServeType {
|
||||
// Unsupported self serve type passed as feature flag
|
||||
invalid = "invalid",
|
||||
// Add your self serve types here
|
||||
example = "example"
|
||||
example = "example",
|
||||
}
|
||||
|
||||
export abstract class SelfServeBaseClass {
|
||||
@@ -126,8 +126,8 @@ export const mapToSmartUiDescriptor = (context: Map<string, CommonInputTypes>):
|
||||
root: {
|
||||
id: "root",
|
||||
info: root?.info,
|
||||
children: []
|
||||
}
|
||||
children: [],
|
||||
},
|
||||
};
|
||||
|
||||
while (context.size > 0) {
|
||||
@@ -151,7 +151,7 @@ const addToDescriptor = (
|
||||
id: value.id,
|
||||
info: value.info,
|
||||
input: getInput(value),
|
||||
children: []
|
||||
children: [],
|
||||
} as Node;
|
||||
context.delete(key);
|
||||
root.children.push(element);
|
||||
|
||||
Reference in New Issue
Block a user