pl-fe: admin dashboard support on non-pleroma backends
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
@ -33,7 +33,7 @@ const useAccount = (accountId?: string, opts: UseAccountOpts = {}) => {
|
||||
{ enabled: !!accountId, transform: normalizeAccount },
|
||||
);
|
||||
|
||||
const meta = useAppSelector((state) => accountId && state.accounts_meta[accountId]);
|
||||
const meta = useAppSelector((state) => accountId ? state.accounts_meta[accountId] : undefined);
|
||||
|
||||
const {
|
||||
relationship,
|
||||
@ -49,7 +49,14 @@ const useAccount = (accountId?: string, opts: UseAccountOpts = {}) => {
|
||||
const isUnavailable = (me === entity?.id) ? false : (isBlocked && !features.blockersVisible);
|
||||
|
||||
const account = useMemo(
|
||||
() => entity ? { ...entity, relationship, scrobble, __meta: { meta, ...entity.__meta } } : undefined,
|
||||
() => entity ? {
|
||||
...entity,
|
||||
relationship,
|
||||
scrobble,
|
||||
__meta: { meta, ...entity.__meta },
|
||||
// @ts-ignore
|
||||
is_admin: meta?.role ? (meta.role.permissions & 0x1) === 0x1 : entity.is_admin,
|
||||
} : undefined,
|
||||
[entity, relationship, scrobble],
|
||||
);
|
||||
|
||||
|
||||
@ -1000,7 +1000,7 @@ const MenuButton: React.FC<IMenuButton> = ({
|
||||
icon: require('@tabler/icons/outline/gavel.svg'),
|
||||
});
|
||||
|
||||
if (isAdmin) {
|
||||
if (isAdmin && features.pleromaAdminStatuses) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.admin_status),
|
||||
href: `/pleroma/admin/#/statuses/${status.id}/`,
|
||||
|
||||
@ -319,7 +319,7 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||
icon: require('@tabler/icons/outline/gavel.svg'),
|
||||
});
|
||||
|
||||
if (isAdmin) {
|
||||
if (isAdmin && features.pleromaAdminStatuses) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.adminStatus),
|
||||
action: handleModerateStatus,
|
||||
|
||||
@ -11,7 +11,9 @@ import type { Account, CredentialAccount } from 'pl-api';
|
||||
|
||||
interface AccountMeta {
|
||||
pleroma: Account['__meta']['pleroma'];
|
||||
source: Account['__meta']['source'];
|
||||
pleromaSource: Account['__meta']['source'];
|
||||
source?: CredentialAccount['source'];
|
||||
role?: CredentialAccount['role'];
|
||||
}
|
||||
|
||||
type State = Immutable<Record<string, AccountMeta | undefined>>;
|
||||
@ -22,7 +24,9 @@ const importAccount = (state: State, account: CredentialAccount): State =>
|
||||
|
||||
draft[account.id] = {
|
||||
pleroma: account.__meta.pleroma ?? existing?.pleroma,
|
||||
source: account.__meta.source ?? existing?.source,
|
||||
pleromaSource: account.__meta.source ?? existing?.pleromaSource,
|
||||
source: account.source ?? existing?.source,
|
||||
role: account.role ?? existing?.role,
|
||||
};
|
||||
}, { enableAutoFreeze: true });
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ const makeGetAccount = () => createSelector([
|
||||
...account,
|
||||
relationship,
|
||||
__meta: { meta, ...account.__meta },
|
||||
// @ts-ignore
|
||||
is_admin: meta?.role ? (meta.role.permissions & 0x1) === 0x1 : account.is_admin,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ const getInstanceScopes = (instance: Instance, admin: boolean = true) => {
|
||||
scopes = 'read write follow push write:bites';
|
||||
break;
|
||||
case PLEROMA:
|
||||
scopes = 'read write follow push admin';
|
||||
scopes = 'read write follow push';
|
||||
break;
|
||||
default:
|
||||
scopes = 'read write follow push';
|
||||
|
||||
Reference in New Issue
Block a user