1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00

fix: sort order across the app

discussed with Nicolae and Nuno
This commit is contained in:
Tymoteusz Czech 2022-06-14 11:14:56 +02:00
parent 1d8c286c79
commit 349106a2be
7 changed files with 9 additions and 13 deletions

View File

@ -55,7 +55,7 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
const initialState = useMemo( const initialState = useMemo(
() => ({ () => ({
hiddenColumns: [], hiddenColumns: [],
sortBy: [{ id: 'createdAt', desc: true }], sortBy: [{ id: 'createdAt' }],
}), }),
[] []
); );

View File

@ -119,6 +119,7 @@ const UsersList = () => {
Cell: DateCell, Cell: DateCell,
disableGlobalFilter: true, disableGlobalFilter: true,
sortType: 'date', sortType: 'date',
minWidth: 120,
}, },
{ {
Header: 'Avatar', Header: 'Avatar',
@ -169,6 +170,7 @@ const UsersList = () => {
), ),
disableGlobalFilter: true, disableGlobalFilter: true,
sortType: 'date', sortType: 'date',
minWidth: 150,
}, },
{ {
Header: 'Actions', Header: 'Actions',
@ -193,7 +195,7 @@ const UsersList = () => {
const initialState = useMemo(() => { const initialState = useMemo(() => {
return { return {
sortBy: [{ id: 'createdAt', desc: false }], sortBy: [{ id: 'createdAt' }],
hiddenColumns: isBillingUsers ? [] : ['type'], hiddenColumns: isBillingUsers ? [] : ['type'],
}; };
}, [isBillingUsers]); }, [isBillingUsers]);

View File

@ -99,7 +99,7 @@ const columns = [
}, },
]; ];
const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true }; const defaultSort: SortingRule<string> = { id: 'createdAt' };
const { value: storedParams, setValue: setStoredParams } = createLocalStorage( const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
'FeatureToggleListTable:v1', 'FeatureToggleListTable:v1',

View File

@ -20,10 +20,7 @@ export const FeatureMetricsTable = ({
}: IFeatureMetricsTableProps) => { }: IFeatureMetricsTableProps) => {
const isMediumScreen = useMediaQuery(theme.breakpoints.down('md')); const isMediumScreen = useMediaQuery(theme.breakpoints.down('md'));
const initialState = useMemo( const initialState = useMemo(() => ({ sortBy: [{ id: 'timestamp' }] }), []);
() => ({ sortBy: [{ id: 'timestamp', desc: true }] }),
[]
);
const { const {
getTableProps, getTableProps,

View File

@ -67,10 +67,7 @@ const staticColumns = ['Actions', 'name'];
const defaultSort: SortingRule<string> & { const defaultSort: SortingRule<string> & {
columns?: string[]; columns?: string[];
} = { } = { id: 'createdAt' };
id: 'createdAt',
desc: true,
};
export const ProjectFeatureToggles = ({ export const ProjectFeatureToggles = ({
features, features,

View File

@ -30,7 +30,7 @@ export const SegmentTable = () => {
const { segments, loading } = useSegments(); const { segments, loading } = useSegments();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md')); const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
const [initialState] = useState({ const [initialState] = useState({
sortBy: [{ id: 'createdAt', desc: false }], sortBy: [{ id: 'createdAt' }],
hiddenColumns: ['description'], hiddenColumns: ['description'],
}); });

View File

@ -7,7 +7,7 @@ export const sortTypes = {
date: (v1: any, v2: any, id: string) => { date: (v1: any, v2: any, id: string) => {
const a = new Date(v1?.values?.[id] || 0); const a = new Date(v1?.values?.[id] || 0);
const b = new Date(v2?.values?.[id] || 0); const b = new Date(v2?.values?.[id] || 0);
return a?.getTime() - b?.getTime(); return b?.getTime() - a?.getTime(); // newest first by default
}, },
boolean: (v1: any, v2: any, id: string) => { boolean: (v1: any, v2: any, id: string) => {
const a = v1?.values?.[id]; const a = v1?.values?.[id];