fix: Redirect /orgs to default path (#2006)
				
					
				
			Fixes https://github.com/webrecorder/browsertrix/issues/2005 <!-- Fixes #issue_number --> ### Changes Redirects `/orgs` to user's default home page.
This commit is contained in:
		
							parent
							
								
									2b5f964c24
								
							
						
					
					
						commit
						97eac2b0e2
					
				| @ -108,8 +108,15 @@ export class App extends LiteElement { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   willUpdate(changedProperties: Map<string, unknown>) { |   willUpdate(changedProperties: Map<string, unknown>) { | ||||||
|     if (changedProperties.get("viewState") && this.viewState.route === "org") { |     if (changedProperties.has("viewState")) { | ||||||
|       AppStateService.updateOrgSlug(this.viewState.params.slug || null); |       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); | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,7 +2,6 @@ import "./home"; | |||||||
| 
 | 
 | ||||||
| import(/* webpackChunkName: "sign-up" */ "./sign-up"); | import(/* webpackChunkName: "sign-up" */ "./sign-up"); | ||||||
| import(/* webpackChunkName: "log-in" */ "./log-in"); | import(/* webpackChunkName: "log-in" */ "./log-in"); | ||||||
| import(/* webpackChunkName: "orgs" */ "./orgs"); |  | ||||||
| import(/* webpackChunkName: "org" */ "./org"); | import(/* webpackChunkName: "org" */ "./org"); | ||||||
| import(/* webpackChunkName: "crawls" */ "./crawls"); | import(/* webpackChunkName: "crawls" */ "./crawls"); | ||||||
| import(/* webpackChunkName: "join" */ "./invite/join"); | import(/* webpackChunkName: "join" */ "./invite/join"); | ||||||
|  | |||||||
| @ -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` |  | ||||||
|       <div class="bg-white"> |  | ||||||
|         <header |  | ||||||
|           class="mx-auto box-border w-full max-w-screen-desktop px-3 py-4 md:py-8" |  | ||||||
|         > |  | ||||||
|           <h1 class="text-xl font-medium">${msg("Organizations")}</h1> |  | ||||||
|         </header> |  | ||||||
|         <hr /> |  | ||||||
|       </div> |  | ||||||
|       <main class="mx-auto box-border w-full max-w-screen-desktop px-3 py-4"> |  | ||||||
|         ${this.orgList |  | ||||||
|           ? this.renderOrgs() |  | ||||||
|           : html` |  | ||||||
|               <div class="my-24 flex items-center justify-center text-3xl"> |  | ||||||
|                 <sl-spinner></sl-spinner> |  | ||||||
|               </div> |  | ||||||
|             `}
 |  | ||||||
|       </main> |  | ||||||
|     `;
 |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   private renderOrgs() { |  | ||||||
|     if (!this.orgList?.length) { |  | ||||||
|       return html`<div class="rounded-lg border bg-white p-4 md:p-8">
 |  | ||||||
|         <p class="text-center text-neutral-400"> |  | ||||||
|           ${msg("You don't have any organizations.")} |  | ||||||
|         </p> |  | ||||||
|       </div>`;
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return html` |  | ||||||
|       <btrix-orgs-list |  | ||||||
|         .userInfo=${this.userInfo} |  | ||||||
|         .orgList=${this.orgList} |  | ||||||
|       ></btrix-orgs-list> |  | ||||||
|     `;
 |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   private async getOrgs() { |  | ||||||
|     const data = await this.apiFetch<APIPaginatedList<OrgData>>( |  | ||||||
|       "/orgs", |  | ||||||
|       this.authState!, |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     return data.items; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user