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,
|
||||
onMutate: ({ data, datasetGroupId }) => {
|
||||
queryClient.setQueryData(
|
||||
queryKeys.datasetGroupsGetDatasets(datasetGroupId).queryKey,
|
||||
queryKeys.datasetGroupsGetPermissionGroups(datasetGroupId).queryKey,
|
||||
(oldData: GetDatasetGroupPermissionGroupsResponse[] | undefined) => {
|
||||
if (!oldData) return [];
|
||||
return oldData.map((permissionGroup) => {
|
||||
|
|
|
@ -59,7 +59,7 @@ export const DatasetGroupAppSegments: React.FC<{
|
|||
|
||||
return (
|
||||
<div className="flex flex-col space-y-2">
|
||||
<AppSegmented value={value} options={options} />
|
||||
<AppSegmented type="button" value={value} options={options} />
|
||||
<Separator />
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -46,7 +46,6 @@ export default function Page() {
|
|||
<div className="">
|
||||
<ListDatasetGroupsComponent datasetGroups={filteredItems} isFetched={isFetched} />
|
||||
</div>
|
||||
z
|
||||
</div>
|
||||
|
||||
<NewDatasetGroupModal
|
||||
|
|
|
@ -59,7 +59,7 @@ export const PermissionAppSegments: React.FC<{
|
|||
|
||||
return (
|
||||
<div className="flex flex-col space-y-2">
|
||||
<AppSegmented value={value} options={options} />
|
||||
<AppSegmented type="button" value={value} options={options} />
|
||||
<Separator />
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -3,21 +3,15 @@ import { prefetchPermissionGroup } from '@/api/buster_rest';
|
|||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||
import { PermissionGroupIndividualLayout } from './_PermissionGroupIndividualLayout';
|
||||
|
||||
export default async function Layout(
|
||||
props: {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ permissionGroupId: string }>;
|
||||
}
|
||||
) {
|
||||
export default async function Layout(props: {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ permissionGroupId: string }>;
|
||||
}) {
|
||||
const params = await props.params;
|
||||
|
||||
const {
|
||||
permissionGroupId
|
||||
} = params;
|
||||
const { permissionGroupId } = params;
|
||||
|
||||
const {
|
||||
children
|
||||
} = props;
|
||||
const { children } = props;
|
||||
|
||||
const queryClient = await prefetchPermissionGroup(permissionGroupId);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ export const ListUserItem = React.memo(({ name, email }: { name: string; email:
|
|||
<Avatar size={24} name={name} />
|
||||
</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>}
|
||||
{email && (
|
||||
<Text variant="secondary" style={{ fontSize: 12 }}>
|
||||
|
|
|
@ -63,7 +63,7 @@ const permissionAndSecurityItems: ISidebarGroup = {
|
|||
|
||||
export const SidebarSettings: React.FC<{}> = React.memo(({}) => {
|
||||
const isAdmin = useUserConfigContextSelector((x) => x.isAdmin);
|
||||
const currentRoute = useAppLayoutContextSelector((x) => x.currentRoute);
|
||||
const currentParentRoute = useAppLayoutContextSelector((x) => x.currentParentRoute);
|
||||
|
||||
const content = useMemo(() => {
|
||||
const items = [accountItems];
|
||||
|
@ -78,7 +78,7 @@ export const SidebarSettings: React.FC<{}> = React.memo(({}) => {
|
|||
<Sidebar
|
||||
content={content}
|
||||
header={<SidebarSettingsHeader />}
|
||||
activeItem={currentRoute}
|
||||
activeItem={currentParentRoute}
|
||||
footer={<SidebarUserFooter />}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use client';
|
||||
|
||||
import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes';
|
||||
import { pathNameToRoute } from '@/routes/helpers';
|
||||
import { useMemoizedFn, usePrevious } from '@/hooks';
|
||||
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
||||
import { pathNameToParentRoute, pathNameToRoute } from '@/routes/helpers';
|
||||
import { useMemoizedFn } from '@/hooks';
|
||||
import { useRouter, usePathname, useParams } from 'next/navigation';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import { createContext, useContextSelector } from 'use-context-selector';
|
||||
|
||||
|
@ -12,6 +12,7 @@ export const useAppLayout = () => {
|
|||
const pathname = usePathname();
|
||||
const params = useParams();
|
||||
const currentRoute = pathNameToRoute(pathname, params);
|
||||
const currentParentRoute = pathNameToParentRoute(pathname, params);
|
||||
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
||||
|
||||
const onToggleInviteModal = useMemoizedFn((v?: boolean) => {
|
||||
|
@ -57,7 +58,8 @@ export const useAppLayout = () => {
|
|||
currentRoute,
|
||||
onToggleInviteModal,
|
||||
openInviteModal,
|
||||
onChangePage
|
||||
onChangePage,
|
||||
currentParentRoute
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ const CollectionDeleteButton: React.FC<{
|
|||
|
||||
const onRemoveFromCollection = useMemoizedFn(async () => {
|
||||
if (collection) {
|
||||
console.log(selectedRowKeys, collection);
|
||||
await removeAssetFromCollection({
|
||||
id: collectionId,
|
||||
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 />
|
||||
}));
|
||||
|
||||
console.log(options);
|
||||
|
||||
const PermissionUsersAssignButton: React.FC<{
|
||||
selectedRowKeys: string[];
|
||||
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_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.APP_TERMS_ID]: BusterRoutes.APP_TERMS
|
||||
};
|
||||
|
||||
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]) {
|
||||
return paramRoutesToParent[route as string];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue