Skip to content

feat: table in RB #732

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

Open
wants to merge 34 commits into
base: feat/resource-recommender-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c39760
yoyoy
Elessar1802 May 7, 2025
a0d351a
feat: table in RB
Elessar1802 May 13, 2025
3747f38
fix: keep rows loading until rows is provided
Elessar1802 May 15, 2025
99010be
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 May 19, 2025
98a1615
fix: popup menu ref
Elessar1802 May 19, 2025
0d590b3
revert: change in useAsync
Elessar1802 May 19, 2025
b5820c6
fix: RB table bulk actions props
Elessar1802 May 20, 2025
cf594e3
fix: sticky columns in table
Elessar1802 May 21, 2025
a28de9b
fix: loading state of table & checkbox alignment
Elessar1802 May 21, 2025
a2ee314
fix: alignment for CellComponents
Elessar1802 May 21, 2025
06f0059
feat: add icons to Icon component & fix style in table
Elessar1802 May 27, 2025
53d3548
fix: uat changes
Elessar1802 May 28, 2025
6fcae35
fix: loading during search causes search bar focus loss
Elessar1802 May 28, 2025
b8a37ff
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Jun 11, 2025
ec408e0
Merge branch 'feat/rb-table' into fix/rb-table
Elessar1802 Jun 11, 2025
041865c
fix: uat changes
Elessar1802 Jun 11, 2025
8ef90b3
feat: scale resize-btn on hover
Elessar1802 Jun 11, 2025
08ffe92
chore: override sortable-table-cell__resize-btn from table css
Elessar1802 Jun 11, 2025
fbcd109
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Jun 12, 2025
42f5460
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Jun 13, 2025
fe3db8d
Merge branch 'feat/rb-table' into fix/rb-table
Elessar1802 Jun 13, 2025
c8de7d5
feat(css): uat
Elessar1802 Jun 18, 2025
0c2fd13
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Jun 18, 2025
306753e
fix: scrollTo func instead of scrollToTop prop
Elessar1802 Jun 19, 2025
d1bf390
fix: bulk select all if not paginated
Elessar1802 Jun 23, 2025
9b8f2a9
Merge branch 'feat/resource-recommender-develop' of github.com:devtro…
Elessar1802 Jun 23, 2025
da9d3d9
fix: new pagination const
Elessar1802 Jun 24, 2025
eb2b1b0
fix: bulk selection count logic
Elessar1802 Jun 24, 2025
fa075f8
feat: add download icon and update icon map; add ResourceRecommenderA…
AbhishekA1509 Jun 24, 2025
b954eff
Merge branch 'fix/rb-table' of https://github.com/devtron-labs/devtro…
AbhishekA1509 Jun 24, 2025
e15749b
fix: filter if filter func provided
Elessar1802 Jun 25, 2025
f22829a
fix: add new clearFilters prop to table props
Elessar1802 Jun 26, 2025
74c4046
fix: update version from 1.15.3-pre-4 to 1.15.3-beta-3 in package.jso…
AbhishekA1509 Jun 26, 2025
2e1f380
fix: update version from 1.15.3-beta-3 to 1.15.3-beta-4 in package.js…
AbhishekA1509 Jun 26, 2025
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
2 changes: 1 addition & 1 deletion src/Common/Helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export function useAsync<T>(
setState((state) => ({ ...state, loading: false }))
return
}
setState((state) => ({ ...state, dependencies: dependencyArray }))
setState((state) => ({ ...state, loading: true, dependencies: dependencyArray }))
reload()
return () =>
setState((state) => ({
Expand Down
24 changes: 19 additions & 5 deletions src/Common/PopupMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import React, { useEffect } from 'react'
import React, { forwardRef, useEffect } from 'react'
import { Modal } from './Modals/Modal'
import { PopupMenuBodyType, PopupMenuButtonType, PopupMenuType } from './Types'

Expand Down Expand Up @@ -155,19 +155,33 @@ const PopupMenu = ({
)
}

const Button = ({
const Button = forwardRef(({
children = null,
disabled = false,
rootClassName = '',
tabIndex = 0,
onHover = false,
isKebab = false,
dataTestId = '',
}: PopupMenuButtonType) => {
}: PopupMenuButtonType, forwardedRef) => {
const { handleOpen, popupPosition, buttonRef, initialiseButtonWidth } = usePopupContext()

const refCallback = (node) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we require these changes now?

initialiseButtonWidth.current = node

if (typeof forwardedRef === 'function') {
forwardedRef(node)
return
}

if (forwardedRef && typeof forwardedRef === 'object') {
forwardedRef.current = node
}
}

return (
<button
ref={initialiseButtonWidth}
ref={refCallback}
type="button"
tabIndex={tabIndex}
disabled={disabled}
Expand All @@ -181,7 +195,7 @@ const Button = ({
{children}
</button>
)
}
})

const Body = ({
children = null,
Expand Down
31 changes: 18 additions & 13 deletions src/Shared/Components/Table/InternalTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SortableTableHeaderCell } from '@Common/SortableTableHeaderCell'

import { BulkSelection } from '../BulkSelection'
import BulkSelectionActionWidget from './BulkSelectionActionWidget'
import { BULK_ACTION_GUTTER_LABEL, EVENT_TARGET, SHIMMER_DUMMY_ARRAY } from './constants'
import { BULK_ACTION_GUTTER_LABEL, EVENT_TARGET, NO_ROWS_OR_GET_ROWS_ERROR, SHIMMER_DUMMY_ARRAY } from './constants'
import { FiltersTypeEnum, InternalTableProps, PaginationEnum, SignalsType } from './types'
import useTableWithKeyboardShortcuts from './useTableWithKeyboardShortcuts'
import { getFilteringPromise, searchAndSortRows } from './utils'
Expand All @@ -42,6 +42,7 @@ const InternalTable = ({
handleToggleBulkSelectionOnRow,
paginationVariant,
RowActionsOnHoverComponent,
children,
}: InternalTableProps) => {
const rowsContainerRef = useRef<HTMLDivElement>(null)
const parentRef = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -103,9 +104,9 @@ const InternalTable = ({
[visibleColumns],
)

const [areFilteredRowsLoading, filteredRows, filteredRowsError, reloadFilteredRows] = useAsync(async () => {
const [_areFilteredRowsLoading, filteredRows, filteredRowsError, reloadFilteredRows] = useAsync(async () => {
if (!rows && !getRows) {
throw new Error('Neither rows nor getRows function provided')
throw NO_ROWS_OR_GET_ROWS_ERROR
}

return getFilteringPromise({
Expand All @@ -120,6 +121,8 @@ const InternalTable = ({
})
}, [searchKey, sortBy, sortOrder, rows, sortByToColumnIndexMap, JSON.stringify(otherFilters)])

const areFilteredRowsLoading = _areFilteredRowsLoading || filteredRowsError === NO_ROWS_OR_GET_ROWS_ERROR

const bulkSelectionCount = getSelectedIdentifiersCount?.() ?? 0

const visibleRows = useMemo(() => {
Expand Down Expand Up @@ -170,7 +173,7 @@ const InternalTable = ({
paginationVariant === PaginationEnum.PAGINATED && filteredRows?.length > DEFAULT_BASE_PAGE_SIZE

const renderRows = () => {
if (loading && !visibleColumns.length) {
if (loading) {
return SHIMMER_DUMMY_ARRAY.map((shimmerRowLabel) => (
<div
key={shimmerRowLabel}
Expand Down Expand Up @@ -257,7 +260,7 @@ const InternalTable = ({
value={row.data[field]}
signals={EVENT_TARGET as SignalsType}
row={row}
filterData={filterData}
filterData={filterData as any}
isRowActive={isRowActive}
{...additionalProps}
/>
Expand All @@ -282,23 +285,23 @@ const InternalTable = ({
}

const renderContent = () => {
if (!areFilteredRowsLoading && !filteredRows?.length) {
if (filteredRowsError && !areFilteredRowsLoading && !loading) {
return <ErrorScreenManager code={filteredRowsError.code} reload={reloadFilteredRows} />
}

if (!areFilteredRowsLoading && !filteredRows?.length && !loading) {
return filtersVariant !== FiltersTypeEnum.NONE && isFilterApplied ? (
<GenericFilterEmptyState handleClearFilters={clearFilters} />
) : (
<GenericEmptyState {...emptyStateConfig.noRowsConfig} />
)
}

if (filteredRowsError && !areFilteredRowsLoading) {
return <ErrorScreenManager code={filteredRowsError.code} reload={reloadFilteredRows} />
}

return (
<div tabIndex={0} role="grid" className="generic-table flexbox-col dc__overflow-hidden flex-grow-1">
<div className="flexbox-col flex-grow-1 w-100 dc__overflow-auto" ref={parentRef}>
<div className="bg__primary dc__min-width-fit-content px-20 border__secondary--bottom">
{loading && !visibleColumns.length ? (
{loading ? (
<div className="flexbox py-12 dc__gap-16">
{SHIMMER_DUMMY_ARRAY.map((label) => (
<div key={label} className="shimmer w-180" />
Expand All @@ -312,7 +315,7 @@ const InternalTable = ({
}}
>
{visibleColumns.map(({ label, field, isSortable, size, showTippyOnTruncate }) => {
const isResizable = !!size.range
const isResizable = !!size?.range

if (field === BULK_ACTION_GUTTER_LABEL) {
return <BulkSelection key={field} showPagination={showPagination} />
Expand Down Expand Up @@ -361,10 +364,12 @@ const InternalTable = ({
changePage={changePage}
changePageSize={changePageSize}
offset={offset}
rootClassName="border__primary--top flex dc__content-space px-20"
rootClassName="border__secondary--top flex dc__content-space px-20"
size={filteredRows.length}
/>
)}

{children}
</div>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/Components/Table/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export const EVENT_TARGET = new EventTarget()
export const DRAG_SELECTOR_IDENTIFIER = 'table-drag-selector'

export const SHIMMER_DUMMY_ARRAY = [1, 2, 3]

export const NO_ROWS_OR_GET_ROWS_ERROR = new Error('Neither rows nor getRows function provided')
Loading