Skip to content

Commit

Permalink
Merge pull request #282 from jdi-testing/issue-208
Browse files Browse the repository at this point in the history
Issue-208: Change name feature
  • Loading branch information
Bryant-24 authored Aug 12, 2021
2 parents 4612398 + ffc8569 commit 9db9023
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
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.39",
"version": "3.0.40",
"permissions": [
"activeTab",
"tabs",
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": "jdi-react-extension",
"version": "3.0.39",
"version": "3.0.40",
"description": "jdi react extension",
"scripts": {
"start": "npm run webpack",
Expand Down
4 changes: 2 additions & 2 deletions src/js/blocks/autoFind/autoFindProvider/AutoFindProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ const AutoFindProvider = inject("mainModel")(
});
};

const changeElementName = (id, name) => {
const changeElementName = ({id, name}) => {
setPredictedElements((previousValue) => {
const renamed = previousValue.map((el) => {
if (el.element_id === id) {
el.jdi_class_name = name;
el.jdi_custom_class_name = name;
sendMessage.changeElementName(el);
}
return el;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ export const runContextMenu = () => {
let predictedElement;

const menuItems = (
{ jdi_class_name, element_id, skipGeneration },
{ jdi_class_name, jdi_custom_class_name = null, element_id, skipGeneration },
types
) => [
{
text: `Change name: ${jdi_class_name} <i class='cm_text_icon'>&#9998;</i>`,
text: `Change name: ${jdi_custom_class_name ? jdi_custom_class_name : jdi_class_name} <i class='cm_text_icon'>&#9998;</i>`,
events: {
click: () => changeElementNameModal(element_id, jdi_class_name),
},
Expand Down
9 changes: 8 additions & 1 deletion src/js/blocks/autoFind/autoFindProvider/pageObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ export const predictedToConvert = (elements) => {
return f.map((e, i) => {
let elementName = getElementName(e);
let elementTagId = e.predictedAttrId;
let customElementName = e.jdi_custom_class_name;

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;

return {
...e,
Locator: e.xpath,
Name: elementTagId ? elementTagId : elementName,
Name: name,
Type: getJDILabel(e.predicted_label),
parent: null,
parentId: null,
Expand Down

0 comments on commit 9db9023

Please sign in to comment.