From 97eac2b0e2d976cb6f0a616687a01537d6d817d5 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Thu, 8 Aug 2024 15:15:11 -0700 Subject: [PATCH] fix: Redirect `/orgs` to default path (#2006) Fixes https://github.com/webrecorder/browsertrix/issues/2005 ### Changes Redirects `/orgs` to user's default home page. --- frontend/src/index.ts | 11 +++++- frontend/src/pages/index.ts | 1 - frontend/src/pages/orgs.ts | 75 ------------------------------------- 3 files changed, 9 insertions(+), 78 deletions(-) delete mode 100644 frontend/src/pages/orgs.ts diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 724e81f8..31750a2b 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -108,8 +108,15 @@ export class App extends LiteElement { } willUpdate(changedProperties: Map) { - if (changedProperties.get("viewState") && this.viewState.route === "org") { - AppStateService.updateOrgSlug(this.viewState.params.slug || null); + if (changedProperties.has("viewState")) { + if (this.viewState.route === "orgs") { + this.navigate(this.orgBasePath); + } else if ( + changedProperties.get("viewState") && + this.viewState.route === "org" + ) { + AppStateService.updateOrgSlug(this.viewState.params.slug || null); + } } } diff --git a/frontend/src/pages/index.ts b/frontend/src/pages/index.ts index 6a61cde1..46f9d04a 100644 --- a/frontend/src/pages/index.ts +++ b/frontend/src/pages/index.ts @@ -2,7 +2,6 @@ import "./home"; import(/* webpackChunkName: "sign-up" */ "./sign-up"); import(/* webpackChunkName: "log-in" */ "./log-in"); -import(/* webpackChunkName: "orgs" */ "./orgs"); import(/* webpackChunkName: "org" */ "./org"); import(/* webpackChunkName: "crawls" */ "./crawls"); import(/* webpackChunkName: "join" */ "./invite/join"); diff --git a/frontend/src/pages/orgs.ts b/frontend/src/pages/orgs.ts deleted file mode 100644 index b618da58..00000000 --- a/frontend/src/pages/orgs.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { localized, msg } from "@lit/localize"; -import { customElement, property, state } from "lit/decorators.js"; - -import type { APIPaginatedList } from "@/types/api"; -import type { CurrentUser } from "@/types/user"; -import { needLogin } from "@/utils/auth"; -import type { AuthState } from "@/utils/AuthService"; -import LiteElement, { html } from "@/utils/LiteElement"; -import type { OrgData } from "@/utils/orgs"; - -@localized() -@customElement("btrix-orgs") -@needLogin -export class Orgs extends LiteElement { - @property({ type: Object }) - authState?: AuthState; - - @property({ type: Object }) - userInfo?: CurrentUser; - - @state() - private orgList?: OrgData[]; - - async firstUpdated() { - this.orgList = await this.getOrgs(); - } - - render() { - return html` -
-
-

${msg("Organizations")}

-
-
-
-
- ${this.orgList - ? this.renderOrgs() - : html` -
- -
- `} -
- `; - } - - private renderOrgs() { - if (!this.orgList?.length) { - return html`
-

- ${msg("You don't have any organizations.")} -

-
`; - } - - return html` - - `; - } - - private async getOrgs() { - const data = await this.apiFetch>( - "/orgs", - this.authState!, - ); - - return data.items; - } -}