diff --git a/app/scenes/Home.tsx b/app/scenes/Home.tsx
index 034a30067..5a09d0b7d 100644
--- a/app/scenes/Home.tsx
+++ b/app/scenes/Home.tsx
@@ -32,7 +32,7 @@ function Home() {
void pins.fetchPage();
}, [pins]);
- const canManageTeam = usePolicy(team).manage;
+ const can = usePolicy(team);
return (
{!ui.languagePromptDismissed && }
{t("Home")}
-
+
diff --git a/app/scenes/Login/Notices.tsx b/app/scenes/Login/Notices.tsx
index 71e38abdb..5b91caf0e 100644
--- a/app/scenes/Login/Notices.tsx
+++ b/app/scenes/Login/Notices.tsx
@@ -37,7 +37,13 @@ export default function Notices() {
Please use a Google Workspaces account instead.
)}
- {notice === "maximum-teams" && (
+ {notice === "pending-deletion" && (
+
+ The workspace associated with your user is scheduled for deletion and
+ cannot at accessed at this time.
+
+ )}
+ {notice === "maximum-reached" && (
The workspace you authenticated with is not authorized on this
installation. Try another?
diff --git a/app/scenes/Settings/Details.tsx b/app/scenes/Settings/Details.tsx
index 1caa6620a..a41b45dc5 100644
--- a/app/scenes/Settings/Details.tsx
+++ b/app/scenes/Settings/Details.tsx
@@ -20,18 +20,22 @@ import Switch from "~/components/Switch";
import Text from "~/components/Text";
import env from "~/env";
import useCurrentTeam from "~/hooks/useCurrentTeam";
+import usePolicy from "~/hooks/usePolicy";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
import isCloudHosted from "~/utils/isCloudHosted";
+import TeamDelete from "../TeamDelete";
import ImageInput from "./components/ImageInput";
import SettingRow from "./components/SettingRow";
function Details() {
- const { auth, ui } = useStores();
+ const { auth, dialogs, ui } = useStores();
const { showToast } = useToasts();
const { t } = useTranslation();
const team = useCurrentTeam();
const theme = useTheme();
+ const can = usePolicy(team);
+
const form = useRef(null);
const [accent, setAccent] = useState(
team.preferences?.customTheme?.accent
@@ -125,6 +129,14 @@ function Details() {
[showToast, t]
);
+ const showDeleteWorkspace = () => {
+ dialogs.openModal({
+ title: t("Delete workspace"),
+ content: ,
+ isCentered: true,
+ });
+ };
+
const onSelectCollection = React.useCallback(async (value: string) => {
const defaultCollectionId = value === "home" ? null : value;
setDefaultCollectionId(defaultCollectionId);
@@ -222,6 +234,7 @@ function Details() {
{team.avatarUrl && (
{auth.isSaving ? `${t("Saving")}…` : t("Save")}
+
+ {can.delete && (
+ <>
+
+
+ {t("Danger")}
+
+
+
+
+
+ >
+ )}
diff --git a/app/scenes/Settings/Members.tsx b/app/scenes/Settings/Members.tsx
index da970d8be..242650b33 100644
--- a/app/scenes/Settings/Members.tsx
+++ b/app/scenes/Settings/Members.tsx
@@ -184,7 +184,7 @@ function Members() {
,
+ isCentered: true,
});
};
@@ -131,8 +132,7 @@ function Preferences() {
/>
-
-
+ {t("Danger")}
}>
{t("Shared Links")}
- {can.manage && !canShareDocuments && (
+ {can.update && !canShareDocuments && (
<>
}>
{t("Sharing is currently disabled.")}{" "}
@@ -95,7 +95,7 @@ function Shares() {
void;
+};
+
+function TeamDelete({ onSubmit }: Props) {
+ const [isWaitingCode, setWaitingCode] = React.useState(false);
+ const { auth } = useStores();
+ const { showToast } = useToasts();
+ const team = useCurrentTeam();
+ const { t } = useTranslation();
+ const {
+ register,
+ handleSubmit: formHandleSubmit,
+ formState,
+ } = useForm();
+
+ const handleRequestDelete = React.useCallback(
+ async (ev: React.SyntheticEvent) => {
+ ev.preventDefault();
+
+ try {
+ await auth.requestDeleteTeam();
+ setWaitingCode(true);
+ } catch (error) {
+ showToast(error.message, {
+ type: "error",
+ });
+ }
+ },
+ [auth, showToast]
+ );
+
+ const handleSubmit = React.useCallback(
+ async (data: FormData) => {
+ try {
+ await auth.deleteTeam(data);
+ await auth.logout();
+ onSubmit();
+ } catch (error) {
+ showToast(error.message, {
+ type: "error",
+ });
+ }
+ },
+ [auth, onSubmit, showToast]
+ );
+
+ const inputProps = register("code", {
+ required: true,
+ });
+ const appName = env.APP_NAME;
+ const workspaceName = team.name;
+
+ return (
+
+
+
+ );
+}
+
+export default observer(TeamDelete);
diff --git a/app/scenes/UserDelete.tsx b/app/scenes/UserDelete.tsx
index 13ce212e6..884080303 100644
--- a/app/scenes/UserDelete.tsx
+++ b/app/scenes/UserDelete.tsx
@@ -30,7 +30,7 @@ function UserDelete() {
ev.preventDefault();
try {
- await auth.requestDelete();
+ await auth.requestDeleteUser();
setWaitingCode(true);
} catch (error) {
showToast(error.message, {
@@ -71,16 +71,8 @@ function UserDelete() {
enter the code below to permanantly destroy your account.
-
- ,
- }}
- />
-
) : (
-