Skip to content

Commit

Permalink
fix default view mode logic
Browse files Browse the repository at this point in the history
  • Loading branch information
riahk committed Nov 16, 2020
1 parent cd7f177 commit fe8c98a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions superset-frontend/src/components/ListView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ function ListView<T extends object = any>({
initialSort,
initialFilters: filters,
renderCard: Boolean(renderCard),
defaultViewMode,
});
const filterable = Boolean(filters.length);
if (filterable) {
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/components/ListView/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ interface UseListViewConfig {
Cell: (conf: any) => React.ReactNode;
};
renderCard?: boolean;
defaultViewMode?: ViewModeType;
}

export function useListViewState({
Expand All @@ -146,6 +147,7 @@ export function useListViewState({
bulkSelectMode = false,
bulkSelectColumnConfig,
renderCard = false,
defaultViewMode = 'card',
}: UseListViewConfig) {
const [query, setQuery] = useQueryParams({
filters: RisonParam,
Expand All @@ -171,7 +173,8 @@ export function useListViewState({
};

const [viewMode, setViewMode] = useState<ViewModeType>(
(query.viewMode as ViewModeType) || 'table',
(query.viewMode as ViewModeType) ||
(renderCard ? defaultViewMode : 'table'),
);

const columnsWithSelect = useMemo(() => {
Expand Down

0 comments on commit fe8c98a

Please sign in to comment.