Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PageLoading component message and translation #369

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ npm/npmjs/-/resolve/1.22.8, MIT AND ISC, approved, #15315
npm/npmjs/-/resolve/2.0.0-next.5, MIT AND ISC, approved, #3078
npm/npmjs/-/reusify/1.0.4, MIT, approved, clearlydefined
npm/npmjs/-/rimraf/3.0.2, ISC, approved, clearlydefined
npm/npmjs/-/rollup/4.24.0, MIT, approved, clearlydefined
npm/npmjs/-/rollup/4.24.0, MIT AND (ISC AND MIT), approved, #16917
npm/npmjs/-/run-parallel/1.2.0, MIT, approved, clearlydefined
npm/npmjs/-/safe-array-concat/1.1.2, MIT, approved, clearlydefined
npm/npmjs/-/safe-buffer/5.2.1, MIT, approved, clearlydefined
Expand Down Expand Up @@ -866,22 +866,22 @@ npm/npmjs/@parcel/watcher-win32-x64/2.4.1, MIT, approved, clearlydefined
npm/npmjs/@parcel/watcher/2.4.1, MIT, approved, clearlydefined
npm/npmjs/@popperjs/core/2.11.8, MIT, approved, clearlydefined
npm/npmjs/@rollup/pluginutils/5.1.2, MIT, approved, #16428
npm/npmjs/@rollup/rollup-android-arm-eabi/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-android-arm64/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-darwin-arm64/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-darwin-x64/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-arm-gnueabihf/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-arm-musleabihf/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-arm64-gnu/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-arm64-musl/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-powerpc64le-gnu/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-riscv64-gnu/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-s390x-gnu/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-x64-gnu/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-linux-x64-musl/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-win32-arm64-msvc/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-win32-ia32-msvc/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-win32-x64-msvc/4.24.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-android-arm-eabi/4.24.0, MIT AND (ISC AND MIT), approved, #16904
npm/npmjs/@rollup/rollup-android-arm64/4.24.0, MIT AND (ISC AND MIT), approved, #16918
npm/npmjs/@rollup/rollup-darwin-arm64/4.24.0, MIT AND (ISC AND MIT), approved, #16908
npm/npmjs/@rollup/rollup-darwin-x64/4.24.0, MIT AND (ISC AND MIT), approved, #16901
npm/npmjs/@rollup/rollup-linux-arm-gnueabihf/4.24.0, MIT AND (ISC AND MIT), approved, #16906
npm/npmjs/@rollup/rollup-linux-arm-musleabihf/4.24.0, MIT AND (ISC AND MIT), approved, #16914
npm/npmjs/@rollup/rollup-linux-arm64-gnu/4.24.0, MIT AND (ISC AND MIT), approved, #16910
npm/npmjs/@rollup/rollup-linux-arm64-musl/4.24.0, MIT AND (ISC AND MIT), approved, #16912
npm/npmjs/@rollup/rollup-linux-powerpc64le-gnu/4.24.0, MIT AND (ISC AND MIT), approved, #16916
npm/npmjs/@rollup/rollup-linux-riscv64-gnu/4.24.0, MIT AND (ISC AND MIT), approved, #16907
npm/npmjs/@rollup/rollup-linux-s390x-gnu/4.24.0, MIT AND (ISC AND MIT), approved, #16919
npm/npmjs/@rollup/rollup-linux-x64-gnu/4.24.0, MIT AND (ISC AND MIT), approved, #16915
npm/npmjs/@rollup/rollup-linux-x64-musl/4.24.0, MIT AND (ISC AND MIT), approved, #16911
npm/npmjs/@rollup/rollup-win32-arm64-msvc/4.24.0, MIT AND (ISC AND MIT), approved, #16909
npm/npmjs/@rollup/rollup-win32-ia32-msvc/4.24.0, MIT AND (ISC AND MIT), approved, #16913
npm/npmjs/@rollup/rollup-win32-x64-msvc/4.24.0, MIT AND (ISC AND MIT), approved, #16902
npm/npmjs/@rtsao/scc/1.1.0, MIT, approved, clearlydefined
npm/npmjs/@rushstack/node-core-library/4.0.2, MIT, approved, clearlydefined
npm/npmjs/@rushstack/rig-package/0.5.2, MIT, approved, clearlydefined
Expand Down
17 changes: 17 additions & 0 deletions src/components/basic/Table/PageLoadingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface PageLoadingTableProps<Row, Args>
allItems?: Row[]
callbackToPage?: (data: PaginResult<Row>) => void
allItemsLoadedHint?: string
mappedTableSearchTranslation?: Record<string, string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Usmanfee In the existing components we simply pass the message in the current language, so the suggested solution works differently. See my comment in the ticket: #368 (comment)

}

const scrollOffset = 350 // Adjust this value for earlier load
Expand All @@ -65,6 +66,8 @@ export const PageLoadingTable = function <Row, Args>({
allItems,
callbackToPage,
allItemsLoadedHint = 'All items have been loaded.',
mappedTableSearchTranslation,
searchExpr,
...props
}: PageLoadingTableProps<Row, Args>) {
const [page, setPage] = useState(0)
Expand Down Expand Up @@ -149,6 +152,19 @@ export const PageLoadingTable = function <Row, Args>({
}
}, [handleScroll])

const getTranslationMessage = (key: string, defaultMessage: string) => {
if (mappedTableSearchTranslation && key in mappedTableSearchTranslation) {
return mappedTableSearchTranslation[key]
}
return defaultMessage
}

const noRowsMsg = !items.length
? searchExpr
? getTranslationMessage('noSearchItemsToDisplay', 'No results found')
: getTranslationMessage('noItemsToDisplay', 'No items to display')
: ''

return (
<>
<Table
Expand All @@ -160,6 +176,7 @@ export const PageLoadingTable = function <Row, Args>({
error={error}
rows={items}
reload={refetch}
noRowsMsg={noRowsMsg}
{...props}
/>
{/* Display loading spinner while fetching data */}
Expand Down