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 7003674 commit efc9847
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 @@ -1601,7 +1601,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 @@ -1373,6 +1373,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 @@ -1423,7 +1424,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 @@ -1450,14 +1451,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 @@ -1476,6 +1477,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 @@ -1499,6 +1501,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 efc9847

Please sign in to comment.