diff --git a/src/components/sectionList/SectionListRow.tsx b/src/components/sectionList/SectionListRow.tsx index befc83cb..8d1503fe 100644 --- a/src/components/sectionList/SectionListRow.tsx +++ b/src/components/sectionList/SectionListRow.tsx @@ -18,6 +18,7 @@ export type SectionListRowProps = { selectedColumns: SelectedColumns onSelect: (modelId: string, checked: boolean) => void selected: boolean + renderActions: (modelId: string) => React.ReactNode renderColumnValue: (column: SelectedColumn) => React.ReactNode onClick?: (modelData: GistModel | Model) => void active?: boolean @@ -30,6 +31,7 @@ export function SectionListRow({ onSelect, onClick, selected, + renderActions, renderColumnValue, }: SectionListRowProps) { return ( @@ -55,12 +57,7 @@ export function SectionListRow({ {renderColumnValue(selectedColumn)} ))} - - - - - - + {renderActions(modelData.id)} ) } diff --git a/src/components/sectionList/SectionListWrapper.tsx b/src/components/sectionList/SectionListWrapper.tsx index dda1b7bb..b8f26eca 100644 --- a/src/components/sectionList/SectionListWrapper.tsx +++ b/src/components/sectionList/SectionListWrapper.tsx @@ -4,6 +4,11 @@ import { useSchemaFromHandle } from '../../lib' import { Pager, ModelCollection } from '../../types/models' import { DetailsPanel, DefaultDetailsPanelContent } from './detailsPanel' import { FilterWrapper } from './filters/FilterWrapper' +import { + ActionEdit, + ActionMore, + ListActions, +} from './listActions/SectionListActions' import { useModelListView } from './listView' import { ModelValue } from './modelValue/ModelValue' import { SectionList } from './SectionList' @@ -57,6 +62,9 @@ export const SectionListWrapper = ({ } } + const handleShowDetails = (id: string) => + setDetailsId((prevDetailsId) => (prevDetailsId === id ? undefined : id)) + const allSelected = useMemo(() => { return data?.length !== 0 && data?.length === selectedModels.size }, [data, selectedModels.size]) @@ -95,12 +103,21 @@ export const SectionListWrapper = ({ selectedColumns={headerColumns} onSelect={handleSelect} onClick={({ id }) => { - setDetailsId((prevDetailsId) => - prevDetailsId === id ? undefined : id - ) + handleShowDetails(id) }} selected={selectedModels.has(model.id)} active={model.id === detailsId} + renderActions={(id) => ( + + + + handleShowDetails(id) + } + /> + + )} renderColumnValue={({ path }) => { return ( { @@ -26,35 +32,56 @@ export const ActionEdit = ({ modelId }: { modelId: string }) => { ) } -export const ActionMore = () => { +type ActionMoreProps = { + modelId: string + onShowDetailsClick: () => void +} +export const ActionMore = ({ + modelId, + onShowDetailsClick, +}: ActionMoreProps) => { const [open, setOpen] = useState(false) const ref = useRef(null) + const href = useHref(modelId, { relative: 'path' }) + const handleClick = useLinkClickHandler(modelId) + const navigate = useNavigate() return (
- + + {open && ( + setOpen(false)} + > + + } + onClick={onShowDetailsClick} + /> + } + onClick={(_, e) => { + handleClick(e) + setOpen(false) + }} + target="_blank" + href={href} + > + + + )}
) }