1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01: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(
() => ({
hiddenColumns: [],
sortBy: [{ id: 'createdAt', desc: true }],
sortBy: [{ id: 'createdAt' }],
}),
[]
);

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ export const sortTypes = {
date: (v1: any, v2: any, id: string) => {
const a = new Date(v1?.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) => {
const a = v1?.values?.[id];