mirror of https://github.com/buster-so/buster.git
update permission groups
This commit is contained in:
parent
a3f71f6186
commit
d385ccd302
|
@ -240,7 +240,7 @@ export const useUpdateDatasetGroupPermissionGroups = () => {
|
||||||
mutationFn: updateDatasetGroupPermissionGroups,
|
mutationFn: updateDatasetGroupPermissionGroups,
|
||||||
onMutate: ({ data, datasetGroupId }) => {
|
onMutate: ({ data, datasetGroupId }) => {
|
||||||
queryClient.setQueryData(
|
queryClient.setQueryData(
|
||||||
queryKeys.datasetGroupsGetDatasets(datasetGroupId).queryKey,
|
queryKeys.datasetGroupsGetPermissionGroups(datasetGroupId).queryKey,
|
||||||
(oldData: GetDatasetGroupPermissionGroupsResponse[] | undefined) => {
|
(oldData: GetDatasetGroupPermissionGroupsResponse[] | undefined) => {
|
||||||
if (!oldData) return [];
|
if (!oldData) return [];
|
||||||
return oldData.map((permissionGroup) => {
|
return oldData.map((permissionGroup) => {
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const DatasetGroupAppSegments: React.FC<{
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-2">
|
<div className="flex flex-col space-y-2">
|
||||||
<AppSegmented value={value} options={options} />
|
<AppSegmented type="button" value={value} options={options} />
|
||||||
<Separator />
|
<Separator />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -46,7 +46,6 @@ export default function Page() {
|
||||||
<div className="">
|
<div className="">
|
||||||
<ListDatasetGroupsComponent datasetGroups={filteredItems} isFetched={isFetched} />
|
<ListDatasetGroupsComponent datasetGroups={filteredItems} isFetched={isFetched} />
|
||||||
</div>
|
</div>
|
||||||
z
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<NewDatasetGroupModal
|
<NewDatasetGroupModal
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const PermissionAppSegments: React.FC<{
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-2">
|
<div className="flex flex-col space-y-2">
|
||||||
<AppSegmented value={value} options={options} />
|
<AppSegmented type="button" value={value} options={options} />
|
||||||
<Separator />
|
<Separator />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,21 +3,15 @@ import { prefetchPermissionGroup } from '@/api/buster_rest';
|
||||||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||||
import { PermissionGroupIndividualLayout } from './_PermissionGroupIndividualLayout';
|
import { PermissionGroupIndividualLayout } from './_PermissionGroupIndividualLayout';
|
||||||
|
|
||||||
export default async function Layout(
|
export default async function Layout(props: {
|
||||||
props: {
|
children: React.ReactNode;
|
||||||
children: React.ReactNode;
|
params: Promise<{ permissionGroupId: string }>;
|
||||||
params: Promise<{ permissionGroupId: string }>;
|
}) {
|
||||||
}
|
|
||||||
) {
|
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
|
|
||||||
const {
|
const { permissionGroupId } = params;
|
||||||
permissionGroupId
|
|
||||||
} = params;
|
|
||||||
|
|
||||||
const {
|
const { children } = props;
|
||||||
children
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const queryClient = await prefetchPermissionGroup(permissionGroupId);
|
const queryClient = await prefetchPermissionGroup(permissionGroupId);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ export const ListUserItem = React.memo(({ name, email }: { name: string; email:
|
||||||
<Avatar size={24} name={name} />
|
<Avatar size={24} name={name} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col justify-center space-y-1">
|
<div className="flex flex-col justify-center space-y-0">
|
||||||
{name && <Text>{name}</Text>}
|
{name && <Text>{name}</Text>}
|
||||||
{email && (
|
{email && (
|
||||||
<Text variant="secondary" style={{ fontSize: 12 }}>
|
<Text variant="secondary" style={{ fontSize: 12 }}>
|
||||||
|
|
|
@ -63,7 +63,7 @@ const permissionAndSecurityItems: ISidebarGroup = {
|
||||||
|
|
||||||
export const SidebarSettings: React.FC<{}> = React.memo(({}) => {
|
export const SidebarSettings: React.FC<{}> = React.memo(({}) => {
|
||||||
const isAdmin = useUserConfigContextSelector((x) => x.isAdmin);
|
const isAdmin = useUserConfigContextSelector((x) => x.isAdmin);
|
||||||
const currentRoute = useAppLayoutContextSelector((x) => x.currentRoute);
|
const currentParentRoute = useAppLayoutContextSelector((x) => x.currentParentRoute);
|
||||||
|
|
||||||
const content = useMemo(() => {
|
const content = useMemo(() => {
|
||||||
const items = [accountItems];
|
const items = [accountItems];
|
||||||
|
@ -78,7 +78,7 @@ export const SidebarSettings: React.FC<{}> = React.memo(({}) => {
|
||||||
<Sidebar
|
<Sidebar
|
||||||
content={content}
|
content={content}
|
||||||
header={<SidebarSettingsHeader />}
|
header={<SidebarSettingsHeader />}
|
||||||
activeItem={currentRoute}
|
activeItem={currentParentRoute}
|
||||||
footer={<SidebarUserFooter />}
|
footer={<SidebarUserFooter />}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes';
|
import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes';
|
||||||
import { pathNameToRoute } from '@/routes/helpers';
|
import { pathNameToParentRoute, pathNameToRoute } from '@/routes/helpers';
|
||||||
import { useMemoizedFn, usePrevious } from '@/hooks';
|
import { useMemoizedFn } from '@/hooks';
|
||||||
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
import { useRouter, usePathname, useParams } from 'next/navigation';
|
||||||
import React, { PropsWithChildren } from 'react';
|
import React, { PropsWithChildren } from 'react';
|
||||||
import { createContext, useContextSelector } from 'use-context-selector';
|
import { createContext, useContextSelector } from 'use-context-selector';
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ export const useAppLayout = () => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const currentRoute = pathNameToRoute(pathname, params);
|
const currentRoute = pathNameToRoute(pathname, params);
|
||||||
|
const currentParentRoute = pathNameToParentRoute(pathname, params);
|
||||||
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
||||||
|
|
||||||
const onToggleInviteModal = useMemoizedFn((v?: boolean) => {
|
const onToggleInviteModal = useMemoizedFn((v?: boolean) => {
|
||||||
|
@ -57,7 +58,8 @@ export const useAppLayout = () => {
|
||||||
currentRoute,
|
currentRoute,
|
||||||
onToggleInviteModal,
|
onToggleInviteModal,
|
||||||
openInviteModal,
|
openInviteModal,
|
||||||
onChangePage
|
onChangePage,
|
||||||
|
currentParentRoute
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ const CollectionDeleteButton: React.FC<{
|
||||||
|
|
||||||
const onRemoveFromCollection = useMemoizedFn(async () => {
|
const onRemoveFromCollection = useMemoizedFn(async () => {
|
||||||
if (collection) {
|
if (collection) {
|
||||||
console.log(selectedRowKeys, collection);
|
|
||||||
await removeAssetFromCollection({
|
await removeAssetFromCollection({
|
||||||
id: collectionId,
|
id: collectionId,
|
||||||
assets: (collection.assets || [])?.reduce<{ type: 'metric' | 'dashboard'; id: string }[]>(
|
assets: (collection.assets || [])?.reduce<{ type: 'metric' | 'dashboard'; id: string }[]>(
|
||||||
|
|
|
@ -38,8 +38,6 @@ const options = PERMISSION_USERS_OPTIONS.map((v) => ({
|
||||||
icon: v.value === 'included' ? <CheckDouble /> : <Xmark />
|
icon: v.value === 'included' ? <CheckDouble /> : <Xmark />
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(options);
|
|
||||||
|
|
||||||
const PermissionUsersAssignButton: React.FC<{
|
const PermissionUsersAssignButton: React.FC<{
|
||||||
selectedRowKeys: string[];
|
selectedRowKeys: string[];
|
||||||
onSelectChange: (selectedRowKeys: string[]) => void;
|
onSelectChange: (selectedRowKeys: string[]) => void;
|
||||||
|
|
|
@ -21,9 +21,53 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes =>
|
||||||
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
[BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS,
|
[BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS,
|
[BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS
|
||||||
[BusterRoutes.SETTINGS_USERS_ID]: BusterRoutes.SETTINGS_USERS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (route && paramRoutesToParent[route as string]) {
|
||||||
|
return paramRoutesToParent[route as string];
|
||||||
|
}
|
||||||
|
|
||||||
|
return route || BusterRoutes.ROOT;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const pathNameToParentRoute = (pathName: string, params: any): BusterRoutes => {
|
||||||
|
const route = Object.values(BusterRoutes).find((r) => {
|
||||||
|
return r === pathName || createBusterRoute({ route: r, ...params }) === pathName;
|
||||||
|
});
|
||||||
|
|
||||||
|
const paramRoutesToParent: Record<string, BusterRoutes> = {
|
||||||
|
[BusterRoutes.APP_CHAT_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_DASHBOARD_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_METRIC_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_COLLECTION_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_REASONING_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_CHAT_ID_VALUE_ID]: BusterRoutes.APP_CHAT,
|
||||||
|
[BusterRoutes.APP_METRIC_ID]: BusterRoutes.APP_METRIC,
|
||||||
|
[BusterRoutes.APP_DASHBOARD_METRICS_ID]: BusterRoutes.APP_DASHBOARDS,
|
||||||
|
[BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
|
||||||
|
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
||||||
|
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
|
||||||
|
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
|
[BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
|
[BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS,
|
||||||
|
[BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS,
|
||||||
|
[BusterRoutes.SETTINGS_USERS_ID]: BusterRoutes.SETTINGS_USERS,
|
||||||
|
[BusterRoutes.SETTINGS_USERS_ID_DATASETS]: BusterRoutes.SETTINGS_USERS,
|
||||||
|
[BusterRoutes.SETTINGS_USERS_ID_PERMISSION_GROUPS]: BusterRoutes.SETTINGS_USERS,
|
||||||
|
[BusterRoutes.SETTINGS_USERS_ID_TEAMS]: BusterRoutes.SETTINGS_USERS,
|
||||||
|
[BusterRoutes.SETTINGS_USERS_ID_DATASET_GROUPS]: BusterRoutes.SETTINGS_USERS,
|
||||||
|
[BusterRoutes.SETTINGS_DATASET_GROUPS_ID_PERMISSION_GROUPS]:
|
||||||
|
BusterRoutes.SETTINGS_DATASET_GROUPS,
|
||||||
|
[BusterRoutes.SETTINGS_DATASET_GROUPS_ID_DATASETS]: BusterRoutes.SETTINGS_DATASET_GROUPS,
|
||||||
|
[BusterRoutes.SETTINGS_DATASET_GROUPS_ID_USERS]: BusterRoutes.SETTINGS_DATASET_GROUPS,
|
||||||
|
[BusterRoutes.SETTINGS_PERMISSION_GROUPS_ID_USERS]: BusterRoutes.SETTINGS_PERMISSION_GROUPS,
|
||||||
|
[BusterRoutes.SETTINGS_PERMISSION_GROUPS_ID_DATASET_GROUPS]:
|
||||||
|
BusterRoutes.SETTINGS_PERMISSION_GROUPS,
|
||||||
|
[BusterRoutes.SETTINGS_PERMISSION_GROUPS_ID_DATASETS]: BusterRoutes.SETTINGS_PERMISSION_GROUPS
|
||||||
|
};
|
||||||
|
|
||||||
if (route && paramRoutesToParent[route as string]) {
|
if (route && paramRoutesToParent[route as string]) {
|
||||||
return paramRoutesToParent[route as string];
|
return paramRoutesToParent[route as string];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue