Skip to content

Commit

Permalink
Merge pull request #1409 from jdi-testing/issue_1144
Browse files Browse the repository at this point in the history
Issue 1144 Empty state for Locators List
  • Loading branch information
Iogsotot authored Jul 27, 2023
2 parents d2184a9 + 9b58f30 commit 14d118a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
"singleQuote": false,
"endOfLine": "auto"
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "JDN",
"description": "JDN – helps Test Automation Engineer to create Page Objects in the test automation framework and speed up test development",
"devtools_page": "index.html",
"version": "3.13.535",
"version": "3.13.536",
"icons": {
"128": "icon128.png"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdn-ai-chrome-extension",
"version": "3.13.535",
"version": "3.13.536",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
23 changes: 18 additions & 5 deletions src/features/locators/LocatorsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
} from "./selectors/locatorsFiltered.selectors";
import { useNotifications } from "../../common/components/notification/useNotifications";
import { selectCurrentPageObject } from "../pageObjects/selectors/pageObjects.selectors";
import { EmptyListInfo } from "../../common/components/emptyListInfo/EmptyListInfo";
import { EmptyListModal } from "./text.constants";
import { LocatorsEmptyListInfo } from "./components/LocatorsEmptyListInfo";

const { confirm } = Modal;

Expand All @@ -56,6 +57,8 @@ export const LocatorsPage = () => {
const breadcrumbsRef = useRef(null);
const [locatorsSnapshot] = useState(useSelector(selectLocatorsByPageObject));
const [filterSnapshot] = useState(useSelector(selectClassFilterByPO));
const [isEmptyListModalOpen, setIsEmptyListModalOpen] = useState(!Boolean(size(locators)));
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
// For changing locatorsList-content height depends on header height
const containerHeight = useCalculateHeaderSize(breadcrumbsRef);

Expand Down Expand Up @@ -168,6 +171,8 @@ export const LocatorsPage = () => {
<Filter />
</Row>
<LocatorListHeader
isEditModalOpen={isEditModalOpen}
setIsEditModalOpen={setIsEditModalOpen}
render={(viewProps: LocatorTreeProps["viewProps"]) => (
<div
ref={containerRef}
Expand All @@ -179,10 +184,18 @@ export const LocatorsPage = () => {
) : showSpinner ? (
<LocatorTreeSpinner />
) : (
<EmptyListInfo>
Select the elements you need on the web page coverage and add them to the PO via a double-click or
through the context menu
</EmptyListInfo>
<>
<Modal
title={EmptyListModal.Title}
open={isEmptyListModalOpen}
onCancel={() => setIsEmptyListModalOpen(false)}
onOk={pageBack}
okText={EmptyListModal.OkButtonTitle}
>
{EmptyListModal.Contents}
</Modal>
<LocatorsEmptyListInfo setIsEditModalOpen={setIsEditModalOpen}></LocatorsEmptyListInfo>
</>
)}
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/features/locators/components/LocatorEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const LocatorEditDialog: React.FC<Props> = ({
const initialValues: FormValues = {
type,
name: name || "",
locator: locator.output ?? "",
locator: locator?.output ?? "",
locatorType: defaultLocatorType,
annotationType: defaultAnnotationType,
};
Expand Down
13 changes: 11 additions & 2 deletions src/features/locators/components/LocatorListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ import {
selectActualActiveByPageObject,
} from "../selectors/locatorsFiltered.selectors";

export const LocatorListHeader = ({ render }: { render: (viewProps: LocatorTreeProps["viewProps"]) => ReactNode }) => {
interface LocatorListHeaderProps {
render: (viewProps: LocatorTreeProps["viewProps"]) => ReactNode;
isEditModalOpen: boolean;
setIsEditModalOpen: (isOpen: boolean) => void;
}

export const LocatorListHeader = ({
render,
isEditModalOpen,
setIsEditModalOpen,
}: LocatorListHeaderProps): JSX.Element => {
const dispatch = useDispatch();
const [expandAll, setExpandAll] = useState(ExpandState.Expanded);
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [isCreatingForm, setIsCreatingForm] = useState(false);
const [searchString, setSearchString] = useState("");

Expand Down
25 changes: 25 additions & 0 deletions src/features/locators/components/LocatorsEmptyListInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { EmptyListInfo } from "../../../common/components/emptyListInfo/EmptyListInfo";
import React from "react";
import { Button } from "antd";
import { OnboardingPopup } from "../../onboarding/components/OnboardingPopup";

interface LocatorsEmptyListInfoProps {
setIsEditModalOpen: (isOpen: boolean) => void;
}

export const LocatorsEmptyListInfo = ({ setIsEditModalOpen }: LocatorsEmptyListInfoProps): JSX.Element => (
<EmptyListInfo>
You can either create a{" "}
<Button type="link" onClick={() => setIsEditModalOpen(true)}>
Custom locator
</Button>{" "}
or refer to our{" "}
<OnboardingPopup>
<Button type="link" size="small">
Onboarding tutorial
</Button>
.
</OnboardingPopup>{" "}
to understand the JDN features
</EmptyListInfo>
);
6 changes: 6 additions & 0 deletions src/features/locators/text.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const enum EmptyListModal {
Title = "Unable to Identify Elements",
Contents = "Unfortunately, we can't identify any elements. Please make sure that the correct library is " +
"selected and that general settings are properly configured.",
OkButtonTitle = "Open Settings",
}

0 comments on commit 14d118a

Please sign in to comment.