From 084a01fb02e3cd004fc4f8827e2180ecbba2e611 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 12 Jan 2022 13:52:37 -0800 Subject: [PATCH] Admin social features (#408) * ActivityPub admin pages for configuration * Fix dev build * Add support for requiring follow approval. Closes https://github.com/owncast/owncast/issues/1208 * Point at admin version of followers endpoint * Add setting for toggling displaying fediverse engagement in admin. https://github.com/owncast/owncast/issues/1404 * Add instance URL textfield to federation config and disable federation if it is empty * If instance URL is not https disable federation * Tweak federation toggle text. Make go live message optional * Add federation info modal. Closes https://github.com/owncast/owncast/issues/1544 * Add support for blocked federated domains. For https://github.com/owncast/owncast/issues/1209 * Simplify fediverse post input * Add placeholder Fediverse icon * Tweak federation logo in admin menu. Closes https://github.com/owncast/owncast/issues/1603 * Add global button for composing a fediverse post. Closes https://github.com/owncast/owncast/issues/1610 * Federation -> Social * Add page for listing federated actions. Closes https://github.com/owncast/owncast/issues/1573 * Auto-close social post modal after success * Make user modal action buttons look nicer * Center and reduce width and center count column. Closes https://github.com/owncast/owncast/issues/1580 * Update the followers table to be clearer * Fix exception thrown when passing undefined * Disable federation settings if feature is disabled * Update enable social modal. For https://github.com/owncast/owncast/issues/1594 * Fix type props * Quiet, linter * Move compose button to the left * Add tooltip for compose button * Add NSFW toggle to federation config. Closes https://github.com/owncast/owncast/issues/1628 * Add support for blocking/removing followers. For https://github.com/owncast/owncast/issues/1630 * Allow editing the server url field even when federation is disabled * Continue to update the copy around the social features * Use relative path to action images. Fixes https://github.com/owncast/owncast/issues/1646 * Link IRIs and make action verbse present tense * Update caniuse --- web/components/client-table.tsx | 2 + web/components/compose-federated-post.tsx | 76 +++++ web/components/config/edit-string-array.tsx | 2 +- web/components/main-layout.tsx | 66 +++- web/components/moderator-user-button.tsx | 15 +- web/components/user-popover.tsx | 38 +-- web/next-env.d.ts | 1 - web/package-lock.json | 16 +- web/pages/config-federation.tsx | 323 ++++++++++++++++++++ web/pages/federation/actions.tsx | 120 ++++++++ web/pages/federation/followers.tsx | 318 +++++++++++++++++++ web/public/fediverse-white.png | Bin 0 -> 4877 bytes web/styles/globals.scss | 18 +- web/styles/main-layout.scss | 1 + web/types/config-section.ts | 10 + web/utils/apis.ts | 18 ++ web/utils/config-constants.tsx | 78 +++++ web/utils/server-status-context.tsx | 8 + 18 files changed, 1068 insertions(+), 42 deletions(-) create mode 100644 web/components/compose-federated-post.tsx create mode 100644 web/pages/config-federation.tsx create mode 100644 web/pages/federation/actions.tsx create mode 100644 web/pages/federation/followers.tsx create mode 100644 web/public/fediverse-white.png diff --git a/web/components/client-table.tsx b/web/components/client-table.tsx index fa7060fd0..f042da439 100644 --- a/web/components/client-table.tsx +++ b/web/components/client-table.tsx @@ -30,8 +30,10 @@ export default function ClientTable({ data }: ClientTableProps) { dataIndex: 'messageCount', key: 'messageCount', className: 'number-col', + width: '12%', sorter: (a: any, b: any) => a.messageCount - b.messageCount, sortDirections: ['descend', 'ascend'] as SortOrder[], + render: (count: number) =>
{count}
, }, { title: 'Connected Time', diff --git a/web/components/compose-federated-post.tsx b/web/components/compose-federated-post.tsx new file mode 100644 index 000000000..901fbfae2 --- /dev/null +++ b/web/components/compose-federated-post.tsx @@ -0,0 +1,76 @@ +import React, { useState } from 'react'; + +import { Button, Space, Input, Modal } from 'antd'; +import { STATUS_ERROR, STATUS_SUCCESS } from '../utils/input-statuses'; +import { fetchData, FEDERATION_MESSAGE_SEND } from '../utils/apis'; + +const { TextArea } = Input; + +interface ComposeFederatedPostProps { + visible: boolean; + handleClose: () => void; +} + +export default function ComposeFederatedPost({ visible, handleClose }: ComposeFederatedPostProps) { + const [content, setContent] = useState(''); + const [postPending, setPostPending] = useState(false); + const [postSuccessState, setPostSuccessState] = useState(null); + + function handleEditorChange(e) { + setContent(e.target.value); + } + + async function sendButtonClicked() { + setPostPending(true); + + const data = { + value: content, + }; + try { + await fetchData(FEDERATION_MESSAGE_SEND, { + data, + method: 'POST', + auth: true, + }); + setPostSuccessState(STATUS_SUCCESS); + setTimeout(handleClose, 1000); + } catch (e) { + // eslint-disable-next-line no-console + console.error(e); + setPostSuccessState(STATUS_ERROR); + } + setPostPending(false); + } + + return ( + handleClose()}>Cancel, + , + ]} + > + +