Skip to content

Commit

Permalink
Remove pageCursors
Browse files Browse the repository at this point in the history
Onitoxan committed Jan 14, 2025

Verified

This commit was signed with the committer’s verified signature.
fedgiac Federico Giacon
1 parent 9c1ddf4 commit 1aa8966
Showing 5 changed files with 17 additions and 65 deletions.
44 changes: 8 additions & 36 deletions apps/hpc-ftsadmin/src/app/components/tables/flows-table.tsx
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ export default function FlowsTable(props: FlowsTableProps) {
const [tableInfoDisplay, setTableInfoDisplay] = useState(
util.getLocalStorageItem<LocalStorageSchema>('tableSettings', true)
);

const parsedFilters = parseFlowFilters(tableFilters, props.pending);
const navigate = useNavigate();
const [state, load] = useDataLoader([query], () =>
@@ -91,8 +92,6 @@ export default function FlowsTable(props: FlowsTableProps) {
sortOrder: query.orderDir,
...parsedFilters,
signal: props.abortSignal,
prevPageCursor: query.prevPageCursor,
nextPageCursor: query.nextPageCursor,
})
);
const handleChipDelete = <T extends FilterKeys>(fieldName: T) => {
@@ -106,26 +105,11 @@ export default function FlowsTable(props: FlowsTableProps) {
}
};

const handleChangePage = (
newPage: number,
prevPageCursor: number,
nextPageCursor: number
) => {
if (newPage > props.query.page) {
setQuery({
...query,
prevPageCursor: undefined,
nextPageCursor: nextPageCursor,
page: newPage,
});
} else {
setQuery({
...query,
prevPageCursor: prevPageCursor,
nextPageCursor: undefined,
page: newPage,
});
}
const handleChangePage = (newPage: number) => {
setQuery({
...query,
page: newPage,
});
};

const handleChangeRowsPerPage = (
@@ -859,13 +843,7 @@ export default function FlowsTable(props: FlowsTableProps) {
count={data.searchFlows.total}
rowsPerPage={query.rowsPerPage}
page={query.page}
onPageChange={(_, newPage) =>
handleChangePage(
newPage,
data.searchFlows.prevPageCursor,
data.searchFlows.nextPageCursor
)
}
onPageChange={(_, newPage) => handleChangePage(newPage)}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
</TopRowContainer>
@@ -896,13 +874,7 @@ export default function FlowsTable(props: FlowsTableProps) {
count={data.searchFlows.total}
rowsPerPage={query.rowsPerPage}
page={query.page}
onPageChange={(_, newPage) =>
handleChangePage(
newPage,
data.searchFlows.prevPageCursor,
data.searchFlows.nextPageCursor
)
}
onPageChange={(_, newPage) => handleChangePage(newPage)}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
</>
2 changes: 0 additions & 2 deletions apps/hpc-ftsadmin/src/app/components/tables/table-utils.tsx
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@ import type {
export type Query = {
orderDir: 'ASC' | 'DESC';
tableHeaders: string;
prevPageCursor?: number;
nextPageCursor?: number;
};

export type FlowQuery = Query & {
24 changes: 9 additions & 15 deletions apps/hpc-ftsadmin/src/app/utils/codecs.ts
Original file line number Diff line number Diff line change
@@ -32,22 +32,16 @@ const ROWS_PER_PAGE = new t.Type<number, number>(
t.identity
);

const PARAMS_CODEC = t.intersection([
t.type({
page: util.INTEGER_FROM_STRING,
rowsPerPage: ROWS_PER_PAGE,
orderDir: t.keyof({
ASC: 'ASC',
DESC: 'DESC',
}),
filters: t.string,
tableHeaders: t.string,
}),
t.partial({
prevPageCursor: util.INTEGER_FROM_STRING,
nextPageCursor: util.INTEGER_FROM_STRING,
const PARAMS_CODEC = t.type({
page: util.INTEGER_FROM_STRING,
rowsPerPage: ROWS_PER_PAGE,
orderDir: t.keyof({
ASC: 'ASC',
DESC: 'DESC',
}),
]);
filters: t.string,
tableHeaders: t.string,
});

const extractIdentifierIds = <
T extends OrganizationHeaderID | FlowHeaderID | KeywordHeaderID,
4 changes: 0 additions & 4 deletions libs/hpc-data/src/lib/flows.ts
Original file line number Diff line number Diff line change
@@ -223,8 +223,6 @@ export const SEARCH_FLOWS_RESULT = t.type({
searchFlows: t.type({
total: t.number,
flows: FLOW_RESULT,
prevPageCursor: t.number,
nextPageCursor: t.number,
hasNextPage: t.boolean,
hasPreviousPage: t.boolean,
pageSize: t.number,
@@ -282,8 +280,6 @@ export type NestedFlowFilters = t.TypeOf<typeof NESTED_FLOW_FILTERS>;

export const SEARCH_FLOWS_PARAMS = t.partial({
limit: t.number,
prevPageCursor: t.number,
nextPageCursor: t.number,
sortOrder: t.string,
sortField: t.string,
...FLOW_FILTERS.props,
8 changes: 0 additions & 8 deletions libs/hpc-live/src/lib/model.ts
Original file line number Diff line number Diff line change
@@ -627,17 +627,9 @@ export class LiveModel implements Model {
const query = `query {
searchFlows${searchFlowsParams(params)} {
total
prevPageCursor
hasNextPage
nextPageCursor
hasPreviousPage
pageSize
${this.searchFlowFields}
}
}`;

0 comments on commit 1aa8966

Please sign in to comment.