Skip to content

Commit 458a8b6

Browse files
fixed sorting for ASC and DESC
1 parent 7d3b505 commit 458a8b6

File tree

19 files changed

+48
-38
lines changed

19 files changed

+48
-38
lines changed

src/ui/layouts/common/Table/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ export const Table: React.FC<TableProps> = ({
167167
const isValidFilterForCategory: any =
168168
isValidFilterFroValue && filters?.map((f) => f.type.value).join('');
169169
const checkValidFilter = isValidFilterFroValue + isValidFilterForCategory;
170-
console.log(checkValidFilter, 'checkValidFilter');
171170

172171
const { dispatchStackData } = callActionForStacksForPagination();
173172
const {
@@ -197,7 +196,7 @@ export const Table: React.FC<TableProps> = ({
197196
if (filters) {
198197
setPageIndex(0);
199198
}
200-
if (checkValidFilter) {
199+
if (checkValidFilter || activeSorting || checkForLocationPath) {
201200
switch (componentName) {
202201
case 'stacks':
203202
if (CheckIfRun) {
@@ -272,12 +271,7 @@ export const Table: React.FC<TableProps> = ({
272271
}
273272

274273
// eslint-disable-next-line react-hooks/exhaustive-deps
275-
}, [
276-
checkForLocationPath,
277-
checkValidFilter,
278-
activeSorting,
279-
activeSortingDirection,
280-
]);
274+
}, [checkForLocationPath, checkValidFilter, activeSorting]);
281275
let rowsToDisplay = tableRows;
282276
// function getFetchedState(state: any) {
283277
// setFetchingMembers(state);

src/ui/layouts/pipelines/PipelineDetail/Runs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const Runs: React.FC<{ pipelineId: TId; filter: any }> = ({
99
}) => {
1010
const [sortBy, setSortBy] = useState('created');
1111
function getSorted(activeSorting: any, activeSortingDirection: any) {
12-
setSortBy(activeSorting);
12+
setSortBy(activeSortingDirection?.toLowerCase() + ':' + activeSorting);
1313
// console.log(activeSorting, activeSortingDirection, 'aaaaaaa');
1414
}
1515
const { fetching, runIds, runsPaginated } = useService({

src/ui/layouts/pipelines/Pipelines/AllRuns/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface Props {
1515
export const AllRuns: React.FC<Props> = ({ filter }: Props) => {
1616
const [sortBy, setSortBy] = useState('created');
1717
function getSorted(activeSorting: any, activeSortingDirection: any) {
18-
setSortBy(activeSorting);
18+
setSortBy(activeSortingDirection?.toLowerCase() + ':' + activeSorting);
1919
// console.log(activeSorting, activeSortingDirection, 'aaaaaaa');
2020
}
2121

src/ui/layouts/pipelines/Pipelines/List/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export const List: React.FC<Props> = ({ filter }: Props) => {
6666
/>
6767
)}
6868
activeSortingDirection={activeSortingDirection}
69-
activeSorting={activeSorting}
69+
activeSorting={
70+
activeSortingDirection?.toLowerCase() + ':' + activeSorting
71+
}
7072
// activeSorting={
7173
// activeSorting !== 'created' && activeSortingDirection !== 'ASC'
7274
// ? activeSorting

src/ui/layouts/pipelines/Pipelines/List/useService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const useService = (
4848
const [
4949
activeSortingDirection,
5050
setActiveSortingDirection,
51-
] = React.useState<SortingDirection | null>('DESC');
51+
] = React.useState<SortingDirection | null>('ASC');
5252

5353
const dispatch = useDispatch();
5454

@@ -70,10 +70,11 @@ export const useService = (
7070
useEffect(() => {
7171
if (!isValidFilter) {
7272
const intervalId = setInterval(() => {
73-
//assign interval to a variable to clear it.
73+
const applySorting =
74+
activeSortingDirection?.toLowerCase() + ':' + activeSorting;
7475
dispatch(
7576
pipelinesActions.getMy({
76-
sort_by: activeSorting ? activeSorting : 'created',
77+
sort_by: applySorting ? applySorting : 'created',
7778
logical_operator: 'and',
7879
// name: '',
7980
project: selectedProject,

src/ui/layouts/pipelines/RunsTable/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,16 @@ export const RunsTable: React.FC<{
7272
if (getSorted) {
7373
getSorted(activeSorting, activeSortingDirection);
7474
}
75+
console.log(activeSortingDirection, 'activeSortingDirection');
7576
// eslint-disable-next-line react-hooks/exhaustive-deps
7677
}, [getSorted]);
7778

7879
return (
7980
<Table
8081
activeSortingDirection={activeSortingDirection}
81-
activeSorting={activeSorting}
82+
activeSorting={
83+
activeSortingDirection?.toLowerCase() + ':' + activeSorting
84+
}
8285
// activeSorting={
8386
// activeSorting !== 'created' && activeSortingDirection !== 'ASC'
8487
// ? activeSorting

src/ui/layouts/pipelines/RunsTable/useService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const useService = ({
4646
const [
4747
activeSortingDirection,
4848
setActiveSortingDirection,
49-
] = React.useState<SortingDirection | null>('DESC');
49+
] = React.useState<SortingDirection | null>('ASC');
5050
const [sortedRuns, setSortedRuns] = React.useState<TRun[]>([]);
5151

5252
const runs = pipelineRuns

src/ui/layouts/runs/RunsTable/useService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ export const useService = ({ runIds }: { runIds: TId[] }): ServiceInterface => {
2727
const [
2828
activeSortingDirection,
2929
setActiveSortingDirection,
30-
] = React.useState<SortingDirection | null>('DESC');
30+
] = React.useState<SortingDirection | null>('ASC');
3131
const [sortedRuns, setSortedRuns] = React.useState<TRun[]>([]);
3232

3333
const runs = useSelector(runSelectors.forRunIds(runIds));
3434

3535
useEffect(() => {
36-
const orderedRuns = _.orderBy(
37-
runs,
38-
[activeSorting],
39-
[activeSortingDirection === 'DESC' ? 'desc' : 'asc'],
40-
);
36+
// const orderedRuns = _.orderBy(
37+
// runs,
38+
// [activeSorting],
39+
// [activeSortingDirection === 'DESC' ? 'desc' : 'asc'],
40+
// );
4141

42-
setSortedRuns(orderedRuns as TRun[]);
42+
setSortedRuns(runs as TRun[]);
4343
}, []);
4444
useEffect(() => {
4545
return () => {

src/ui/layouts/settings/Organization/useService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const useService = (): ServiceInterface => {
3333
const [
3434
activeSortingDirection,
3535
setActiveSortingDirection,
36-
] = React.useState<SortingDirection | null>('DESC');
36+
] = React.useState<SortingDirection | null>('ASC');
3737
const dispatch = useDispatch();
3838

3939
const members = useSelector(organizationSelectors.myMembers);

src/ui/layouts/stackComponents/RunsTable/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export const RunsTable: React.FC<{
6767
return (
6868
<Table
6969
activeSortingDirection={activeSortingDirection}
70-
activeSorting={activeSorting}
70+
activeSorting={
71+
activeSortingDirection?.toLowerCase() + ':' + activeSorting
72+
}
7173
// activeSorting={
7274
// activeSorting !== 'created' && activeSortingDirection !== 'ASC'
7375
// ? activeSorting

0 commit comments

Comments
 (0)