Skip to content

Commit

Permalink
Merge pull request #374 from jdi-testing/1.0.50generation_issues
Browse files Browse the repository at this point in the history
1.0.55generation issues
  • Loading branch information
RomanIovlev authored Oct 2, 2021
2 parents 55f09c2 + 6c85241 commit 97fe62e
Show file tree
Hide file tree
Showing 37 changed files with 931 additions and 669 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
node_modules
dist

.vscode

yarn-lock.json
5 changes: 0 additions & 5 deletions .vscode/extensions.json

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ For updating version in package.json and manifest.json you can run
```
npm run patch
```
or manualy change version in this files.
or manually change version in these files.

Commit and push changes.

When your request has been merged, github actions will create draft of release with current package.json version tag.
When your request has been merged, GitHub actions will create draft of release with current package.json version tag.
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": "",
"devtools_page": "index.html",
"version": "3.0.54",
"version": "3.0.55",
"permissions": [
"activeTab",
"tabs",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdi-react-extension",
"version": "3.0.54",
"version": "3.0.55",
"description": "jdi react extension",
"scripts": {
"start": "npm run webpack",
Expand Down
19 changes: 9 additions & 10 deletions src/js/blocks/autoFind/autoFindProvider/AutoFindProvider.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* eslint-disable indent */
import _, { sortBy } from "lodash";
import React, { useState, useEffect } from "react";
import { inject, observer } from "mobx-react";
import { useContext } from "react";
import _, {sortBy} from "lodash";
import React, {useContext, useEffect, useState} from "react";
import {inject, observer} from "mobx-react";
import {
generatePageObject,
getElements,
highlightElements,
runDocumentListeners,
generatePageObject,
requestGenerationData,
} from "./../utils/pageDataHandlers";
import { JDIclasses, getJdiClassName } from "./../utils/generationClassesMap";
import { connector, sendMessage } from "../utils/connector";
runDocumentListeners,
} from "../utils/pageDataHandlers";
import {getJdiClassName, JDIClasses} from "../utils/generationClassesMap";
import {connector, sendMessage} from "../utils/connector";

export const autoFindStatus = {
noStatus: "",
Expand Down Expand Up @@ -157,7 +156,7 @@ const AutoFindProvider = inject("mainModel")(
sendMessage.elementData({
element,
types: sortBy(
Object.keys(JDIclasses).map((label) => {
Object.keys(JDIClasses).map((label) => {
return { label, jdi: getJdiClassName(label) };
}),
["jdi"]
Expand Down
1 change: 1 addition & 0 deletions src/js/blocks/autoFind/components/ControlBar.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { Divider, Space, Menu, Dropdown } from "antd";
import React, { useState, useEffect } from "react";
import { useAutoFind } from "../autoFindProvider/AutoFindProvider";
Expand Down
10 changes: 5 additions & 5 deletions src/js/blocks/autoFind/components/GenerationButtons.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Icon, { SearchOutlined } from "@ant-design/icons";
import { Button, Space } from "antd";
import Icon, {SearchOutlined} from "@ant-design/icons";
import {Button, Space} from "antd";
import React from "react";
import { autoFindStatus, useAutoFind, xpathGenerationStatus } from "../autoFindProvider/AutoFindProvider";
import {autoFindStatus, useAutoFind, xpathGenerationStatus} from "../autoFindProvider/AutoFindProvider";

// import "./GenerationButtons.less";
import ClearAllSvg from "../../../../icons/clear-all.svg";
import DownloadSvg from "../../../../icons/download.svg";
import { Content } from "antd/lib/layout/layout";
import {Content} from "antd/lib/layout/layout";

export const GenerationButtons = () => {
const [
Expand All @@ -20,7 +20,7 @@ export const GenerationButtons = () => {
<Button
icon={<SearchOutlined />}
type="primary"
loading={status == autoFindStatus.loading}
loading={status === autoFindStatus.loading}
disabled={!allowIdentifyElements}
onClick={identifyElements}
className="jdn__buttons"
Expand Down
9 changes: 4 additions & 5 deletions src/js/blocks/autoFind/components/PerceptionTreshold.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";
import React, {useState} from "react";
import Text from "antd/lib/typography/Text";
import { Col, Row, Slider, Tooltip } from "antd";
import { useAutoFind } from "../autoFindProvider/AutoFindProvider";
import { useState } from "react";
import { Content } from "antd/lib/layout/layout";
import {Col, Row, Slider, Tooltip} from "antd";
import {useAutoFind} from "../autoFindProvider/AutoFindProvider";
import {Content} from "antd/lib/layout/layout";
import Icon from "@ant-design/icons";

import QuestionFilled from "../../../../icons/question-filled.svg";
Expand Down
6 changes: 3 additions & 3 deletions src/js/blocks/autoFind/components/Result.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Space } from "antd";
import { Content } from "antd/lib/layout/layout";
import {Space} from "antd";
import {Content} from "antd/lib/layout/layout";
import Text from "antd/lib/typography/Text";
import React from "react";
import { autoFindStatus, useAutoFind } from "../autoFindProvider/AutoFindProvider";
import {autoFindStatus, useAutoFind} from "../autoFindProvider/AutoFindProvider";

const hideStatus = [autoFindStatus.loading, autoFindStatus.removed];

Expand Down
4 changes: 2 additions & 2 deletions src/js/blocks/autoFind/components/XPathSettings.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";

import { Collapse, InputNumber } from "antd";
import {Collapse, InputNumber} from "antd";
import CollapsePanel from "antd/lib/collapse/CollapsePanel";
import Checkbox from "antd/lib/checkbox/Checkbox";

import { useAutoFind } from "../autoFindProvider/AutoFindProvider";
import {useAutoFind} from "../autoFindProvider/AutoFindProvider";

export const XPathSettings = () => {
const [{ xpathConfig }, { setXpathConfig }] = useAutoFind();
Expand Down
2 changes: 1 addition & 1 deletion src/js/blocks/autoFind/contentScripts/generationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getGenerationAttributes = () => {
return {
...predictedElement,
};
})).filter(el => !!el);
})).filter((el) => !!el);
return generationAttributes;
};

Expand Down
4 changes: 2 additions & 2 deletions src/js/blocks/autoFind/contentScripts/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export const highlightOnPage = () => {
};

const clearContainer = (parent) => {
nodes.forEach(node => {
nodes.forEach((node) => {
if (parent.contains(node)) {
const id = node.getAttribute('jdn-hash');
predictedElements.find(elem => elem.element_id === id).hidden = true;
predictedElements.find((elem) => elem.element_id === id).hidden = true;
chrome.runtime.sendMessage({
message: "REMOVE_ELEMENT",
param: id,
Expand Down
8 changes: 4 additions & 4 deletions src/js/blocks/autoFind/tests/autoFind.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { AutoFindProvider, autoFindStatus, useAutoFind } from "../autoFindProvider/AutoFindProvider";
import {AutoFindProvider, autoFindStatus, useAutoFind} from "../autoFindProvider/AutoFindProvider";

import { act } from "react-dom/test-utils";
import { render, unmountComponentAtNode } from "react-dom";
import {act} from "react-dom/test-utils";
import {render, unmountComponentAtNode} from "react-dom";
import * as pageDataHandlers from "../utils/pageDataHandlers";
import { connector } from "../utils/connector";
import {connector} from "../utils/connector";
import {
abovePerception,
generationData,
Expand Down
4 changes: 2 additions & 2 deletions src/js/blocks/autoFind/utils/generationClassesMap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const defaultClass = "UIElement";

export const JDIclasses = {
export const JDIClasses = {
button: "Button",
link: "Link",
iframe: defaultClass,
Expand All @@ -23,7 +23,7 @@ export const JDIclasses = {
table: "Table",
};

export const getJDILabel = (label) => JDIclasses[label] || label;
export const getJDILabel = (label) => JDIClasses[label] || label;

export const getJdiClassName = (label) => {
let jdiClass = getJDILabel(label);
Expand Down
21 changes: 10 additions & 11 deletions src/js/blocks/autoFind/utils/pageDataHandlers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { connector, sendMessage } from "./connector";
import { runContextMenu } from "./../contentScripts/contextMenu/contextmenu";
import { getGenerationAttributes } from "./../contentScripts/generationData";
import { highlightOnPage } from "./../contentScripts/highlight";
import { getPageData } from "./../contentScripts/pageData";
import { urlListener } from "./../contentScripts/urlListener";
import { getPage, predictedToConvert } from "./pageObject";
import { autoFindStatus } from "./../autoFindProvider/AutoFindProvider";
import { highlightOrder } from "./../contentScripts/highlightOrder";
import { reportProblemPopup } from "../contentScripts/reportProblemPopup/reportProblemPopup";
import { GENERATE_XPATH, MUI_PREDICT, request } from "./backend";
import {connector, sendMessage} from "./connector";
import {runContextMenu} from "../contentScripts/contextMenu/contextmenu";
import {getGenerationAttributes} from "../contentScripts/generationData";
import {highlightOnPage} from "../contentScripts/highlight";
import {getPageData} from "../contentScripts/pageData";
import {urlListener} from "../contentScripts/urlListener";
import {getPage, predictedToConvert} from "./pageObject";
import {autoFindStatus} from "../autoFindProvider/AutoFindProvider";
import {highlightOrder} from "../contentScripts/highlightOrder";
import {reportProblemPopup} from "../contentScripts/reportProblemPopup/reportProblemPopup";
/* global chrome*/

let documentListenersStarted;
Expand Down
21 changes: 11 additions & 10 deletions src/js/blocks/autoFind/utils/pageObject.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { camelCase } from "../../../models/GenerateBlockModel";
import { getJDILabel } from "./generationClassesMap";
import { connector } from "./connector";
import {camelCase} from "../../../models/GenerateBlockModel";
import {getJDILabel} from "./generationClassesMap";
import {connector} from "./connector";

const getPackage = (url) => {
const urlObject = new URL(url);
return urlObject.hostname
return new URL(url).hostname
.split(".")
.reverse()
.map((e) => e.replace(/[^a-zA-Z0-9]+/g, ""))
Expand Down Expand Up @@ -32,15 +31,17 @@ export const predictedToConvert = (elements) => {

const customElementName = e.jdi_custom_class_name;

if (uniqueNames.indexOf(elementName) >= 0) elementName += i;
if (elementTagId && uniqueNames.indexOf(elementTagId) >= 0) elementTagId += i;
if (uniqueNames.indexOf(elementName) >= 0) {
elementName += i;
}
if (elementTagId && uniqueNames.indexOf(elementTagId) >= 0) {
elementTagId += i;
}
uniqueNames.push(elementTagId, elementName);

const name = customElementName ?
customElementName :
elementTagId ?
elementTagId :
elementName;
elementTagId ? elementTagId : elementName;

return {
...e,
Expand Down
Loading

0 comments on commit 97fe62e

Please sign in to comment.