address comment

This commit is contained in:
hardiknai-techm
2021-05-10 21:56:23 +05:30
parent a675124bdc
commit c50543c341
11 changed files with 209 additions and 33623 deletions

31048
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,15 @@
import { IconButton, TooltipHost } from "@fluentui/react"; import { Icon, TooltipHost } from "@fluentui/react";
import * as React from "react"; import * as React from "react";
export interface TooltipProps { export interface TooltipProps {
children: string; children: string;
} }
const iconProps = { iconName: "Info" };
export const InfoTooltip: React.FunctionComponent = ({ children }: TooltipProps) => { export const InfoTooltip: React.FunctionComponent = ({ children }: TooltipProps) => {
return ( return (
<span> <span>
<TooltipHost content={children}> <TooltipHost content={children}>
<IconButton iconProps={iconProps} ariaLabel="Info" vertical-align /> <Icon iconName="Info" ariaLabel="Info" className="panelInfoIcon" />
</TooltipHost> </TooltipHost>
</span> </span>
); );

View File

@@ -22,15 +22,15 @@ describe("ThroughputInput Pane", () => {
it("test Autoscale Mode select", () => { it("test Autoscale Mode select", () => {
wrapper.setProps({ isAutoscaleSelected: true }); wrapper.setProps({ isAutoscaleSelected: true });
expect(wrapper.find('[data-testid="ruDescription"]').at(0).text()).toBe( expect(wrapper.find('[aria-label="ruDescription"]').at(0).text()).toBe(
"Estimate your required RU/s with capacity calculator." "Estimate your required RU/s with capacity calculator."
); );
expect(wrapper.find('[data-testid="maxRUDescription"]').at(0).text()).toContain("Max RU/s"); expect(wrapper.find('[aria-label="maxRUDescription"]').at(0).text()).toContain("Max RU/s");
}); });
it("test Manual Mode select", () => { it("test Manual Mode select", () => {
wrapper.setProps({ isAutoscaleSelected: false }); wrapper.setProps({ isAutoscaleSelected: false });
expect(wrapper.find('[data-testid="ruDescription"]').at(0).text()).toContain("Estimate your required RU/s with"); expect(wrapper.find('[aria-label="ruDescription"]').at(0).text()).toContain("Estimate your required RU/s with");
expect(wrapper.find('[data-testid="capacityLink"]').at(0).text()).toContain("capacity calculator"); expect(wrapper.find('[aria-label="capacityLink"]').at(0).text()).toContain("capacity calculator");
}); });
}); });

View File

