Files
upstream-mirror 30810eecd7
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

116 lines
4.3 KiB
TypeScript

import { Box, Button, ButtonGroup, Callout } from '@rocket.chat/fuselage';
import { useStableCallback } from '@rocket.chat/fuselage-hooks';
import { ContextualbarDialog, Page, PageContent, PageHeader } from '@rocket.chat/ui-client';
import { useSetting, useRouteParameter, useRouter } from '@rocket.chat/ui-contexts';
import { Trans, useTranslation } from 'react-i18next';
import AttributesContextualBar from './ABACAttributesTab/AttributesContextualBar';
import AttributesContextualBarWithData from './ABACAttributesTab/AttributesContextualBarWithData';
import AttributesPage from './ABACAttributesTab/AttributesPage';
import LogsPage from './ABACLogsTab/LogsPage';
import RoomsContextualBar from './ABACRoomsTab/RoomsContextualBar';
import RoomsContextualBarWithData from './ABACRoomsTab/RoomsContextualBarWithData';
import RoomsPage from './ABACRoomsTab/RoomsPage';
import SettingsPage from './ABACSettingTab/SettingsPage';
import AdminABACTabs from './AdminABACTabs';
import { useABACTabPermissions } from './hooks/useABACTabPermissions';
import { useIsABACAvailable } from './hooks/useIsABACAvailable';
import { useExternalLink } from '../../../hooks/useExternalLink';
import { useLdapSync } from '../../../hooks/useLdapSync';
import { links } from '../../../lib/links';
export type AdminABACPageProps = {
shouldShowWarning: boolean;
};
const AdminABACPage = ({ shouldShowWarning }: AdminABACPageProps) => {
const { t } = useTranslation();
const router = useRouter();
const tab = useRouteParameter('tab');
const _id = useRouteParameter('id');
const context = useRouteParameter('context');
const learnMore = useExternalLink();
const isABACAvailable = useIsABACAvailable();
const ldapEnabled = useSetting('LDAP_Enable');
const abacEnabled = useSetting('ABAC_Enabled');
const handleSyncNow = useLdapSync();
const isSyncDisabled = !ldapEnabled || !abacEnabled;
const tabPermissions = useABACTabPermissions();
const handleCloseContextualbar = useStableCallback((): void => {
if (!context) {
return;
}
router.navigate(
{
name: 'admin-ABAC',
params: { ...router.getRouteParameters(), context: '', id: '' },
},
{ replace: true },
);
});
return (
<Page flexDirection='row'>
<Page>
<PageHeader title={t('ABAC')}>
<ButtonGroup>
<Button
disabled={isSyncDisabled}
title={isSyncDisabled ? t('Enable_ABAC_and_LDAP_to_sync') : undefined}
onClick={handleSyncNow}
>
{t('LDAP_Sync_Now')}
</Button>
<Button icon='new-window' secondary onClick={() => learnMore(links.go.abacDocs)}>
{t('ABAC_Learn_More')}
</Button>
</ButtonGroup>
</PageHeader>
{shouldShowWarning && (
<Box marginInline={24} marginBlock={16}>
<Callout type='warning' title={t('ABAC_automatically_disabled_callout')}>
<Trans
i18nKey='ABAC_automatically_disabled_callout_description'
components={{
1: (
<a href={links.go.abacDocs} rel='noopener noreferrer' target='_blank'>
ABAC capabilities without restriction.
</a>
),
}}
/>
</Callout>
</Box>
)}
<AdminABACTabs />
<PageContent>
{tab === 'settings' && tabPermissions.settings && <SettingsPage />}
{tab === 'room-attributes' && tabPermissions['room-attributes'] && <AttributesPage />}
{tab === 'rooms' && tabPermissions.rooms && <RoomsPage />}
{tab === 'logs' && tabPermissions.logs && <LogsPage />}
</PageContent>
</Page>
{isABACAvailable === true && tab !== undefined && context !== undefined && (
<ContextualbarDialog onClose={() => handleCloseContextualbar()}>
{tab === 'room-attributes' && tabPermissions['room-attributes'] && (
<>
{context === 'new' && <AttributesContextualBar onClose={() => handleCloseContextualbar()} />}
{context === 'edit' && _id && <AttributesContextualBarWithData id={_id} onClose={() => handleCloseContextualbar()} />}
</>
)}
{tab === 'rooms' && tabPermissions.rooms && (
<>
{context === 'new' && <RoomsContextualBar onClose={() => handleCloseContextualbar()} />}
{context === 'edit' && _id && <RoomsContextualBarWithData id={_id} onClose={() => handleCloseContextualbar()} />}
</>
)}
</ContextualbarDialog>
)}
</Page>
);
};
export default AdminABACPage;