snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
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 1s
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 1s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import type { IRole, IPermission } from '@rocket.chat/core-typings';
|
||||
import { useStableCallback } from '@rocket.chat/fuselage-hooks';
|
||||
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
|
||||
|
||||
export const useChangeRole = ({
|
||||
onGrant,
|
||||
onRemove,
|
||||
permissionId,
|
||||
}: {
|
||||
onGrant: (permissionId: IPermission['_id'], roleId: IRole['_id']) => Promise<void>;
|
||||
onRemove: (permissionId: IPermission['_id'], roleId: IRole['_id']) => Promise<void>;
|
||||
permissionId: IPermission['_id'];
|
||||
}): ((roleId: IRole['_id'], granted: boolean) => Promise<boolean>) => {
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
return useStableCallback(async (roleId: IRole['_id'], granted: boolean) => {
|
||||
try {
|
||||
if (granted) {
|
||||
await onRemove(permissionId, roleId);
|
||||
} else {
|
||||
await onGrant(permissionId, roleId);
|
||||
}
|
||||
return !granted;
|
||||
} catch (error: unknown) {
|
||||
dispatchToastMessage({ type: 'error', message: error });
|
||||
}
|
||||
return granted;
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Permissions } from '../../../../stores';
|
||||
import { filterPermissionKeys, mapPermissionKeys } from '../helpers/mapPermissionKeys';
|
||||
|
||||
export const useFilteredPermissions = ({ filter }: { filter: string }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const mappedPermissionKeys = useMemo(() => {
|
||||
const permissions = Array.from(Permissions.state.records.values());
|
||||
return mapPermissionKeys({ t, permissions });
|
||||
}, [t]);
|
||||
|
||||
const debouncedFilter = useDebouncedValue(filter, 400);
|
||||
|
||||
return useMemo(() => {
|
||||
return filterPermissionKeys(mappedPermissionKeys, debouncedFilter);
|
||||
}, [debouncedFilter, mappedPermissionKeys]);
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { IRole, IPermission } from '@rocket.chat/core-typings';
|
||||
import { useCallback } from 'react';
|
||||
import { useShallow } from 'zustand/shallow';
|
||||
|
||||
import { useFilteredPermissions } from './useFilteredPermissions';
|
||||
import { CONSTANTS } from '../../../../../app/authorization/lib';
|
||||
import { pipe } from '../../../../lib/cachedStores/pipe';
|
||||
import { Permissions, Roles } from '../../../../stores';
|
||||
|
||||
export const usePermissionsAndRoles = (
|
||||
type = 'permissions',
|
||||
filter = '',
|
||||
limit = 25,
|
||||
skip = 0,
|
||||
): { permissions: IPermission[]; total: number; roleList: IRole[] } => {
|
||||
const filteredIds = useFilteredPermissions({ filter });
|
||||
|
||||
const predicate = useCallback(
|
||||
(record: IPermission): boolean => {
|
||||
if (type === 'permissions') {
|
||||
return record.level !== CONSTANTS.SETTINGS_LEVEL && filteredIds.includes(record._id);
|
||||
}
|
||||
return record.level === CONSTANTS.SETTINGS_LEVEL && filteredIds.includes(record._id);
|
||||
},
|
||||
[filteredIds, type],
|
||||
);
|
||||
|
||||
const { apply: transform } = pipe<IPermission>().sortByField('_id', 1).slice(skip, limit);
|
||||
const permissions = Permissions.use(useShallow((state) => transform(state.filter(predicate))));
|
||||
const permissionsTotal = Permissions.use(useShallow((state) => state.count(predicate)));
|
||||
|
||||
const roleList = Roles.use(useShallow((state) => Array.from(state.records.values())));
|
||||
|
||||
return { permissions, total: permissionsTotal, roleList };
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { IRole } from '@rocket.chat/core-typings';
|
||||
|
||||
import { Roles } from '../../../../stores';
|
||||
|
||||
export const useRole = (_id?: IRole['_id']) => Roles.use((state) => (_id ? state.get(_id) : undefined));
|
||||
Reference in New Issue
Block a user