-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b595bb8
commit 5aaa88b
Showing
8 changed files
with
582 additions
and
24 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<template> | ||
<v-dialog | ||
transition="dialog-bottom-transition" | ||
width="700" | ||
@click:outside="close();" | ||
> | ||
<v-card class="bg-v-theme-surface" data-test="card-dialog"> | ||
<v-card-title class="text-h5 pa-4 bg-primary" data-test="dialog-title">{{ modalTitle }}</v-card-title> | ||
<v-container data-test="dialog-text"> | ||
<v-row class="mb-2"> | ||
<v-col> | ||
<h4>{{ modalMessage }}</h4> | ||
</v-col> | ||
</v-row> | ||
<v-card-actions> | ||
<v-spacer /> | ||
<v-btn | ||
variant="text" | ||
color="primary" | ||
data-test="save-btn" | ||
@click="buttonFunction()" | ||
> | ||
{{ buttonText }} | ||
</v-btn> | ||
</v-card-actions> | ||
</v-container> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, onMounted } from "vue"; | ||
import axios, { AxiosError } from "axios"; | ||
import { useRouter, useRoute } from "vue-router"; | ||
import { useStore } from "@/store"; | ||
const store = useStore(); | ||
const router = useRouter(); | ||
const route = useRoute(); | ||
const modalTitle = ref("Accept Namespace Invitation"); | ||
const modalMessage = ref<string>("Processing..."); | ||
const buttonText = ref("Close"); | ||
const close = () => { | ||
store.commit("namespaces/setShowNamespaceInvite", false); | ||
router.push("/"); | ||
}; | ||
const buttonFunction = async () => { | ||
if (buttonText.value === "Close") { | ||
close(); | ||
} else { | ||
await store.dispatch("namespaces/switchNamespace", { | ||
tenant_id: route.query["tenant-id"] as string, | ||
}); | ||
window.location.reload(); | ||
} | ||
}; | ||
onMounted(async () => { | ||
if (store.getters["namespaces/showNamespaceInviteDialog"] === true) { | ||
try { | ||
await router.isReady(); | ||
await store.dispatch("namespaces/acceptInvite", { | ||
tenant: route.query["tenant-id"] as string || route.query.tenantid as string, | ||
sig: route.query.sig as string, | ||
}); | ||
modalMessage.value = "Invitation accepted successfully!"; | ||
buttonText.value = "Switch to new namespace"; | ||
} catch (error: unknown) { | ||
if (axios.isAxiosError(error)) { | ||
const axiosError = error as AxiosError; | ||
switch (axiosError.response?.status) { | ||
case 400: | ||
modalMessage.value = "Invalid request. Please check the invitation link."; | ||
break; | ||
case 403: | ||
modalMessage.value = "Invalid or unassociated token. Please verify your credentials. Please try again later."; | ||
break; | ||
case 404: | ||
modalMessage.value = "Namespace or member not found. The invitation may have expired."; | ||
break; | ||
case 500: | ||
modalMessage.value = "Our servers couldn't handle your invitation acceptance. Please try again later."; | ||
break; | ||
default: | ||
modalMessage.value = "Unknown error. Please try again later."; | ||
break; | ||
} | ||
} | ||
buttonText.value = "Close"; | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters