) => {
- switch (props.validationStatus) {
- case WebhookValidationStatus.NotDiscordURL:
- return (
-
- URL must be to a Discord webhook, starting with
- "https://discord.com/api/webhooks/".
-
- );
- case WebhookValidationStatus.NotSameGuild:
- return (
-
- Webhook must be in the same guild you are currently editing.
-
- );
- case WebhookValidationStatus.DoesNotExist:
- return (
-
- This webhook doesn't exist.
-
- );
- default:
- return ;
- }
-};
-
-const Alert = styled(GoAlert)`
- color: ${palette.red400};
- position: relative;
- top: 2px;
-`;
+export const ServerUtilities = (props: Props) => (
+
+ {/* Server Utilities */}
+
+
+ Access Control
+ >
+ }
+ description="Set up who can use Roleypoly in your server"
+ link={`/s/${props.guildData.id}/edit/access-control`}
+ />
+
+
+ Audit Logging
+ >
+ }
+ description="Setup audit logging via a Discord webhook"
+ link={`/s/${props.guildData.id}/edit/audit-logging`}
+ />
+
+
+ Import from Roleypoly Legacy
+ >
+ }
+ description="Used Roleypoly before and don't see your categories?"
+ link={`/s/${props.guildData.id}/edit/import-from-legacy`}
+ />
+
+
+ Manage your Data
+ >
+ }
+ description="Export or delete all of your Roleypoly data."
+ link={`/s/${props.guildData.id}/edit/data`}
+ />
+
+);
diff --git a/packages/design-system/molecules/server-utilities/index.ts b/packages/design-system/molecules/server-utilities/index.ts
new file mode 100644
index 0000000..2020033
--- /dev/null
+++ b/packages/design-system/molecules/server-utilities/index.ts
@@ -0,0 +1 @@
+export * from './ServerUtilities';
diff --git a/packages/design-system/organisms/editor-shell/EditorShell.tsx b/packages/design-system/organisms/editor-shell/EditorShell.tsx
index 0258b00..693b163 100644
--- a/packages/design-system/organisms/editor-shell/EditorShell.tsx
+++ b/packages/design-system/organisms/editor-shell/EditorShell.tsx
@@ -5,12 +5,7 @@ import { ServerUtilities } from '@roleypoly/design-system/molecules/server-utili
import { SecondaryEditing } from '@roleypoly/design-system/organisms/masthead';
import { Container } from '@roleypoly/design-system/organisms/role-picker/RolePicker.styled';
import { ServerCategoryEditor } from '@roleypoly/design-system/organisms/server-category-editor';
-import {
- Category,
- GuildData,
- PresentableGuild,
- WebhookValidationStatus,
-} from '@roleypoly/types';
+import { Category, PresentableGuild } from '@roleypoly/types';
import deepEqual from 'deep-equal';
import React from 'react';
@@ -19,26 +14,17 @@ export type EditorShellProps = {
onGuildChange?: (guild: PresentableGuild) => void;
onCategoryChange?: (category: Category) => void;
onMessageChange?: (message: PresentableGuild['data']['message']) => void;
- errors: {
- webhookValidation: WebhookValidationStatus;
- };
};
export const EditorShell = (props: EditorShellProps) => {
const [guild, setGuild] = React.useState(props.guild);
- const [errors, setErrors] = React.useState(props.errors);
React.useEffect(() => {
setGuild(props.guild);
}, [props.guild]);
- React.useEffect(() => {
- setErrors(props.errors);
- }, [props.errors]);
-
const reset = () => {
setGuild(props.guild);
- setErrors({ webhookValidation: WebhookValidationStatus.Ok });
};
const replaceCategories = (categories: Category[]) => {
@@ -53,12 +39,6 @@ export const EditorShell = (props: EditorShellProps) => {
});
};
- const updateGuildData = (data: PresentableGuild['data']) => {
- setGuild((currentGuild) => {
- return { ...currentGuild, data };
- });
- };
-
const doSubmit = () => {
props.onGuildChange?.(guild);
};
@@ -87,47 +67,8 @@ export const EditorShell = (props: EditorShellProps) => {
-
+
>
);
};
-
-const validateWebhook = (
- webhook: GuildData['auditLogWebhook'],
- validationStatus: WebhookValidationStatus
-) => {
- if (!webhook) {
- return WebhookValidationStatus.NoneSet;
- }
-
- try {
- const url = new URL(webhook);
-
- if (
- url.hostname !== 'discord.com' ||
- url.protocol !== 'https:' ||
- url.pathname.startsWith('api/webhooks/')
- ) {
- return WebhookValidationStatus.NotDiscordURL;
- }
- } catch (e) {
- return WebhookValidationStatus.Ok;
- }
-
- if (
- validationStatus !== WebhookValidationStatus.Ok &&
- validationStatus !== WebhookValidationStatus.NoneSet
- ) {
- return validationStatus;
- }
-
- return WebhookValidationStatus.Ok;
-};
diff --git a/packages/design-system/templates/editor/Editor.tsx b/packages/design-system/templates/editor/Editor.tsx
index 36d76d3..6e6169c 100644
--- a/packages/design-system/templates/editor/Editor.tsx
+++ b/packages/design-system/templates/editor/Editor.tsx
@@ -11,9 +11,7 @@ export const EditorTemplate = (
props;
return (
-
+
);
};
-
-export type EditorErrors = EditorShellProps['errors'];
diff --git a/packages/web/src/pages/editor.tsx b/packages/web/src/pages/editor.tsx
index c123568..5dfa9d6 100644
--- a/packages/web/src/pages/editor.tsx
+++ b/packages/web/src/pages/editor.tsx
@@ -1,11 +1,10 @@
import { navigate, Redirect } from '@reach/router';
-import { EditorErrors, EditorTemplate } from '@roleypoly/design-system/templates/editor';
+import { EditorTemplate } from '@roleypoly/design-system/templates/editor';
import { GenericLoadingTemplate } from '@roleypoly/design-system/templates/generic-loading';
import {
GuildDataUpdate,
PresentableGuild,
UserGuildPermissions,
- WebhookValidationStatus,
} from '@roleypoly/types';
import * as React from 'react';
import { useAppShellProps } from '../contexts/app-shell/AppShellContext';
@@ -26,9 +25,6 @@ const Editor = (props: EditorProps) => {
const [guild, setGuild] = React.useState(null);
const [pending, setPending] = React.useState(false);
- const [errors, setErrors] = React.useState({
- webhookValidation: WebhookValidationStatus.Ok,
- });
React.useEffect(() => {
const shouldPullUncached = (): boolean => {
@@ -104,28 +100,13 @@ const Editor = (props: EditorProps) => {
navigate(`/s/${props.serverID}`);
}
- if (response.status === 400) {
- const error = await response.json();
- if (error.data.what === 'webhookValidationStatus') {
- setErrors((errors) => ({
- ...errors,
- webhookValidation: error.data.webhookValidationStatus,
- }));
- }
- }
-
setPending(false);
};
return (
<>
-
+
>
);
};