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

feat(Heroku): add presence #6744

Merged
merged 13 commits into from
Sep 8, 2022
Prev Previous commit
Next Next commit
feat: implement 'blog' and 'dashboard' subdomain presences
  • Loading branch information
theusaf committed Sep 1, 2022
commit 7f4091fabc8ad0c37e056827e0f825cfc851d74f
59 changes: 59 additions & 0 deletions websites/H/Heroku/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,65 @@ Tools: ${toolsStatus.textContent.replace(/\s/g, "")}`;
}
break;
}
case "blog.heroku.com": {
presenceData.details = "Browsing blog posts";
if (pathname !== "/") {
presenceData.state = document.title.match(
/(.*?)(?=(?: \| Heroku|$))/
)[1];
}
break;
}
case "dashboard.heroku.com": {
presenceData.details = "Viewing Dashboard";
if (pathname === "/apps") {
presenceData.state = "Apps";
} else if (pathname === "/new-app") {
presenceData.details = "Creating new app";
} else if (pathname.startsWith("/account")) {
presenceData.details = "Managing account";
if (pathname === "/acount") {
presenceData.state = "Account settings";
} else if (pathname === "/account/applications") {
presenceData.state = "Application settings";
} else if (pathname === "/account/billing") {
presenceData.state = "Billing settings";
}
} else if (pathname.startsWith("/apps/")) {
if (await presence.getSetting<boolean>("showNames")) {
presenceData.details = `Managing app: '${
document.title.match(/(.*?)(?=(?: \| Heroku|$))/)[1]
}'`;
} else {
presenceData.details = "Managing app";
}
const [, , subpath, subpath2] = pathname.split("/").slice(1);
if (subpath) {
switch (subpath) {
case "activity": {
presenceData.state = "Activity";
if (subpath2 === "/builds") {
presenceData.state = "Viewing build log";
}
break;
}
default: {
presenceData.state = `${subpath[0].toUpperCase()}${subpath.slice(
1
)}`;
}
}
} else {
presenceData.state = "Overview";
}
} else if (pathname === "/provision-addon") {
presenceData.details = "Provisioning an addon";
presenceData.state = document.querySelector(
".new-app-view > div > div > div:nth-of-type(2) > div:nth-of-type(2)"
).textContent;
}
break;
}
}

if (presenceData.details) {
Expand Down