forked from linode/manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [M3-9016] - Convert
DomainRecords.tsx
to functional compo…
…nent (linode#11447) * Initial commit * More refactoring... * Consolidate Pagination Footer * Few fixes... * Fix NS record domain render * Added changeset: Refactor DomainRecords and convert DomainRecords to functional component * Update changeset * Fix DomainRecordTable paginatedData type * Refactor generateTypes * Memoize generateTypes * Utility rename for clarity * Update tablerow key * Change to more descriptive var names * Fix typo * Use scrollErrorIntoViewV2 * Fix linting * Refactor to remove some ramda dependencies and avoid `any` types
- Loading branch information
1 parent
a2686c1
commit 584aab4
Showing
12 changed files
with
1,007 additions
and
903 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11447-tech-stories-1734960446943.md
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,5 @@ | ||
--- | ||
'@linode/manager': Tech Stories | ||
--- | ||
|
||
Refactor and convert DomainRecords to functional component ([#11447](https://github.com/linode/manager/pull/11447)) |
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
6 changes: 4 additions & 2 deletions
6
...atures/Domains/DomainRecordActionMenu.tsx → .../DomainRecords/DomainRecordActionMenu.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
File renamed without changes.
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
88 changes: 88 additions & 0 deletions
88
packages/manager/src/features/Domains/DomainDetail/DomainRecords/DomainRecordTable.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,88 @@ | ||
import React from 'react'; | ||
|
||
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter'; | ||
import { Table } from 'src/components/Table'; | ||
import { TableBody } from 'src/components/TableBody'; | ||
import { TableCell } from 'src/components/TableCell'; | ||
import { TableHead } from 'src/components/TableHead'; | ||
import { TableRow } from 'src/components/TableRow'; | ||
import { TableRowEmpty } from 'src/components/TableRowEmpty/TableRowEmpty'; | ||
|
||
import { StyledTableCell } from './DomainRecords.styles'; | ||
|
||
import type { IType } from './generateTypes'; | ||
import type { Domain, DomainRecord } from '@linode/api-v4/lib/domains'; | ||
|
||
interface DomainRecordTableProps { | ||
count: number; | ||
handlePageChange: (page: number) => void; | ||
handlePageSizeChange: (pageSize: number) => void; | ||
page: number; | ||
pageSize: number; | ||
paginatedData: Domain[] | DomainRecord[]; | ||
type: IType; | ||
} | ||
|
||
export const DomainRecordTable = (props: DomainRecordTableProps) => { | ||
const { | ||
count, | ||
handlePageChange, | ||
handlePageSizeChange, | ||
page, | ||
pageSize, | ||
paginatedData, | ||
type, | ||
} = props; | ||
|
||
return ( | ||
<> | ||
<Table aria-label={`List of Domains ${type.title}`}> | ||
<TableHead> | ||
<TableRow> | ||
{type.columns.length > 0 && | ||
type.columns.map((col, columnIndex) => { | ||
return <TableCell key={columnIndex}>{col.title}</TableCell>; | ||
})} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{type.data.length === 0 ? ( | ||
<TableRowEmpty colSpan={type.columns.length} /> | ||
) : ( | ||
paginatedData.map((data, idx) => { | ||
return ( | ||
<TableRow | ||
data-qa-record-row={type.title} | ||
key={`domain-record-${idx}`} | ||
> | ||
{type.columns.length > 0 && | ||
type.columns.map(({ render, title }, columnIndex) => { | ||
return ( | ||
<StyledTableCell | ||
data-qa-column={title} | ||
key={columnIndex} | ||
parentColumn={title} | ||
> | ||
{render(data)} | ||
</StyledTableCell> | ||
); | ||
})} | ||
</TableRow> | ||
); | ||
}) | ||
)} | ||
</TableBody> | ||
</Table> | ||
<PaginationFooter | ||
count={count} | ||
eventCategory={`${type.title.toLowerCase()} panel`} | ||
handlePageChange={handlePageChange} | ||
handleSizeChange={handlePageSizeChange} | ||
page={page} | ||
pageSize={pageSize} | ||
// Disabling show All as it is impacting page performance. | ||
showAll={false} | ||
/> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.