feat: add integration access settings (#725)
* feat: add integration access settings * fix: typecheck and test issues * fix: test timeout * chore: address pull request feedback * chore: add throw if action forbidden for integration permissions * fix: unable to create new migrations because of duplicate prevId in sqlite snapshots * chore: add sqlite migration for integration permissions * test: add unit tests for integration access * test: add permission checks to integration router tests * test: add unit test for integration permissions * chore: add mysql migration * fix: format issues
This commit is contained in:
1 parent
be711149f7
commit
408cdeb5c3
50 files changed
+4392
-615
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { Stack, Table, TableTbody, TableTh, TableThead, TableTr } from "@mantine/core";
|
||||
|
||||
import type { GroupPermissionKey } from "@homarr/definitions";
|
||||
import { getPermissionsWithChildren } from "@homarr/definitions";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
|
||||
import type { AccessQueryData } from "./access-settings";
|
||||
import { AccessDisplayRow } from "./access-table-rows";
|
||||
import { GroupItemContent } from "./group-access-form";
|
||||
|
||||
export interface InheritTableProps<TPermission extends string> {
|
||||
accessQueryData: AccessQueryData<TPermission>;
|
||||
mapPermissions: Partial<Record<GroupPermissionKey, TPermission>>;
|
||||
fullAccessGroupPermission: GroupPermissionKey;
|
||||
}
|
||||
|
||||
export const InheritAccessTable = <TPermission extends string>({
|
||||
accessQueryData,
|
||||
mapPermissions,
|
||||
fullAccessGroupPermission,
|
||||
}: InheritTableProps<TPermission>) => {
|
||||
const tPermissions = useScopedI18n("permission");
|
||||
return (
|
||||
<Stack pt="sm">
|
||||
<Table>
|
||||
<TableThead>
|
||||
<TableTr>
|
||||
<TableTh>{tPermissions("field.user.label")}</TableTh>
|
||||
<TableTh>{tPermissions("field.permission.label")}</TableTh>
|
||||
</TableTr>
|
||||
</TableThead>
|
||||
<TableTbody>
|
||||
{accessQueryData.inherited.map(({ group, permission }) => {
|
||||
const entityPermission =
|
||||
permission in mapPermissions
|
||||
? mapPermissions[permission]
|
||||
: getPermissionsWithChildren([permission]).includes(fullAccessGroupPermission)
|
||||
? "full"
|
||||
: null;
|
||||
|
||||
if (!entityPermission) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AccessDisplayRow
|
||||
key={group.id}
|
||||
itemContent={<GroupItemContent group={group} />}
|
||||
permission={entityPermission}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</TableTbody>
|
||||
</Table>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user