8000 feat: Adds team preference to disable user account removal by tommoor · Pull Request #7556 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Adds team preference to disable user account removal #7556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions app/scenes/Settings/Preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Switch from "~/components/Switch";
import Text from "~/components/Text";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import useCurrentUser from "~/hooks/useCurrentUser";
import usePolicy from "~/hooks/usePolicy";
import useStores from "~/hooks/useStores";
import UserDelete from "../UserDelete";
import SettingRow from "./components/SettingRow";
Expand All @@ -23,6 +24,7 @@ function Preferences() {
const { ui, dialogs } = useStores();
const user = useCurrentUser();
const team = useCurrentTeam();
const can = usePolicy(user.id);

const handlePreferenceChange =
(inverted = false) =>
Expand Down Expand Up @@ -166,20 +168,24 @@ function Preferences() {
/>
</SettingRow>

<Heading as="h2">{t("Danger")}</Heading>
<SettingRow
name="delete"
label={t("Delete account")}
description={t(
"You may delete your account at any time, note that this is unrecoverable"
)}
>
<span>
<Button neutral>
{t("Delete account")}…
</Button>
</span>
</SettingRow>
{can.delete && (
<>
<Heading as="h2">{t("Danger")}</Heading>
<SettingRow
name="delete"
label={t("Delete account")}
description={t(
"You may delete your account at any time, note that this is unrecoverable"
)}
>
<span>
<Button neutral>
{t("Delete account")}…
</Button>
</span>
</SettingRow>
</>
)}
</Scene>
);
}
Expand Down
13 changes: 13 additions & 0 deletions app/scenes/Settings/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,19 @@ function Security() {
>
/>
</SettingRow>
<SettingRow
label={t("Users can delete account")}
name={TeamPreference.MembersCanDeleteAccount}
description={t(
"When enabled, users can delete their own account from the workspace"
)}
>
<Switch
id={TeamPreference.MembersCanDeleteAccount}
checked={team.getPreference(TeamPreference.MembersCanDeleteAccount)}
>
/>
</SettingRow>
<SettingRow
label={t("Rich service embeds")}
name="documentEmbeds"
Expand Down
5 changes: 4 additions & 1 deletion server/policies/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ allow(User, ["update", "delete", "readDetails"], User, (actor, user) =>
or(
//
isTeamAdmin(actor, user),
actor.id === user?.id
and(
actor.id === user?.id,
!!actor.team.getPreference(TeamPreference.MembersCanDeleteAccount)
)
)
);

Expand Down
2 changes: 2 additions & 0 deletions server/routes/api/teams/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const TeamsUpdateSchema = BaseSchema.extend({
membersCanInvite: z.boolean().optional(),
/** Whether members can create API keys. */
membersCanCreateApiKey: z.boolean().optional(),
/** Whether members can delete their user account. */
membersCanDeleteAccount: z.boolean().optional(),
/** Whether commenting is enabled */
commenting: z.boolean().optional(),
/** The custom theme for the team. */
Expand Down
1 change: 1 addition & 0 deletions shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const TeamPreferenceDefaults: TeamPreferences = {
[TeamPreference.ViewersCanExport]: true,
[TeamPreference.MembersCanInvite]: false,
[TeamPreference.MembersCanCreateApiKey]: true,
[TeamPreference.MembersCanDeleteAccount]: true,
[TeamPreference.PublicBranding]: false,
[TeamPreference.Commenting]: true,
[TeamPreference.CustomTheme]: undefined,
Expand Down
2 changes: 2 additions & 0 deletions shared/i18n/locales/en_US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@
"When enabled, documents can be shared publicly on the internet by any member of the workspace": "When enabled, documents can be shared publicly on the internet by any member of the workspace",
"Viewer document exports": "Viewer document exports",
"When enabled, viewers can see download options for documents": "When enabled, viewers can see download options for documents",
"Users can delete account": "Users can delete account",
"When enabled, users can delete their own account from the workspace": "When enabled, users can delete their own account from the workspace",
"Rich service embeds": "Rich service embeds",
"Links to supported services are shown as rich embeds within your documents": "Links to supported services are shown as rich embeds within your documents",
"Collection creation": "Collection creation",
Expand Down
3 changes: 3 additions & 0 deletions shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ export enum TeamPreference {
MembersCanInvite = "membersCanInvite",
/** Whether members can create API keys. */
MembersCanCreateApiKey = "membersCanCreateApiKey",
/** Whether members can delete their user account. */
MembersCanDeleteAccount = "membersCanDeleteAccount",
/** Whether users can comment on documents. */
Commenting = "commenting",
/** The custom theme for the team. */
Expand All @@ -220,6 +222,7 @@ export type TeamPreferences = {
[TeamPreference.ViewersCanExport]?: boolean;
[TeamPreference.MembersCanInvite]?: boolean;
[TeamPreference.MembersCanCreateApiKey]?: boolean;
[TeamPreference.MembersCanDeleteAccount]?: boolean;
[TeamPreference.Commenting]?: boolean;
[TeamPreference.CustomTheme]?: Partial<CustomTheme>;
[TeamPreference.TocPosition]?: TOCPosition;
Expand Down
Loading
1E0A
0