Skip to content

Commit

Permalink
Wildcard subdomains - UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenfra committed May 16, 2022
1 parent 8f5a7e6 commit 83fd73b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,11 @@ manage things like container crud */
}

#edit-sites-assigned .hostname .subdomain.wildcardSubdomain {
opacity: 0.2;
background-color: var(--identity-icon-color);
border-radius: 8px;
margin-right: 4px;
padding-left: 10px;
padding-right: 10px;
}

.assigned-sites-list > div {
Expand Down
11 changes: 7 additions & 4 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {

// Populating the panel: name and icon
document.getElementById("edit-assignments-title").textContent = identity.name;
document.getElementById("edit-sites-assigned").setAttribute("data-identity-color", identity.color);

const userContextId = Logic.currentUserContextId();
const assignments = await Logic.getAssignmentObjectByContainer(userContextId);
Expand Down Expand Up @@ -1427,7 +1428,7 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
});
// Wildcard click-to-toggle subdomains
trElement.querySelectorAll(".subdomain").forEach((subdomainLink) => {
subdomainLink.addEventListener("click", async (e) => {
subdomainLink.addEventListener("click", (e) => {
const wildcardHostname = e.target.getAttribute("data-wildcardHostname");
Utils.setWildcardHostnameForAssignment(assumedUrl, wildcardHostname);
if (wildcardHostname) {
Expand All @@ -1454,14 +1455,14 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
if (wildcardHostname && wildcardHostname !== hostname) {
if (hostname.endsWith(wildcardHostname)) {
return {
wildcard: hostname.substring(0, hostname.length - wildcardHostname.length),
wildcard: "★",
remaining: wildcardHostname
};
} else {
// In case something got corrupted, allow user to fix error
// by clicking "____" link to clear corrupted wildcard hostname
// by clicking '★' link to clear corrupted wildcard hostname
return {
wildcard: "___",
wildcard: "",
remaining: hostname
};
}
Expand All @@ -1480,6 +1481,7 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
// Add wildcard subdomain(s)
if (subdomains.wildcard) {
result.appendChild(this.assignmentSubdomainLink(null, subdomains.wildcard));
result.appendChild(document.createTextNode("."));
}

// Add non-wildcard subdomains
Expand All @@ -1503,6 +1505,7 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
result.className = "subdomain";
if (wildcardHostnameOnClick) {
result.setAttribute("data-wildcardHostname", wildcardHostnameOnClick);
result.title = `*.${wildcardHostnameOnClick}`;
} else {
result.classList.add("wildcardSubdomain");
}
Expand Down

0 comments on commit 83fd73b

Please sign in to comment.