mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: date should sort asc/desc properly (#5335)
This commit is contained in:
parent
fd3a7f12cb
commit
069d90d8cb
@ -89,7 +89,6 @@ export const BannersTable = () => {
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
@ -134,7 +133,7 @@ export const BannersTable = () => {
|
||||
);
|
||||
|
||||
const [initialState] = useState({
|
||||
sortBy: [{ id: 'createdAt' }],
|
||||
sortBy: [{ id: 'createdAt', desc: true }],
|
||||
});
|
||||
|
||||
const { data, getSearchText } = useSearch(columns, searchValue, banners);
|
||||
|
@ -40,14 +40,12 @@ const columns = [
|
||||
Header: 'Created date',
|
||||
accessor: 'created',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
disableGlobalFilter: true,
|
||||
},
|
||||
{
|
||||
Header: 'Due date',
|
||||
accessor: 'dueDate',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
disableGlobalFilter: true,
|
||||
},
|
||||
{
|
||||
@ -76,7 +74,7 @@ export const BillingHistory: VFC<IBillingHistoryProps> = ({
|
||||
}) => {
|
||||
const initialState = useMemo(
|
||||
() => ({
|
||||
sortBy: [{ id: 'created' }],
|
||||
sortBy: [{ id: 'created', desc: true }],
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
@ -44,7 +44,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'joinedAt' };
|
||||
const defaultSort: SortingRule<string> = { id: 'joinedAt', desc: true };
|
||||
|
||||
const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
||||
'Group:v1',
|
||||
@ -91,7 +91,6 @@ export const Group: VFC = () => {
|
||||
Header: 'Joined',
|
||||
accessor: 'joinedAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
@ -112,7 +111,6 @@ export const Group: VFC = () => {
|
||||
title={(date) => `Last login: ${date}`}
|
||||
/>
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ export const RoleDeleteDialogGroups = ({
|
||||
groups,
|
||||
}: IRoleDeleteDialogGroupsProps) => {
|
||||
const [initialState] = useState(() => ({
|
||||
sortBy: [{ id: 'createdAt' }],
|
||||
sortBy: [{ id: 'createdAt', desc: true }],
|
||||
}));
|
||||
|
||||
const columns = useMemo(
|
||||
@ -41,7 +41,6 @@ export const RoleDeleteDialogGroups = ({
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ export const RoleDeleteDialogServiceAccounts = ({
|
||||
serviceAccounts,
|
||||
}: IRoleDeleteDialogServiceAccountsProps) => {
|
||||
const [initialState] = useState(() => ({
|
||||
sortBy: [{ id: 'seenAt' }],
|
||||
sortBy: [{ id: 'seenAt', desc: true }],
|
||||
}));
|
||||
|
||||
const columns = useMemo(
|
||||
@ -63,7 +63,6 @@ export const RoleDeleteDialogServiceAccounts = ({
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
@ -77,7 +76,6 @@ export const RoleDeleteDialogServiceAccounts = ({
|
||||
return bSeenAt?.getTime() - aSeenAt?.getTime();
|
||||
})[0]?.seenAt,
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
] as Column<IServiceAccount>[],
|
||||
|
@ -19,7 +19,7 @@ export const RoleDeleteDialogUsers = ({
|
||||
users,
|
||||
}: IRoleDeleteDialogUsersProps) => {
|
||||
const [initialState] = useState(() => ({
|
||||
sortBy: [{ id: 'last-login' }],
|
||||
sortBy: [{ id: 'last-login', desc: true }],
|
||||
}));
|
||||
|
||||
const columns = useMemo(
|
||||
@ -41,7 +41,6 @@ export const RoleDeleteDialogUsers = ({
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
@ -56,7 +55,6 @@ export const RoleDeleteDialogUsers = ({
|
||||
title={(date) => `Last login: ${date}`}
|
||||
/>
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
] as Column<IUser>[],
|
||||
|
@ -81,7 +81,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt' };
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true };
|
||||
|
||||
interface IServiceAccountTokensProps {
|
||||
serviceAccount: IServiceAccount;
|
||||
@ -179,21 +179,18 @@ export const ServiceAccountTokens = ({
|
||||
}
|
||||
return <DateCell value={value} />;
|
||||
},
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
Header: 'Last seen',
|
||||
accessor: 'seenAt',
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
|
@ -131,7 +131,6 @@ export const ServiceAccountsTable = () => {
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
@ -145,7 +144,6 @@ export const ServiceAccountsTable = () => {
|
||||
return bSeenAt?.getTime() - aSeenAt?.getTime();
|
||||
})[0]?.seenAt,
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
@ -178,7 +176,7 @@ export const ServiceAccountsTable = () => {
|
||||
);
|
||||
|
||||
const [initialState] = useState({
|
||||
sortBy: [{ id: 'createdAt' }],
|
||||
sortBy: [{ id: 'createdAt', desc: true }],
|
||||
hiddenColumns: ['username'],
|
||||
});
|
||||
|
||||
|
@ -144,7 +144,6 @@ const UsersList = () => {
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
width: 120,
|
||||
maxWidth: 120,
|
||||
},
|
||||
@ -159,7 +158,6 @@ const UsersList = () => {
|
||||
title={(date) => `Last login: ${date}`}
|
||||
/>
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
@ -206,7 +204,7 @@ const UsersList = () => {
|
||||
|
||||
const initialState = useMemo(() => {
|
||||
return {
|
||||
sortBy: [{ id: 'createdAt' }],
|
||||
sortBy: [{ id: 'createdAt', desc: true }],
|
||||
hiddenColumns: isBillingUsers
|
||||
? ['username', 'email']
|
||||
: ['type', 'username', 'email'],
|
||||
|
@ -146,14 +146,12 @@ export const ArchiveTable = ({
|
||||
accessor: 'createdAt',
|
||||
width: 150,
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
},
|
||||
{
|
||||
Header: 'Archived',
|
||||
accessor: 'archivedAt',
|
||||
width: 150,
|
||||
Cell: FeatureArchivedCell,
|
||||
sortType: 'date',
|
||||
},
|
||||
...(!projectId
|
||||
? [
|
||||
|
@ -38,7 +38,7 @@ export interface IChangeRequestTableProps {
|
||||
|
||||
const defaultSort: SortingRule<string> & {
|
||||
columns?: string[];
|
||||
} = { id: 'createdAt' };
|
||||
} = { id: 'createdAt', desc: true };
|
||||
|
||||
const StyledTabContainer = styled('div')({
|
||||
paddingLeft: 0,
|
||||
@ -162,7 +162,6 @@ export const ChangeRequestsTabs = ({
|
||||
accessor: 'createdAt',
|
||||
maxWidth: 100,
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
},
|
||||
{
|
||||
Header: 'Environment',
|
||||
|
@ -13,7 +13,10 @@ export const useApiTokenTable = (
|
||||
tokens: IApiToken[],
|
||||
getActionCell: (props: any) => JSX.Element,
|
||||
) => {
|
||||
const initialState = useMemo(() => ({ sortBy: [{ id: 'createdAt' }] }), []);
|
||||
const initialState = useMemo(
|
||||
() => ({ sortBy: [{ id: 'createdAt', desc: true }] }),
|
||||
[],
|
||||
);
|
||||
|
||||
const COLUMNS = useMemo(() => {
|
||||
return [
|
||||
@ -72,7 +75,6 @@ export const useApiTokenTable = (
|
||||
Header: 'Last seen',
|
||||
accessor: 'seenAt',
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
minWidth: 150,
|
||||
disableGlobalFilter: true,
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search' | 'favorites', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt' };
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true };
|
||||
|
||||
const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
||||
'FeatureToggleListTable:v1',
|
||||
@ -177,7 +177,6 @@ export const FeatureToggleListTable: VFC = () => {
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'created_at' };
|
||||
const defaultSort: SortingRule<string> = { id: 'created_at', desc: true };
|
||||
|
||||
const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
||||
'LoginHistoryTable:v1',
|
||||
@ -72,7 +72,6 @@ export const LoginHistoryTable = () => {
|
||||
Cell: ({ value }: { value: Date }) => (
|
||||
<TimeAgoCell value={value} dateFormat={formatDateYMDHMS} />
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ const staticColumns = ['Select', 'Actions', 'name', 'favorite'];
|
||||
|
||||
const defaultSort: SortingRule<string> & {
|
||||
columns?: string[];
|
||||
} = { id: 'createdAt' };
|
||||
} = { id: 'createdAt', desc: true };
|
||||
|
||||
export const PaginatedProjectFeatureToggles = ({
|
||||
features,
|
||||
@ -266,7 +266,6 @@ export const PaginatedProjectFeatureToggles = ({
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
minWidth: 120,
|
||||
},
|
||||
...environments.map((value: ProjectEnvironmentType | string) => {
|
||||
|
@ -79,7 +79,7 @@ const staticColumns = ['Select', 'Actions', 'name', 'favorite'];
|
||||
|
||||
const defaultSort: SortingRule<string> & {
|
||||
columns?: string[];
|
||||
} = { id: 'createdAt' };
|
||||
} = { id: 'createdAt', desc: true };
|
||||
|
||||
/**
|
||||
* @deprecated remove when flag `featureSearchFrontend` is removed
|
||||
@ -259,7 +259,6 @@ export const ProjectFeatureToggles = ({
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
minWidth: 120,
|
||||
},
|
||||
...environments.map((value: ProjectEnvironmentType | string) => {
|
||||
|
@ -78,7 +78,7 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
|
||||
const initialState = useMemo(
|
||||
() => ({
|
||||
hiddenColumns: [],
|
||||
sortBy: [{ id: 'createdAt' }],
|
||||
sortBy: [{ id: 'createdAt', desc: true }],
|
||||
}),
|
||||
[],
|
||||
);
|
||||
@ -116,7 +116,6 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
|
||||
{
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
sortType: 'date',
|
||||
Cell: DateCell,
|
||||
disableGlobalFilter: true,
|
||||
maxWidth: 150,
|
||||
|
@ -54,7 +54,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'added' };
|
||||
const defaultSort: SortingRule<string> = { id: 'added', desc: true };
|
||||
|
||||
const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
||||
'ProjectAccess:v1',
|
||||
@ -176,7 +176,6 @@ export const ProjectAccessTable: VFC = () => {
|
||||
Cell: ({ value }: { value: Date }) => (
|
||||
<TimeAgoCell value={value} emptyText='Never' />
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 130,
|
||||
},
|
||||
{
|
||||
@ -196,7 +195,6 @@ export const ProjectAccessTable: VFC = () => {
|
||||
Cell: ({ value }: { value: Date }) => (
|
||||
<TimeAgoCell value={value} emptyText='Never' />
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 130,
|
||||
},
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ const StyledTitle = styled('div')(({ theme }) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'joinedAt' };
|
||||
const defaultSort: SortingRule<string> = { id: 'joinedAt', desc: true };
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -77,7 +77,6 @@ const columns = [
|
||||
Header: 'Joined',
|
||||
accessor: 'joinedAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
@ -91,7 +90,6 @@ const columns = [
|
||||
title={(date) => `Last login: ${date}`}
|
||||
/>
|
||||
),
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
// Always hidden -- for search
|
||||
|
@ -75,7 +75,7 @@ export type PageQueryType = Partial<
|
||||
Record<'sort' | 'order' | 'search', string>
|
||||
>;
|
||||
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt' };
|
||||
const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true };
|
||||
|
||||
const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
||||
'PersonalAPITokensTable:v1',
|
||||
@ -132,21 +132,18 @@ export const PersonalAPITokensTab = () => {
|
||||
}
|
||||
return <DateCell value={value} />;
|
||||
},
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
Header: 'Created',
|
||||
accessor: 'createdAt',
|
||||
Cell: DateCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
Header: 'Last seen',
|
||||
accessor: 'seenAt',
|
||||
Cell: TimeAgoCell,
|
||||
sortType: 'date',
|
||||
maxWidth: 150,
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user