Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-72170] fix nested hetero-list entries with mixture of inputs and buttons #8602

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions war/src/main/js/components/dropdowns/hetero-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ function generateHandles() {
});
}

function convertInputsToButtons(e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a deprecation warning logged to get developers to adapt code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timja would you be OK if this were merged without the deprecation warning or would you strongly prefer that the deprecation warning be added before it is merged?

I'd like to be sure this is included in the next weekly so that it is a strong candidate for a backport to the Nov 15, 2023 LTS baseline.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged with the assumption that we can add the deprecation message in a later pull request

let oldInputs = e.querySelectorAll("INPUT.hetero-list-add");
oldInputs.forEach((oldbtn) => {
let btn = document.createElement("button");
btn.setAttribute("type", "button");
btn.classList.add("hetero-list-add", "jenkins-button");
btn.innerText = oldbtn.getAttribute("value");
if (oldbtn.hasAttribute("suffix")) {
btn.setAttribute("suffix", oldbtn.getAttribute("suffix"));
}
let chevron = createElementFromHtml(Symbols.CHEVRON_DOWN);
btn.appendChild(chevron);
oldbtn.parentNode.appendChild(btn);
oldbtn.remove();
});
}

function generateButtons() {
behaviorShim.specify(
"DIV.hetero-list-container",
Expand All @@ -31,26 +48,8 @@ function generateButtons() {
return;
}

convertInputsToButtons(e);
let btn = Array.from(e.querySelectorAll("BUTTON.hetero-list-add")).pop();
if (!btn) {
let oldbtn = Array.from(
e.querySelectorAll("INPUT.hetero-list-add"),
).pop();
if (!oldbtn) {
return;
}
btn = document.createElement("button");
btn.setAttribute("type", "button");
btn.classList.add("hetero-list-add", "jenkins-button");
btn.innerText = oldbtn.getAttribute("value");
if (oldbtn.hasAttribute("suffix")) {
btn.setAttribute("suffix", oldbtn.getAttribute("suffix"));
}
let chevron = createElementFromHtml(Symbols.CHEVRON_DOWN);
btn.appendChild(chevron);
oldbtn.parentNode.appendChild(btn);
oldbtn.remove();
}

let prototypes = e.lastElementChild;
while (!prototypes.classList.contains("prototypes")) {
Expand Down