@@ -1,14 +1,4 @@
import { import { Checkbox, DirectionalHint, Link, Stack, Text, TextField, TooltipHost } from "@fluentui/react";
Checkbox,
ChoiceGroup,
DirectionalHint,
IChoiceGroupOption,
Link,
Stack,
Text,
TextField,
TooltipHost,
} from "@fluentui/react";
import React, { FunctionComponent, useState } from "react"; import React, { FunctionComponent, useState } from "react";
import * as Constants from "../../../Common/Constants"; import * as Constants from "../../../Common/Constants";
import { InfoTooltip } from "../../../Common/Tooltip/InfoTooltip"; import { InfoTooltip } from "../../../Common/Tooltip/InfoTooltip";
@@ -90,8 +80,8 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
); );
}; };
const handleOnChangeMode = (ev: React.FormEvent<HTMLInputElement>, option: IChoiceGroupOption): void => { const handleOnChangeMode = (event: React.ChangeEvent<HTMLInputElement>, mode: string): void => {
if (option.key === "true") { if (mode === "Autoscale") {
setThroughputValue(AutoPilotUtils.minAutoPilotThroughput); setThroughputValue(AutoPilotUtils.minAutoPilotThroughput);
setIsAutoscale(true); setIsAutoscale(true);
} else { } else {
@@ -100,10 +90,6 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
} }
}; };
const optionList: IChoiceGroupOption[] = [
{ key: "true", text: "Autoscale" },
{ key: "false", text: "Manual" },
];
return ( return (
<div className="throughputInputContainer throughputInputSpacing"> <div className="throughputInputContainer throughputInputSpacing">
<Stack horizontal> <Stack horizontal>
@@ -115,26 +101,41 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
</Stack> </Stack>
<Stack horizontal verticalAlign="center"> <Stack horizontal verticalAlign="center">
<ChoiceGroup <input
selectedKey={"" + isAutoscaleSelected} className="throughputInputRadioBtn"
options={optionList} aria-label="Autoscale mode"
onChange={handleOnChangeMode} checked={isAutoscaleSelected}
aria-label="mode" type="radio"
role="radio"
tabIndex={0}
onChange={(e) => handleOnChangeMode(e, "Autoscale")}
/> />
<span className="throughputInputRadioBtnLabel">Autoscale</span>
<input
className="throughputInputRadioBtn"
aria-label="Manual mode"
checked={!isAutoscaleSelected}
type="radio"
role="radio"
tabIndex={0}
onChange={(e) => handleOnChangeMode(e, "Manual")}
/>
<span className="throughputInputRadioBtnLabel">Manual</span>
</Stack> </Stack>
{isAutoscaleSelected && ( {isAutoscaleSelected && (
<Stack className="throughputInputSpacing"> <Stack className="throughputInputSpacing">
<Text variant="small" data-testid="ruDescription"> <Text variant="small" aria-label="ruDescription">
Estimate your required RU/s with{" "} Estimate your required RU/s with{" "}
<Link target="_blank" href="https://cosmos.azure.com/capacitycalculator/" data-testid="ruDescription"> <Link target="_blank" href="https://cosmos.azure.com/capacitycalculator/" aria-label="ruDescription">
capacity calculator capacity calculator
</Link> </Link>
. .
</Text> </Text>
<Stack horizontal> <Stack horizontal>
<Text variant="small" style={{ lineHeight: "20px", fontWeight: 600 }} data-testid="maxRUDescription"> <Text variant="small" style={{ lineHeight: "20px", fontWeight: 600 }} aria-label="maxRUDescription">
{isDatabase ? "Database" : getCollectionName()} Max RU/s {isDatabase ? "Database" : getCollectionName()} Max RU/s
</Text> </Text>
<InfoTooltip>{getAutoScaleTooltip()}</InfoTooltip> <InfoTooltip>{getAutoScaleTooltip()}</InfoTooltip>
@@ -168,9 +169,9 @@ export const ThroughputInput: FunctionComponent<ThroughputInputProps> = ({
{!isAutoscaleSelected && ( {!isAutoscaleSelected && (
<Stack className="throughputInputSpacing"> <Stack className="throughputInputSpacing">
<Text variant="small" data-testid="ruDescription"> <Text variant="small" aria-label="ruDescription">
Estimate your required RU/s with&nbsp; Estimate your required RU/s with&nbsp;
<Link target="_blank" href="https://cosmos.azure.com/capacitycalculator/" data-testid="capacityLink"> <Link target="_blank" href="https://cosmos.azure.com/capacitycalculator/" aria-label="capacityLink">
capacity calculator capacity calculator
</Link> </Link>
. .

View File

@@ -134,7 +134,7 @@ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage); TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage);
}, []); }, []);
const submit = () => { const onSubmit = () => {
if (!_isValid()) { if (!_isValid()) {
return; return;
} }
@@ -249,17 +249,17 @@ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
[] []
); );
const genericPaneProps: RightPaneFormProps = { const props: RightPaneFormProps = {
expandConsole: container.expandConsole, expandConsole: container.expandConsole,
formError: formErrors, formError: formErrors,
formErrorDetail: formErrorsDetails, formErrorDetail: formErrorsDetails,
isExecuting, isExecuting,
submitButtonText: "OK", submitButtonText: "OK",
onSubmit: submit, onSubmit,
}; };
return ( return (
<RightPaneForm {...genericPaneProps}> <RightPaneForm {...props}>
<div className="paneContentContainer" role="dialog" aria-labelledby="databaseTitle"> <div className="paneContentContainer" role="dialog" aria-labelledby="databaseTitle">
{showUpsellMessage && formErrors === "" && ( {showUpsellMessage && formErrors === "" && (
<PanelInfoErrorComponent <PanelInfoErrorComponent

View File

@@ -9,12 +9,6 @@ export const PanelFooterComponent: React.FunctionComponent<PanelFooterProps> = (
buttonLabel, buttonLabel,
}: PanelFooterProps): JSX.Element => ( }: PanelFooterProps): JSX.Element => (
<div className="panelFooter"> <div className="panelFooter">
<PrimaryButton <PrimaryButton type="submit" id="sidePanelOkButton" text={buttonLabel} ariaLabel={buttonLabel} />
type="submit"
id="sidePanelOkButton"
text={buttonLabel}
ariaLabel={buttonLabel}
data-testid="submit"
/>
</div> </div>
); );

View File

@@ -15,7 +15,7 @@ const props = {
onSubmit, onSubmit,
}; };
describe("Load Query Pane", () => { describe("Right Pane Form", () => {
let wrapper: ReactWrapper; let wrapper: ReactWrapper;
it("should render Default properly", () => { it("should render Default properly", () => {
@@ -24,12 +24,12 @@ describe("Load Query Pane", () => {
}); });
it("should call submit method enter in form", () => { it("should call submit method enter in form", () => {
render(<RightPaneForm {...props} />); render(<RightPaneForm {...props} />);
fireEvent.click(screen.getByTestId("submit")); fireEvent.click(screen.getByLabelText("Load"));
expect(onSubmit).toHaveBeenCalled(); expect(onSubmit).toHaveBeenCalled();
}); });
it("should call submit method click on submit button", () => { it("should call submit method click on submit button", () => {
render(<RightPaneForm {...props} />); render(<RightPaneForm {...props} />);
fireEvent.click(screen.getByTestId("submit")); fireEvent.click(screen.getByLabelText("Load"));
expect(onSubmit).toHaveBeenCalled(); expect(onSubmit).toHaveBeenCalled();
}); });
it("should render error in header", () => { it("should render error in header", () => {

View File

@@ -1,30 +1,15 @@
<<<<<<< HEAD
import React, { FunctionComponent, ReactNode } from "react"; import React, { FunctionComponent, ReactNode } from "react";
import { PanelFooterComponent } from "../PanelFooterComponent"; import { PanelFooterComponent } from "../PanelFooterComponent";
import { PanelInfoErrorComponent, PanelInfoErrorProps } from "../PanelInfoErrorComponent"; import { PanelInfoErrorComponent, PanelInfoErrorProps } from "../PanelInfoErrorComponent";
import { PanelLoadingScreen } from "../PanelLoadingScreen"; import { PanelLoadingScreen } from "../PanelLoadingScreen";
=======
import { IconButton } from "@fluentui/react";
import React, { FunctionComponent, ReactNode } from "react";
import { KeyCodes } from "../../../Common/Constants";
>>>>>>> 487fbf207299bfd3b7d6404bf0307a8de29ac987
export interface RightPaneFormProps { export interface RightPaneFormProps {
expandConsole: () => void; expandConsole: () => void;
formError: string; formError: string;
formErrorDetail: string; formErrorDetail: string;
<<<<<<< HEAD
isExecuting: boolean; isExecuting: boolean;
onSubmit: () => void; onSubmit: () => void;
submitButtonText: string; submitButtonText: string;
=======
id: string;
isExecuting: boolean;
onClose: () => void;
onSubmit: () => void;
submitButtonText: string;
title: string;
>>>>>>> 487fbf207299bfd3b7d6404bf0307a8de29ac987
isSubmitButtonHidden?: boolean; isSubmitButtonHidden?: boolean;
children?: ReactNode; children?: ReactNode;
} }

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Load Query Pane should render Default properly 1`] = ` exports[`Right Pane Form should render Default properly 1`] = `
<RightPaneForm <RightPaneForm
expandConsole={[MockFunction]} expandConsole={[MockFunction]}
formError="" formError=""
@@ -28,14 +28,12 @@ exports[`Load Query Pane should render Default properly 1`] = `
> >
<CustomizedPrimaryButton <CustomizedPrimaryButton
ariaLabel="Load" ariaLabel="Load"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
text="Load" text="Load"
type="submit" type="submit"
> >
<PrimaryButton <PrimaryButton
ariaLabel="Load" ariaLabel="Load"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
text="Load" text="Load"
theme={ theme={
@@ -315,7 +313,6 @@ exports[`Load Query Pane should render Default properly 1`] = `
> >
<CustomizedDefaultButton <CustomizedDefaultButton
ariaLabel="Load" ariaLabel="Load"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -597,7 +594,6 @@ exports[`Load Query Pane should render Default properly 1`] = `
> >
<DefaultButton <DefaultButton
ariaLabel="Load" ariaLabel="Load"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -880,7 +876,6 @@ exports[`Load Query Pane should render Default properly 1`] = `
<BaseButton <BaseButton
ariaLabel="Load" ariaLabel="Load"
baseClassName="ms-Button" baseClassName="ms-Button"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -1737,7 +1732,6 @@ exports[`Load Query Pane should render Default properly 1`] = `
aria-label="Load" aria-label="Load"
className="ms-Button ms-Button--primary root-53" className="ms-Button ms-Button--primary root-53"
data-is-focusable={true} data-is-focusable={true}
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onClick={[Function]} onClick={[Function]}
onKeyDown={[Function]} onKeyDown={[Function]}

View File

@@ -1288,7 +1288,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
<Stack <Stack
className="panelInfoErrorContainer" className="panelInfoErrorContainer"
horizontal={true} horizontal={true}
verticalAlign="start" verticalAlign="center"
> >
<div <div
className="ms-Stack panelInfoErrorContainer css-202" className="ms-Stack panelInfoErrorContainer css-202"
@@ -1296,14 +1296,12 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
<StyledIconBase <StyledIconBase
aria-label="warning" aria-label="warning"
className="panelWarningIcon" className="panelWarningIcon"
data-testid="warningIcon"
iconName="WarningSolid" iconName="WarningSolid"
key=".0:$.0" key=".0:$.0"
> >
<IconBase <IconBase
aria-label="warning" aria-label="warning"
className="panelWarningIcon" className="panelWarningIcon"
data-testid="warningIcon"
iconName="WarningSolid" iconName="WarningSolid"
styles={[Function]} styles={[Function]}
theme={ theme={
@@ -1584,11 +1582,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
aria-label="warning" aria-label="warning"
className="panelWarningIcon root-204" className="panelWarningIcon root-204"
data-icon-name="WarningSolid" data-icon-name="WarningSolid"
<<<<<<< HEAD
role="img" role="img"
=======
data-testid="warningIcon"
>>>>>>> 487fbf207299bfd3b7d6404bf0307a8de29ac987
> >
</i> </i>
@@ -1601,13 +1595,11 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
<Text <Text
aria-label="message" aria-label="message"
className="panelWarningErrorMessage" className="panelWarningErrorMessage"
data-testid="panelmessage"
variant="small" variant="small"
> >
<span <span
aria-label="message" aria-label="message"
className="panelWarningErrorMessage css-205" className="panelWarningErrorMessage css-205"
data-testid="panelmessage"
> >
Warning! The action you are about to take cannot be undone. Continuing will permanently delete this resource and all of its children resources. Warning! The action you are about to take cannot be undone. Continuing will permanently delete this resource and all of its children resources.
</span> </span>
@@ -2311,14 +2303,12 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
> >
<CustomizedPrimaryButton <CustomizedPrimaryButton
ariaLabel="OK" ariaLabel="OK"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
text="OK" text="OK"
type="submit" type="submit"
> >
<PrimaryButton <PrimaryButton
ariaLabel="OK" ariaLabel="OK"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
text="OK" text="OK"
theme={ theme={
@@ -2598,7 +2588,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
> >
<CustomizedDefaultButton <CustomizedDefaultButton
ariaLabel="OK" ariaLabel="OK"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -2880,7 +2869,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
> >
<DefaultButton <DefaultButton
ariaLabel="OK" ariaLabel="OK"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -3163,7 +3151,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
<BaseButton <BaseButton
ariaLabel="OK" ariaLabel="OK"
baseClassName="ms-Button" baseClassName="ms-Button"
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onRenderDescription={[Function]} onRenderDescription={[Function]}
primary={true} primary={true}
@@ -4020,7 +4007,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
aria-label="OK" aria-label="OK"
className="ms-Button ms-Button--primary root-218" className="ms-Button ms-Button--primary root-218"
data-is-focusable={true} data-is-focusable={true}
data-testid="submit"
id="sidePanelOkButton" id="sidePanelOkButton"
onClick={[Function]} onClick={[Function]}
onKeyDown={[Function]} onKeyDown={[Function]}