Merge branch 'multitenancy' into 'main'
Multitenancy support See merge request soapbox-pub/soapbox!2866
This commit is contained in:
commit
cdecabda1a
|
@ -1,2 +1,6 @@
|
|||
export { useCreateDomain, type CreateDomainParams } from './useCreateDomain';
|
||||
export { useDeleteDomain } from './useDeleteDomain';
|
||||
export { useDomains } from './useDomains';
|
||||
export { useSuggest } from './useSuggest';
|
||||
export { useUpdateDomain } from './useUpdateDomain';
|
||||
export { useVerify } from './useVerify';
|
|
@ -0,0 +1,23 @@
|
|||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useCreateEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
import { domainSchema } from 'soapbox/schemas';
|
||||
|
||||
interface CreateDomainParams {
|
||||
domain: string;
|
||||
public: boolean;
|
||||
}
|
||||
|
||||
const useCreateDomain = () => {
|
||||
const api = useApi();
|
||||
|
||||
const { createEntity, ...rest } = useCreateEntity([Entities.DOMAINS], (params: CreateDomainParams) =>
|
||||
api.post('/api/v1/pleroma/admin/domains', params), { schema: domainSchema });
|
||||
|
||||
return {
|
||||
createDomain: createEntity,
|
||||
...rest,
|
||||
};
|
||||
};
|
||||
|
||||
export { useCreateDomain, type CreateDomainParams };
|
|
@ -0,0 +1,26 @@
|
|||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useDeleteEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
|
||||
interface DeleteDomainParams {
|
||||
domain: string;
|
||||
public: boolean;
|
||||
}
|
||||
|
||||
const useDeleteDomain = () => {
|
||||
const api = useApi();
|
||||
|
||||
const { deleteEntity, ...rest } = useDeleteEntity(Entities.DOMAINS, (id: string) =>
|
||||
api.delete(`/api/v1/pleroma/admin/domains/${id}`, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
mutate: deleteEntity,
|
||||
...rest,
|
||||
};
|
||||
};
|
||||
|
||||
export { useDeleteDomain, type DeleteDomainParams };
|
|
@ -0,0 +1,25 @@
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
import { domainSchema, type Domain } from 'soapbox/schemas';
|
||||
|
||||
const useDomains = () => {
|
||||
const api = useApi();
|
||||
|
||||
const getDomains = async () => {
|
||||
const { data } = await api.get<Domain[]>('/api/v1/pleroma/admin/domains');
|
||||
|
||||
const normalizedData = data.map((domain) => domainSchema.parse(domain));
|
||||
return normalizedData;
|
||||
};
|
||||
|
||||
const result = useQuery<ReadonlyArray<Domain>>({
|
||||
queryKey: ['domains'],
|
||||
queryFn: getDomains,
|
||||
placeholderData: [],
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export { useDomains };
|
|
@ -0,0 +1,20 @@
|
|||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useCreateEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
import { domainSchema } from 'soapbox/schemas';
|
||||
|
||||
import type { CreateDomainParams } from './useCreateDomain';
|
||||
|
||||
const useUpdateDomain = (id: string) => {
|
||||
const api = useApi();
|
||||
|
||||
const { createEntity, ...rest } = useCreateEntity([Entities.DOMAINS], (params: Omit<CreateDomainParams, 'domain'>) =>
|
||||
api.patch(`/api/v1/pleroma/admin/domains/${id}`, params), { schema: domainSchema });
|
||||
|
||||
return {
|
||||
updateDomain: createEntity,
|
||||
...rest,
|
||||
};
|
||||
};
|
||||
|
||||
export { useUpdateDomain };
|
|
@ -31,13 +31,9 @@ const spaces = {
|
|||
8: 'space-x-8',
|
||||
};
|
||||
|
||||
interface IHStack extends Pick<React.HTMLAttributes<HTMLDivElement>, 'onClick'> {
|
||||
interface IHStack extends Pick<React.HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'onClick' | 'style' | 'title'> {
|
||||
/** Vertical alignment of children. */
|
||||
alignItems?: keyof typeof alignItemsOptions;
|
||||
/** Extra class names on the <div> element. */
|
||||
className?: string;
|
||||
/** Children */
|
||||
children?: React.ReactNode;
|
||||
/** Horizontal alignment of children. */
|
||||
justifyContent?: keyof typeof justifyContentOptions;
|
||||
/** Size of the gap between elements. */
|
||||
|
@ -46,8 +42,6 @@ interface IHStack extends Pick<React.HTMLAttributes<HTMLDivElement>, 'onClick'>
|
|||
grow?: boolean;
|
||||
/** HTML element to use for container. */
|
||||
element?: keyof JSX.IntrinsicElements;
|
||||
/** Extra CSS styles for the <div> */
|
||||
style?: React.CSSProperties;
|
||||
/** Whether to let the flexbox wrap onto multiple lines. */
|
||||
wrap?: boolean;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ const alignItemsOptions = {
|
|||
interface IStack extends React.HTMLAttributes<HTMLDivElement> {
|
||||
/** Horizontal alignment of children. */
|
||||
alignItems?: keyof typeof alignItemsOptions;
|
||||
/** Extra class names on the element. */
|
||||
className?: string;
|
||||
/** Vertical alignment of children. */
|
||||
justifyContent?: keyof typeof justifyContentOptions;
|
||||
/** Size of the gap between elements. */
|
||||
|
|
|
@ -3,6 +3,7 @@ import type * as Schemas from 'soapbox/schemas';
|
|||
enum Entities {
|
||||
ACCOUNTS = 'Accounts',
|
||||
BOOKMARK_FOLDERS = 'BookmarkFolders',
|
||||
DOMAINS = 'Domains',
|
||||
GROUPS = 'Groups',
|
||||
GROUP_MEMBERSHIPS = 'GroupMemberships',
|
||||
GROUP_MUTES = 'GroupMutes',
|
||||
|
@ -16,6 +17,7 @@ enum Entities {
|
|||
interface EntityTypes {
|
||||
[Entities.ACCOUNTS]: Schemas.Account;
|
||||
[Entities.BOOKMARK_FOLDERS]: Schemas.BookmarkFolder;
|
||||
[Entities.DOMAINS]: Schemas.Domain;
|
||||
[Entities.GROUPS]: Schemas.Group;
|
||||
[Entities.GROUP_MEMBERSHIPS]: Schemas.GroupMember;
|
||||
[Entities.GROUP_RELATIONSHIPS]: Schemas.GroupRelationship;
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
import React from 'react';
|
||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { openModal } from 'soapbox/actions/modals';
|
||||
import { useDeleteDomain, useDomains } from 'soapbox/api/hooks/admin';
|
||||
import { dateFormatOptions } from 'soapbox/components/relative-timestamp';
|
||||
import ScrollableList from 'soapbox/components/scrollable-list';
|
||||
import { Button, Column, HStack, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
import Indicator from '../developers/components/indicator';
|
||||
|
||||
import type { Domain as DomainEntity } from 'soapbox/schemas';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.admin.domains', defaultMessage: 'Domains' },
|
||||
deleteConfirm: { id: 'confirmations.admin.delete_domain.confirm', defaultMessage: 'Delete' },
|
||||
deleteHeading: { id: 'confirmations.admin.delete_domain.heading', defaultMessage: 'Delete domain' },
|
||||
deleteMessage: { id: 'confirmations.admin.delete_domain.message', defaultMessage: 'Are you sure you want to delete the domain?' },
|
||||
domainDeleteSuccess: { id: 'admin.edit_domain.deleted', defaultMessage: 'Domain deleted' },
|
||||
domainLastChecked: { id: 'admin.domains.resolve.last_checked', defaultMessage: 'Last checked: {date}' },
|
||||
});
|
||||
|
||||
interface IDomain {
|
||||
domain: DomainEntity;
|
||||
}
|
||||
|
||||
const Domain: React.FC<IDomain> = ({ domain }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const { mutate: deleteDomain } = useDeleteDomain();
|
||||
const { refetch } = useDomains();
|
||||
|
||||
const handleEditDomain = (domain: DomainEntity) => () => {
|
||||
dispatch(openModal('EDIT_DOMAIN', { domainId: domain.id }));
|
||||
};
|
||||
|
||||
const handleDeleteDomain = (id: string) => () => {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
heading: intl.formatMessage(messages.deleteHeading),
|
||||
message: intl.formatMessage(messages.deleteMessage),
|
||||
confirm: intl.formatMessage(messages.deleteConfirm),
|
||||
onConfirm: () => {
|
||||
deleteDomain(domain.id).then(() => {
|
||||
toast.success(messages.domainDeleteSuccess);
|
||||
refetch();
|
||||
}).catch(() => {});
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
const domainState = domain.last_checked_at ? (domain.resolves ? 'active' : 'error') : 'pending';
|
||||
const domainStateLabel = {
|
||||
active: <FormattedMessage id='admin.domains.resolve.success_label' defaultMessage='Resolves correctly' />,
|
||||
error: <FormattedMessage id='admin.domains.resolve.fail_label' defaultMessage='Not resolving' />,
|
||||
pending: <FormattedMessage id='admin.domains.resolve.pending_label' defaultMessage='Pending resolve check' />,
|
||||
}[domainState];
|
||||
const domainStateTitle = domain.last_checked_at ? intl.formatMessage(messages.domainLastChecked, {
|
||||
date: intl.formatDate(domain.last_checked_at, dateFormatOptions),
|
||||
}) : undefined;
|
||||
|
||||
return (
|
||||
<div key={domain.id} className='rounded-lg bg-gray-100 p-4 dark:bg-primary-800'>
|
||||
<Stack space={2}>
|
||||
<HStack alignItems='center' space={4} wrap>
|
||||
<Text size='sm'>
|
||||
<Text tag='span' size='sm' weight='medium'>
|
||||
<FormattedMessage id='admin.domains.name' defaultMessage='Domain:' />
|
||||
</Text>
|
||||
{' '}
|
||||
{domain.domain}
|
||||
</Text>
|
||||
<Text tag='span' size='sm' weight='medium'>
|
||||
{domain.public ? (
|
||||
<FormattedMessage id='admin.domains.public' defaultMessage='Public' />
|
||||
) : (
|
||||
<FormattedMessage id='admin.domains.private' defaultMessage='Private' />
|
||||
)}
|
||||
</Text>
|
||||
<HStack alignItems='center' space={2} title={domainStateTitle}>
|
||||
<Indicator state={domainState} />
|
||||
<Text tag='span' size='sm' weight='medium'>
|
||||
{domainStateLabel}
|
||||
</Text>
|
||||
</HStack>
|
||||
</HStack>
|
||||
<HStack justifyContent='end' space={2}>
|
||||
<Button theme='primary' onClick={handleEditDomain(domain)}>
|
||||
<FormattedMessage id='admin.domains.edit' defaultMessage='Edit' />
|
||||
</Button>
|
||||
<Button theme='primary' onClick={handleDeleteDomain(domain.id)}>
|
||||
<FormattedMessage id='admin.domains.delete' defaultMessage='Delete' />
|
||||
</Button>
|
||||
</HStack>
|
||||
</Stack>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Domains: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const { data: domains, isFetching } = useDomains();
|
||||
|
||||
const handleCreateDomain = () => {
|
||||
dispatch(openModal('EDIT_DOMAIN'));
|
||||
};
|
||||
|
||||
const emptyMessage = <FormattedMessage id='empty_column.admin.domains' defaultMessage='There are no domains yet.' />;
|
||||
|
||||
return (
|
||||
<Column label={intl.formatMessage(messages.heading)}>
|
||||
<Stack className='gap-4'>
|
||||
<Button
|
||||
className='sm:w-fit sm:self-end'
|
||||
icon={require('@tabler/icons/plus.svg')}
|
||||
onClick={handleCreateDomain}
|
||||
theme='secondary'
|
||||
block
|
||||
>
|
||||
<FormattedMessage id='admin.domains.action' defaultMessage='Create domain' />
|
||||
</Button>
|
||||
{domains && (
|
||||
<ScrollableList
|
||||
scrollKey='domains'
|
||||
emptyMessage={emptyMessage}
|
||||
itemClassName='py-3 first:pt-0 last:pb-0'
|
||||
isLoading={isFetching}
|
||||
showLoading={isFetching && !domains?.length}
|
||||
>
|
||||
{domains.map((domain) => (
|
||||
<Domain key={domain.id} domain={domain} />
|
||||
))}
|
||||
</ScrollableList>
|
||||
)}
|
||||
</Stack>
|
||||
</Column>
|
||||
);
|
||||
};
|
||||
|
||||
export default Domains;
|
|
@ -93,12 +93,19 @@ const Dashboard: React.FC = () => {
|
|||
label={<FormattedMessage id='column.admin.moderation_log' defaultMessage='Moderation Log' />}
|
||||
/>
|
||||
|
||||
{features.announcements && (
|
||||
{features.adminAnnouncements && (
|
||||
<ListItem
|
||||
to='/soapbox/admin/announcements'
|
||||
label={<FormattedMessage id='column.admin.announcements' defaultMessage='Announcements' />}
|
||||
/>
|
||||
)}
|
||||
|
||||
{features.domains && (
|
||||
<ListItem
|
||||
to='/soapbox/admin/domains'
|
||||
label={<FormattedMessage id='column.admin.domains' defaultMessage='Domains' />}
|
||||
/>
|
||||
)}
|
||||
</List>
|
||||
|
||||
{account.admin && (
|
||||
|
|
|
@ -10,7 +10,7 @@ import { accountLookup } from 'soapbox/actions/accounts';
|
|||
import { register, verifyCredentials } from 'soapbox/actions/auth';
|
||||
import { openModal } from 'soapbox/actions/modals';
|
||||
import BirthdayInput from 'soapbox/components/birthday-input';
|
||||
import { Checkbox, Form, FormGroup, FormActions, Button, Input, Textarea } from 'soapbox/components/ui';
|
||||
import { Checkbox, Form, FormGroup, FormActions, Button, Input, Textarea, Select } from 'soapbox/components/ui';
|
||||
import CaptchaField from 'soapbox/features/auth-login/components/captcha';
|
||||
import { useAppDispatch, useSettings, useFeatures, useInstance } from 'soapbox/hooks';
|
||||
|
||||
|
@ -50,6 +50,7 @@ const RegistrationForm: React.FC<IRegistrationForm> = ({ inviteToken }) => {
|
|||
const supportsEmailList = features.emailList;
|
||||
const supportsAccountLookup = features.accountLookup;
|
||||
const birthdayRequired = instance.pleroma.metadata.birthday_required;
|
||||
const domains = instance.pleroma.metadata.multitenancy.enabled ? instance.pleroma.metadata.multitenancy.domains!.filter((domain) => domain.public) : undefined;
|
||||
|
||||
const [captchaLoading, setCaptchaLoading] = useState(true);
|
||||
const [submissionLoading, setSubmissionLoading] = useState(false);
|
||||
|
@ -80,7 +81,19 @@ const RegistrationForm: React.FC<IRegistrationForm> = ({ inviteToken }) => {
|
|||
setUsernameUnavailable(false);
|
||||
source.current.cancel();
|
||||
|
||||
usernameAvailable(e.target.value);
|
||||
const domain = params.get('domain');
|
||||
usernameAvailable(e.target.value, domain ? domains!.find(({ id }) => id === domain)?.domain : undefined);
|
||||
};
|
||||
|
||||
const onDomainChange: React.ChangeEventHandler<HTMLSelectElement> = e => {
|
||||
updateParams({ domain: e.target.value || null });
|
||||
setUsernameUnavailable(false);
|
||||
source.current.cancel();
|
||||
|
||||
const username = params.get('username');
|
||||
if (username) {
|
||||
usernameAvailable(username, domains!.find(({ id }) => id === e.target.value)?.domain);
|
||||
}
|
||||
};
|
||||
|
||||
const onCheckboxChange: React.ChangeEventHandler<HTMLInputElement> = e => {
|
||||
|
@ -155,12 +168,12 @@ const RegistrationForm: React.FC<IRegistrationForm> = ({ inviteToken }) => {
|
|||
return params.get('password', '') === passwordConfirmation;
|
||||
};
|
||||
|
||||
const usernameAvailable = useCallback(debounce(username => {
|
||||
const usernameAvailable = useCallback(debounce((username, domain?: string) => {
|
||||
if (!supportsAccountLookup) return;
|
||||
|
||||
const source = refreshCancelToken();
|
||||
|
||||
dispatch(accountLookup(username, source.token))
|
||||
dispatch(accountLookup(`${username}${domain ? `@${domain}` : ''}`, source.token))
|
||||
.then(account => {
|
||||
setUsernameUnavailable(!!account);
|
||||
})
|
||||
|
@ -244,6 +257,20 @@ const RegistrationForm: React.FC<IRegistrationForm> = ({ inviteToken }) => {
|
|||
/>
|
||||
</FormGroup>
|
||||
|
||||
{domains && (
|
||||
<FormGroup>
|
||||
<Select
|
||||
onChange={onDomainChange}
|
||||
value={params.get('domain')}
|
||||
>
|
||||
{domains.map(({ id, domain }) => (
|
||||
<option key={id} value={id}>{domain}</option>
|
||||
))}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
|
||||
{!features.nostrSignup && (
|
||||
<Input
|
||||
type='email'
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
DislikesModal,
|
||||
EditAnnouncementModal,
|
||||
EditBookmarkFolderModal,
|
||||
EditDomainModal,
|
||||
EditFederationModal,
|
||||
EmbedModal,
|
||||
EventMapModal,
|
||||
|
@ -60,6 +61,7 @@ const MODAL_COMPONENTS: Record<string, React.LazyExoticComponent<any>> = {
|
|||
'DISLIKES': DislikesModal,
|
||||
'EDIT_ANNOUNCEMENT': EditAnnouncementModal,
|
||||
'EDIT_BOOKMARK_FOLDER': EditBookmarkFolderModal,
|
||||
'EDIT_DOMAIN': EditDomainModal,
|
||||
'EDIT_FEDERATION': EditFederationModal,
|
||||
'EMBED': EmbedModal,
|
||||
'EVENT_MAP': EventMapModal,
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
import React, { useState } from 'react';
|
||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { closeModal } from 'soapbox/actions/modals';
|
||||
import { useCreateDomain, useDomains, useUpdateDomain } from 'soapbox/api/hooks/admin';
|
||||
import { Form, FormGroup, HStack, Input, Modal, Stack, Text, Toggle } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import { Domain } from 'soapbox/schemas';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
save: { id: 'admin.edit_domain.save', defaultMessage: 'Save' },
|
||||
domainPlaceholder: { id: 'admin.edit_domain.fields.domain_placeholder', defaultMessage: 'Identity domain name' },
|
||||
domainCreateSuccess: { id: 'admin.edit_domain.created', defaultMessage: 'Domain created' },
|
||||
domainUpdateSuccess: { id: 'admin.edit_domain.updated', defaultMessage: 'Domain edited' },
|
||||
});
|
||||
|
||||
interface IEditDomainModal {
|
||||
onClose: (type?: string) => void;
|
||||
domainId?: string;
|
||||
}
|
||||
|
||||
const EditDomainModal: React.FC<IEditDomainModal> = ({ onClose, domainId }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const intl = useIntl();
|
||||
|
||||
const { data: domains, refetch } = useDomains();
|
||||
const { createDomain, isSubmitting: isCreating } = useCreateDomain();
|
||||
const { updateDomain, isSubmitting: isUpdating } = useUpdateDomain(domainId!);
|
||||
|
||||
const [domain] = useState<Domain | null>(domainId ? domains!.find(({ id }) => domainId === id)! : null);
|
||||
const [domainName, setDomainName] = useState(domain?.domain || '');
|
||||
const [isPublic, setPublic] = useState(domain?.public || false);
|
||||
|
||||
const onClickClose = () => {
|
||||
onClose('EDIT_DOMAIN');
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (domainId) {
|
||||
updateDomain({
|
||||
public: isPublic,
|
||||
}).then(() => {
|
||||
toast.success(messages.domainUpdateSuccess);
|
||||
dispatch(closeModal('EDIT_DOMAIN'));
|
||||
refetch();
|
||||
}).catch(() => {});
|
||||
} else {
|
||||
createDomain({
|
||||
domain: domainName,
|
||||
public: isPublic,
|
||||
}).then(() => {
|
||||
toast.success(messages.domainCreateSuccess);
|
||||
dispatch(closeModal('EDIT_DOMAIN'));
|
||||
refetch();
|
||||
}).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onClose={onClickClose}
|
||||
title={domainId
|
||||
? <FormattedMessage id='column.admin.edit_domain' defaultMessage='Edit domain' />
|
||||
: <FormattedMessage id='column.admin.create_domain' defaultMessage='Create domaian' />}
|
||||
confirmationAction={handleSubmit}
|
||||
confirmationText={intl.formatMessage(messages.save)}
|
||||
confirmationDisabled={isCreating || isUpdating}
|
||||
>
|
||||
<Form>
|
||||
<FormGroup
|
||||
labelText={<FormattedMessage id='admin.edit_domain.fields.domain_label' defaultMessage='Domain' />}
|
||||
>
|
||||
<Input
|
||||
autoComplete='off'
|
||||
placeholder={intl.formatMessage(messages.domainPlaceholder)}
|
||||
value={domainName}
|
||||
onChange={({ target }) => setDomainName(target.value)}
|
||||
disabled={!!domainId}
|
||||
/>
|
||||
</FormGroup>
|
||||
<HStack alignItems='center' space={2}>
|
||||
<Toggle
|
||||
checked={isPublic}
|
||||
onChange={({ target }) => setPublic(target.checked)}
|
||||
/>
|
||||
<Stack>
|
||||
<Text tag='span' theme='muted'>
|
||||
<FormattedMessage id='admin.edit_domain.fields.public_label' defaultMessage='Public' />
|
||||
</Text>
|
||||
<Text size='xs' tag='span' theme='muted'>
|
||||
<FormattedMessage id='admin.edit_domain.fields.all_day_hint' defaultMessage='When checked, everyone can sign up for an username with this domain' />
|
||||
</Text>
|
||||
</Stack>
|
||||
</HStack>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default EditDomainModal;
|
|
@ -137,6 +137,7 @@ import {
|
|||
ExternalLogin,
|
||||
LandingTimeline,
|
||||
BookmarkFolders,
|
||||
Domains,
|
||||
} from './util/async-components';
|
||||
import GlobalHotkeys from './util/global-hotkeys';
|
||||
import { WrappedRoute } from './util/react-router-helpers';
|
||||
|
@ -324,7 +325,8 @@ const SwitchingColumnsArea: React.FC<ISwitchingColumnsArea> = ({ children }) =>
|
|||
<WrappedRoute path='/soapbox/admin/log' staffOnly page={AdminPage} component={ModerationLog} content={children} exact />
|
||||
<WrappedRoute path='/soapbox/admin/users' staffOnly page={AdminPage} component={UserIndex} content={children} exact />
|
||||
<WrappedRoute path='/soapbox/admin/theme' staffOnly page={AdminPage} component={ThemeEditor} content={children} exact />
|
||||
<WrappedRoute path='/soapbox/admin/announcements' staffOnly page={AdminPage} component={Announcements} content={children} exact />
|
||||
{features.adminAnnouncements && <WrappedRoute path='/soapbox/admin/announcements' staffOnly page={AdminPage} component={Announcements} content={children} exact />}
|
||||
{features.domains && <WrappedRoute path='/soapbox/admin/domains' staffOnly page={AdminPage} component={Domains} content={children} exact />}
|
||||
<WrappedRoute path='/info' page={EmptyPage} component={ServerInfo} content={children} />
|
||||
|
||||
<WrappedRoute path='/developers/apps/create' developerOnly page={DefaultPage} component={CreateApp} content={children} />
|
||||
|
|
|
@ -167,3 +167,5 @@ export const NostrLoginModal = lazy(() => import('soapbox/features/ui/components
|
|||
export const BookmarkFolders = lazy(() => import('soapbox/features/bookmark-folders'));
|
||||
export const EditBookmarkFolderModal = lazy(() => import('soapbox/features/ui/components/modals/edit-bookmark-folder-modal'));
|
||||
export const SelectBookmarkFolderModal = lazy(() => import('soapbox/features/ui/components/modals/select-bookmark-folder-modal'));
|
||||
export const Domains = lazy(() => import('soapbox/features/admin/domains'));
|
||||
export const EditDomainModal = lazy(() => import('soapbox/features/ui/components/modals/edit-domain-modal'));
|
||||
|
|
|
@ -105,6 +105,16 @@
|
|||
"admin.dashcounters.user_count_label": "total users",
|
||||
"admin.dashwidgets.email_list_header": "Email list",
|
||||
"admin.dashwidgets.software_header": "Software",
|
||||
"admin.domains.action": "Create domain",
|
||||
"admin.domains.delete": "Delete",
|
||||
"admin.domains.edit": "Edit",
|
||||
"admin.domains.name": "Domain:",
|
||||
"admin.domains.private": "Private",
|
||||
"admin.domains.public": "Public",
|
||||
"admin.domains.resolve.fail_label": "Not resolving",
|
||||
"admin.domains.resolve.last_checked": "Last checked: {date}",
|
||||
"admin.domains.resolve.pending_label": "Pending resolve check",
|
||||
"admin.domains.resolve.success_label": "Resolves correctly",
|
||||
"admin.edit_announcement.created": "Announcement created",
|
||||
"admin.edit_announcement.deleted": "Announcement deleted",
|
||||
"admin.edit_announcement.fields.all_day_hint": "When checked, only the dates of the time range will be displayed",
|
||||
|
@ -117,6 +127,14 @@
|
|||
"admin.edit_announcement.fields.start_time_placeholder": "Announcement starts on:",
|
||||
"admin.edit_announcement.save": "Save",
|
||||
"admin.edit_announcement.updated": "Announcement edited",
|
||||
"admin.edit_domain.created": "Domain created",
|
||||
"admin.edit_domain.deleted": "Domain deleted",
|
||||
"admin.edit_domain.fields.all_day_hint": "When checked, everyone can sign up for an username with this domain",
|
||||
"admin.edit_domain.fields.domain_label": "Domain",
|
||||
"admin.edit_domain.fields.domain_placeholder": "Identity domain name",
|
||||
"admin.edit_domain.fields.public_label": "Public",
|
||||
"admin.edit_domain.save": "Save",
|
||||
"admin.edit_domain.updated": "Domain edited",
|
||||
"admin.latest_accounts_panel.more": "Click to see {count, plural, one {# account} other {# accounts}}",
|
||||
"admin.latest_accounts_panel.title": "Latest Accounts",
|
||||
"admin.moderation_log.empty_message": "You have not performed any moderation actions yet. When you do, a history will be shown here.",
|
||||
|
@ -292,8 +310,11 @@
|
|||
"column.admin.announcements": "Announcements",
|
||||
"column.admin.awaiting_approval": "Awaiting Approval",
|
||||
"column.admin.create_announcement": "Create announcement",
|
||||
"column.admin.create_domain": "Create domaian",
|
||||
"column.admin.dashboard": "Dashboard",
|
||||
"column.admin.domains": "Domains",
|
||||
"column.admin.edit_announcement": "Edit announcement",
|
||||
"column.admin.edit_domain": "Edit domain",
|
||||
"column.admin.moderation_log": "Moderation Log",
|
||||
"column.admin.reports": "Reports",
|
||||
"column.admin.reports.menu.moderation_log": "Moderation Log",
|
||||
|
@ -459,6 +480,9 @@
|
|||
"confirmations.admin.delete_announcement.confirm": "Delete",
|
||||
"confirmations.admin.delete_announcement.heading": "Delete announcement",
|
||||
"confirmations.admin.delete_announcement.message": "Are you sure you want to delete the announcement?",
|
||||
"confirmations.admin.delete_domain.confirm": "Delete",
|
||||
"confirmations.admin.delete_domain.heading": "Delete domain",
|
||||
"confirmations.admin.delete_domain.message": "Are you sure you want to delete the domain?",
|
||||
"confirmations.admin.delete_local_user.checkbox": "I understand that I am about to delete a local user.",
|
||||
"confirmations.admin.delete_status.confirm": "Delete post",
|
||||
"confirmations.admin.delete_status.heading": "Delete post",
|
||||
|
@ -654,6 +678,7 @@
|
|||
"empty_column.account_timeline": "No posts here!",
|
||||
"empty_column.account_unavailable": "Profile unavailable",
|
||||
"empty_column.admin.announcements": "There are no announcements yet.",
|
||||
"empty_column.admin.domains": "There are no domains yet.",
|
||||
"empty_column.aliases": "You haven't created any account alias yet.",
|
||||
"empty_column.aliases.suggestions": "There are no account suggestions available for the provided term.",
|
||||
"empty_column.blocks": "You haven't blocked any users yet.",
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import z from 'zod';
|
||||
|
||||
const domainSchema = z.object({
|
||||
id: z.coerce.string(),
|
||||
domain: z.string().catch(''),
|
||||
public: z.boolean().catch(false),
|
||||
resolves: z.boolean().catch(false),
|
||||
last_checked_at: z.string().datetime().catch(''),
|
||||
});
|
||||
|
||||
type Domain = z.infer<typeof domainSchema>
|
||||
|
||||
export { domainSchema, type Domain };
|
|
@ -4,6 +4,7 @@ export { bookmarkFolderSchema, type BookmarkFolder } from './bookmark-folder';
|
|||
export { cardSchema, type Card } from './card';
|
||||
export { chatMessageSchema, type ChatMessage } from './chat-message';
|
||||
export { customEmojiSchema, type CustomEmoji } from './custom-emoji';
|
||||
export { domainSchema, type Domain } from './domain';
|
||||
export { emojiReactionSchema, type EmojiReaction } from './emoji-reaction';
|
||||
export { groupSchema, type Group } from './group';
|
||||
export { groupMemberSchema, type GroupMember } from './group-member';
|
||||
|
|
|
@ -98,6 +98,18 @@ const pleromaSchema = coerceObject({
|
|||
value_length: z.number().nonnegative().catch(2047),
|
||||
}),
|
||||
migration_cooldown_period: z.number().optional().catch(undefined),
|
||||
multitenancy: coerceObject({
|
||||
domains: z
|
||||
.array(
|
||||
z.object({
|
||||
domain: z.coerce.string(),
|
||||
id: z.string(),
|
||||
public: z.boolean().catch(false),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
enabled: z.boolean().catch(false),
|
||||
}),
|
||||
restrict_unauthenticated: coerceObject({
|
||||
activities: coerceObject({
|
||||
local: z.boolean().catch(false),
|
||||
|
|
|
@ -186,6 +186,17 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
*/
|
||||
accountWebsite: v.software === TRUTHSOCIAL,
|
||||
|
||||
/**
|
||||
* Ability to manage announcements by admins.
|
||||
* @see GET /api/v1/pleroma/admin/announcements
|
||||
* @see GET /api/v1/pleroma/admin/announcements/:id
|
||||
* @see POST /api/v1/pleroma/admin/announcements
|
||||
* @see PATCH /api/v1/pleroma/admin/announcements/:id
|
||||
* @see DELETE /api/v1/pleroma/admin/announcements/:id
|
||||
* @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminannouncements}
|
||||
*/
|
||||
adminAnnouncements: v.software === PLEROMA && gte(v.version, '2.2.49'),
|
||||
|
||||
/**
|
||||
* An additional moderator interface is available on the domain.
|
||||
* @see /pleroma/admin
|
||||
|
@ -372,6 +383,15 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
*/
|
||||
dislikes: v.software === FRIENDICA && gte(v.version, '2023.3.0'),
|
||||
|
||||
/**
|
||||
* Allow to register on a given domain
|
||||
* @see GET /api/v1/pleroma/admin/domains
|
||||
* @see POST /api/v1/pleroma/admin/domains
|
||||
* @see PATCH /api/v1/pleroma/admin/domains/:id
|
||||
* @see DELETE /api/v1/pleroma/admin/domains/:id
|
||||
*/
|
||||
domains: instance.pleroma.metadata.multitenancy.enabled,
|
||||
|
||||
/**
|
||||
* Ability to edit profile information.
|
||||
* @see PATCH /api/v1/accounts/update_credentials
|
||||
|
|
Loading…
Reference in New Issue