-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feature/new-job-from-file-revisi…
…on-' into feat/revision-job
- Loading branch information
Showing
13 changed files
with
488 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// temporary_disabled_rules | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
import { | ||
FilterWithDocumentExtraOption, | ||
Operators, | ||
PagedResponse, | ||
QueryHookParamsType, | ||
QueryHookType, | ||
Revision, | ||
SearchBody, | ||
SortingDirection | ||
} from 'api/typings'; | ||
import { useQuery } from 'react-query'; | ||
import { pageSizes } from 'shared/primitives'; | ||
import { useBadgerFetch } from './api'; | ||
|
||
const namespace = process.env.REACT_APP_CATEGORIES_API_NAMESPACE; | ||
|
||
export const useRevisions: QueryHookType<QueryHookParamsType<Revision>, PagedResponse<Revision>> = ( | ||
params, | ||
options | ||
) => { | ||
const { searchText, sortConfig, size: pageSize, page: pageNum, filters } = params; | ||
return useQuery( | ||
['revisions', searchText, sortConfig, pageSize, pageNum], | ||
() => revisionsFetcher(pageNum, pageSize, searchText, sortConfig, filters), | ||
options | ||
); | ||
}; | ||
export function revisionsFetcher( | ||
page = 1, | ||
size = pageSizes._15, | ||
searchText?: string | null, | ||
sortConfig: { | ||
field: keyof Revision; | ||
direction: SortingDirection; | ||
} = { | ||
field: 'revision', | ||
direction: SortingDirection.ASC | ||
}, | ||
filters: FilterWithDocumentExtraOption<keyof Revision>[] = [] | ||
): Promise<PagedResponse<Revision>> { | ||
if (searchText) { | ||
filters.push({ | ||
field: 'revision', | ||
operator: Operators.ILIKE, | ||
value: `%${searchText.trim().toLowerCase()}%` | ||
}); | ||
} | ||
const body: SearchBody<Revision> = { | ||
pagination: { page_num: page, page_size: size }, | ||
filters, | ||
sorting: [{ direction: sortConfig.direction, field: sortConfig.field }] | ||
}; | ||
return useBadgerFetch<PagedResponse<Revision>>({ | ||
url: `${namespace}/annotation`, | ||
method: 'post', | ||
withCredentials: true | ||
})(JSON.stringify(body)); | ||
} | ||
|
||
export function revisionPropFetcher( | ||
propName: keyof Revision, | ||
page = 1, | ||
size = pageSizes._15, | ||
keyword: string = '' | ||
): Promise<PagedResponse<string>> { | ||
const sortConfig = { | ||
field: propName, | ||
direction: SortingDirection.ASC | ||
}; | ||
const filters: FilterWithDocumentExtraOption<keyof Revision>[] = []; | ||
filters.push({ | ||
field: propName, | ||
operator: Operators.DISTINCT | ||
}); | ||
if (keyword) { | ||
filters.push({ | ||
field: propName, | ||
operator: Operators.ILIKE, | ||
value: `%${keyword}%` | ||
}); | ||
} | ||
const body: SearchBody<Revision> = { | ||
pagination: { page_num: page, page_size: size }, | ||
filters, | ||
sorting: [{ direction: sortConfig.direction, field: sortConfig.field as keyof Revision }] | ||
}; | ||
|
||
return useBadgerFetch<PagedResponse<string>>({ | ||
url: `${namespace}/annotation`, | ||
method: 'post', | ||
withCredentials: true | ||
})(JSON.stringify(body)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { RevisionsTableConnector } from './revisions-table-connector'; |
27 changes: 27 additions & 0 deletions
27
web/src/connectors/revisions-table-connector/revisions-columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// temporary_disabled_rules | ||
/* eslint-disable @typescript-eslint/no-redeclare, @typescript-eslint/no-unused-vars */ | ||
import { DataColumnProps } from '@epam/uui'; | ||
import { Revision } from 'api/typings'; | ||
import { Text } from '@epam/loveship'; | ||
import React from 'react'; | ||
|
||
export const revisionsColumns: DataColumnProps<Revision>[] = [ | ||
{ | ||
key: 'revision', | ||
caption: 'REVISION ID', | ||
render: (file) => <Text>{file.revision}</Text>, | ||
grow: 1, | ||
minWidth: 100, | ||
isSortable: true, | ||
width: 150 | ||
}, | ||
{ | ||
key: 'date', | ||
caption: 'CREATED DATE', | ||
render: (file) => <Text>{new Date(file.date).toLocaleDateString()}</Text>, | ||
grow: 0, | ||
minWidth: 100, | ||
isSortable: true, | ||
width: 150 | ||
} | ||
]; |
3 changes: 3 additions & 0 deletions
3
web/src/connectors/revisions-table-connector/revisions-table-connector.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.title { | ||
padding: 22px 0 12px 0; | ||
} |
Oops, something went wrong.