mirror of https://github.com/buster-so/buster.git
highlighted permission group downdown
This commit is contained in:
parent
65174dcf9e
commit
ad394c6cef
|
@ -9,10 +9,11 @@ import {
|
||||||
import { queryKeys } from '@/api/query_keys';
|
import { queryKeys } from '@/api/query_keys';
|
||||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||||
|
|
||||||
export const useListDatasources = () => {
|
export const useListDatasources = (enabled: boolean) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
...queryKeys.datasourceGetList,
|
...queryKeys.datasourceGetList,
|
||||||
queryFn: listDatasources
|
queryFn: listDatasources,
|
||||||
|
enabled
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ export const PermissionListDatasetGroupContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionGroups.length === 0,
|
hidden: cannotQueryPermissionGroups.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionGroups.length.toString()
|
secondaryTitle: cannotQueryPermissionGroups.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -87,7 +87,7 @@ export const PermissionListUserContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryUsers.length === 0,
|
hidden: cannotQueryUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryUsers.length.toString()
|
secondaryTitle: cannotQueryUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -98,7 +98,7 @@ export const PermissionListPermissionGroupContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionGroups.length === 0,
|
hidden: cannotQueryPermissionGroups.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionGroups.length.toString()
|
secondaryTitle: cannotQueryPermissionGroups.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -108,7 +108,7 @@ export const DatasetGroupDatasetsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -108,7 +108,7 @@ export const DatasetGroupDatasetGroupsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionDatasetGroups.length === 0,
|
hidden: cannotQueryPermissionDatasetGroups.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionDatasetGroups.length.toString()
|
secondaryTitle: cannotQueryPermissionDatasetGroups.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -112,7 +112,7 @@ export const DatasetGroupUsersListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -103,7 +103,7 @@ export const PermissionGroupDatasetGroupsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionDatasetGroups.length === 0,
|
hidden: cannotQueryPermissionDatasetGroups.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionDatasetGroups.length.toString()
|
secondaryTitle: cannotQueryPermissionDatasetGroups.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -108,7 +108,7 @@ export const PermissionGroupDatasetsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -107,7 +107,7 @@ export const PermissionGroupUsersListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -109,7 +109,7 @@ export const UserDatasetGroupListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -104,7 +104,7 @@ export const UserDatasetsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -110,7 +110,7 @@ export const UserPermissionGroupsListContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const PERMISSION_OPTIONS_ASSIGNED: SelectItem<'true' | 'false'>[] = [
|
||||||
value: 'true'
|
value: 'true'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Not Assigned',
|
label: 'Not assigned',
|
||||||
value: 'false'
|
value: 'false'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -27,7 +27,7 @@ export const NewDatasetModal: React.FC<{
|
||||||
const [selectedDatasource, setSelectedDatasource] = React.useState<string | null>(
|
const [selectedDatasource, setSelectedDatasource] = React.useState<string | null>(
|
||||||
datasourceId || null
|
datasourceId || null
|
||||||
);
|
);
|
||||||
const { refetch: refetchDatasourcesList } = useListDatasources();
|
const { refetch: refetchDatasourcesList } = useListDatasources(open);
|
||||||
const [datasetName, setDatasetName] = React.useState<string>('');
|
const [datasetName, setDatasetName] = React.useState<string>('');
|
||||||
|
|
||||||
const disableSubmit = !selectedDatasource || !datasetName;
|
const disableSubmit = !selectedDatasource || !datasetName;
|
||||||
|
@ -109,7 +109,7 @@ const SelectDataSourceDropdown: React.FC<{
|
||||||
selectedDatasource: string | null;
|
selectedDatasource: string | null;
|
||||||
}> = React.memo(({ setSelectedDatasource, selectedDatasource }) => {
|
}> = React.memo(({ setSelectedDatasource, selectedDatasource }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { data: dataSourcesList } = useListDatasources();
|
const { data: dataSourcesList } = useListDatasources(false);
|
||||||
|
|
||||||
const selectOptions: SelectItem[] = useMemo(() => {
|
const selectOptions: SelectItem[] = useMemo(() => {
|
||||||
return (dataSourcesList || []).map((dataSource) => ({
|
return (dataSourcesList || []).map((dataSource) => ({
|
||||||
|
|
|
@ -57,7 +57,8 @@ export const Select = <T extends string>({
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onOpenChange={onOpenChange}
|
onOpenChange={onOpenChange}
|
||||||
open={open}
|
open={open}
|
||||||
value={value || defaultValue}
|
defaultValue={defaultValue}
|
||||||
|
value={value}
|
||||||
onValueChange={onValueChange}>
|
onValueChange={onValueChange}>
|
||||||
<SelectTrigger className={className}>
|
<SelectTrigger className={className}>
|
||||||
<SelectValue placeholder={placeholder} defaultValue={value || defaultValue} />
|
<SelectValue placeholder={placeholder} defaultValue={value || defaultValue} />
|
||||||
|
|
|
@ -17,8 +17,7 @@ export const selectVariants = cva(
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default:
|
default: 'border-border shadow bg-background data-[placeholder]:text-gray-light ',
|
||||||
'border-border shadow bg-background data-[placeholder]:text-gray-light hover:border-gray-light',
|
|
||||||
ghost: 'border-none bg-transparent shadow-none disabled:bg-transparent outline-none'
|
ghost: 'border-none bg-transparent shadow-none disabled:bg-transparent outline-none'
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
|
@ -45,7 +44,7 @@ const SelectTrigger = React.forwardRef<
|
||||||
{...props}>
|
{...props}>
|
||||||
{children}
|
{children}
|
||||||
<SelectPrimitive.Icon asChild>
|
<SelectPrimitive.Icon asChild>
|
||||||
<div className="flex h-4 w-4 items-center justify-center opacity-50">
|
<div className="flex items-center justify-center opacity-50">
|
||||||
<ChevronDown />
|
<ChevronDown />
|
||||||
</div>
|
</div>
|
||||||
</SelectPrimitive.Icon>
|
</SelectPrimitive.Icon>
|
||||||
|
@ -61,7 +60,7 @@ const SelectScrollUpButton = React.forwardRef<
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
||||||
{...props}>
|
{...props}>
|
||||||
<div className="flex h-4 w-4 items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<ChevronUp />
|
<ChevronUp />
|
||||||
</div>
|
</div>
|
||||||
</SelectPrimitive.ScrollUpButton>
|
</SelectPrimitive.ScrollUpButton>
|
||||||
|
@ -76,7 +75,7 @@ const SelectScrollDownButton = React.forwardRef<
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
||||||
{...props}>
|
{...props}>
|
||||||
<div className="flex h-4 w-4 items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<ChevronDown />
|
<ChevronDown />
|
||||||
</div>
|
</div>
|
||||||
</SelectPrimitive.ScrollDownButton>
|
</SelectPrimitive.ScrollDownButton>
|
||||||
|
@ -134,39 +133,39 @@ const SelectItem = React.forwardRef<
|
||||||
index?: number;
|
index?: number;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
}
|
}
|
||||||
>(({ className, children, icon, secondaryChildren, index, ...props }, ref) => (
|
>(({ className, children, icon, secondaryChildren, index, ...props }, ref) => {
|
||||||
<SelectPrimitive.Item
|
return (
|
||||||
ref={ref}
|
<SelectPrimitive.Item
|
||||||
className={cn(
|
ref={ref}
|
||||||
'focus:bg-item-hover focus:text-foreground cursor-pointer disabled:cursor-not-allowed disabled:opacity-60',
|
className={cn(
|
||||||
'relative flex w-full cursor-default items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-60',
|
'data-[highlighted]:bg-item-hover focus:text-foreground cursor-pointer disabled:cursor-not-allowed disabled:opacity-60',
|
||||||
className
|
'data-[state=checked]:bg-item-select! relative flex w-full cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-60',
|
||||||
)}
|
className
|
||||||
{...props}>
|
|
||||||
<div className="flex flex-col gap-y-0.5">
|
|
||||||
<div className="flex items-center gap-x-1.5">
|
|
||||||
{icon && <span className="text-icon-color">{icon}</span>}
|
|
||||||
<SelectPrimitive.ItemText className="flex h-full items-center">
|
|
||||||
{children}
|
|
||||||
</SelectPrimitive.ItemText>
|
|
||||||
</div>
|
|
||||||
{secondaryChildren && <span className="text-gray-light text-xs">{secondaryChildren}</span>}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-x-1">
|
|
||||||
<SelectPrimitive.ItemIndicator>
|
|
||||||
<div className="flex h-4 w-4 items-center justify-center">
|
|
||||||
<Check />
|
|
||||||
</div>
|
|
||||||
</SelectPrimitive.ItemIndicator>
|
|
||||||
{index !== undefined && (
|
|
||||||
<span className="text-gray-light flex min-w-2 items-center justify-center text-xs">
|
|
||||||
{index}
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
{...props}>
|
||||||
</SelectPrimitive.Item>
|
<div className="flex flex-col gap-y-0.5">
|
||||||
));
|
<div className="flex items-center gap-x-1.5">
|
||||||
|
{icon && <span className="text-icon-color">{icon}</span>}
|
||||||
|
<SelectPrimitive.ItemText className="flex h-full items-center">
|
||||||
|
{children}
|
||||||
|
</SelectPrimitive.ItemText>
|
||||||
|
</div>
|
||||||
|
{secondaryChildren && <span className="text-gray-light text-xs">{secondaryChildren}</span>}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-x-1">
|
||||||
|
<SelectPrimitive.ItemIndicator>
|
||||||
|
<Check />
|
||||||
|
</SelectPrimitive.ItemIndicator>
|
||||||
|
{index !== undefined && (
|
||||||
|
<span className="text-gray-light flex min-w-2 items-center justify-center text-xs">
|
||||||
|
{index}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</SelectPrimitive.Item>
|
||||||
|
);
|
||||||
|
});
|
||||||
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
||||||
|
|
||||||
const SelectSeparator = React.forwardRef<
|
const SelectSeparator = React.forwardRef<
|
||||||
|
|
|
@ -109,7 +109,7 @@ export const PermissionListUsersContainer: React.FC<{
|
||||||
data: {},
|
data: {},
|
||||||
hidden: cannotQueryPermissionUsers.length === 0,
|
hidden: cannotQueryPermissionUsers.length === 0,
|
||||||
rowSection: {
|
rowSection: {
|
||||||
title: 'Not Assigned',
|
title: 'Not assigned',
|
||||||
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
secondaryTitle: cannotQueryPermissionUsers.length.toString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,7 @@ export const PERMISSION_USERS_OPTIONS: SelectItem<'true' | 'false'>[] = [
|
||||||
value: 'true'
|
value: 'true'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Not Assigned',
|
label: 'Not assigned',
|
||||||
value: 'false'
|
value: 'false'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue