Redirect if org with slug doesn't exist (#1740)

Resolves https://github.com/webrecorder/browsertrix/issues/1739

Redirect to first user's first org if an org with current slug doesn't
exist.
This commit is contained in:
sua yoo 2024-04-24 01:50:55 -07:00 committed by GitHub
parent 6232103e60
commit eeab64a0d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,10 +183,17 @@ export class Org extends LiteElement {
async willUpdate(changedProperties: Map<string, unknown>) { async willUpdate(changedProperties: Map<string, unknown>) {
if ( if (
(changedProperties.has("userInfo") && this.userInfo) || (changedProperties.has("userInfo") || changedProperties.has("slug")) &&
(changedProperties.has("slug") && this.slug) this.userInfo &&
this.slug
) { ) {
if (this.userOrg) {
void this.updateOrg(); void this.updateOrg();
} else {
// Couldn't find org with slug, redirect to first org
this.navTo(`/orgs/${this.userInfo.orgs[0].slug}`);
return;
}
} }
if (changedProperties.has("openDialogName")) { if (changedProperties.has("openDialogName")) {
// Sync URL to create dialog // Sync URL to create dialog
@ -216,9 +223,6 @@ export class Org extends LiteElement {
this.checkStorageQuota(); this.checkStorageQuota();
this.checkExecutionMinutesQuota(); this.checkExecutionMinutesQuota();
} catch { } catch {
// TODO handle 404
this.org = null;
this.notify({ this.notify({
message: msg("Sorry, couldn't retrieve organization at this time."), message: msg("Sorry, couldn't retrieve organization at this time."),
variant: "danger", variant: "danger",
@ -253,8 +257,7 @@ export class Org extends LiteElement {
render() { render() {
if (this.org === null) { if (this.org === null) {
// TODO handle 404 and 500s return html`<btrix-not-found></btrix-not-found>`;
return "";
} }
if (!this.org || !this.userInfo) { if (!this.org || !this.userInfo) {