From 5c397607c4875fdb3d26c9c231ebc2179519be87 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Wed, 7 May 2025 18:28:01 +0530 Subject: [PATCH 01/25] yoyoy --- src/Common/Helper.tsx | 2 +- src/Common/PopupMenu.tsx | 24 +++++++++++++++---- .../Table/useTableWithKeyboardShortcuts.ts | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Common/Helper.tsx b/src/Common/Helper.tsx index 76cd26c9d..d1a7d4516 100644 --- a/src/Common/Helper.tsx +++ b/src/Common/Helper.tsx @@ -450,7 +450,7 @@ export function useAsync( setState((state) => ({ ...state, loading: false })) return } - setState((state) => ({ ...state, dependencies: dependencyArray })) + setState((state) => ({ ...state, loading: true, dependencies: dependencyArray })) reload() return () => setState((state) => ({ diff --git a/src/Common/PopupMenu.tsx b/src/Common/PopupMenu.tsx index 12d4e3107..be3a6b8c4 100644 --- a/src/Common/PopupMenu.tsx +++ b/src/Common/PopupMenu.tsx @@ -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' @@ -155,7 +155,7 @@ const PopupMenu = ({ ) } -const Button = ({ +const Button = forwardRef(({ children = null, disabled = false, rootClassName = '', @@ -163,11 +163,25 @@ const Button = ({ onHover = false, isKebab = false, dataTestId = '', -}: PopupMenuButtonType) => { +}: PopupMenuButtonType, forwardedRef) => { const { handleOpen, popupPosition, buttonRef, initialiseButtonWidth } = usePopupContext() + + const refCallback = (node) => { + initialiseButtonWidth.current = node + + if (typeof forwardedRef === 'function') { + forwardedRef(node) + return + } + + if (forwardedRef && typeof forwardedRef === 'object') { + forwardedRef.current = node + } + } + return ( - ) -} - -export default BulkSelectionDropdownItems diff --git a/src/Shared/Components/BulkSelection/types.tsx b/src/Shared/Components/BulkSelection/types.tsx index 7350a500a..13a901a9a 100644 --- a/src/Shared/Components/BulkSelection/types.tsx +++ b/src/Shared/Components/BulkSelection/types.tsx @@ -56,18 +56,6 @@ export interface BulkSelectionProps { disabled?: boolean } -export interface BulkSelectionDropdownItemsType { - locator: BulkSelectionEvents - label: string - isSelected: boolean - icon: React.FunctionComponent> - iconClass?: string -} - -export interface BulkSelectionDropdownItemsProps - extends BulkSelectionDropdownItemsType, - Pick, 'handleBulkSelection'> {} - export enum SelectAllDialogStatus { OPEN = 'OPEN', CLOSED = 'CLOSED', diff --git a/src/Shared/Components/Icon/Icon.tsx b/src/Shared/Components/Icon/Icon.tsx index d9660cc5a..153aaea0e 100644 --- a/src/Shared/Components/Icon/Icon.tsx +++ b/src/Shared/Components/Icon/Icon.tsx @@ -33,6 +33,8 @@ import { ReactComponent as ICCd } from '@IconsV2/ic-cd.svg' import { ReactComponent as ICChatCircleDots } from '@IconsV2/ic-chat-circle-dots.svg' import { ReactComponent as ICChatCircleOnline } from '@IconsV2/ic-chat-circle-online.svg' import { ReactComponent as ICCheck } from '@IconsV2/ic-check.svg' +import { ReactComponent as ICCheckAll } from '@IconsV2/ic-check-all.svg' +import { ReactComponent as ICCheckSquare } from '@IconsV2/ic-check-square.svg' import { ReactComponent as ICChecks } from '@IconsV2/ic-checks.svg' import { ReactComponent as ICCiLinked } from '@IconsV2/ic-ci-linked.svg' import { ReactComponent as ICCiWebhook } from '@IconsV2/ic-ci-webhook.svg' @@ -227,6 +229,8 @@ export const iconMap = { 'ic-cd': ICCd, 'ic-chat-circle-dots': ICChatCircleDots, 'ic-chat-circle-online': ICChatCircleOnline, + 'ic-check-all': ICCheckAll, + 'ic-check-square': ICCheckSquare, 'ic-check': ICCheck, 'ic-checks': ICChecks, 'ic-ci-linked': ICCiLinked, diff --git a/src/Shared/Components/Table/useTableWithKeyboardShortcuts.ts b/src/Shared/Components/Table/useTableWithKeyboardShortcuts.ts index afb1117bf..91b95fff8 100644 --- a/src/Shared/Components/Table/useTableWithKeyboardShortcuts.ts +++ b/src/Shared/Components/Table/useTableWithKeyboardShortcuts.ts @@ -157,6 +157,7 @@ const useTableWithKeyboardShortcuts = ( callback: () => { if (showPagination) { bulkSelectionButtonRef.current?.click() + bulkSelectionButtonRef.current?.focus() return } From 8ef90b31e36ff786e91d6ac3e0111b311e67e57a Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Wed, 11 Jun 2025 17:39:27 +0530 Subject: [PATCH 14/25] feat: scale resize-btn on hover --- src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss b/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss index edbaf7d3c..eb5d34674 100644 --- a/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss +++ b/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss @@ -28,6 +28,7 @@ > div { height: 100% !important; background-color: var(--B500); + transform: scaleY(1.8); } } } From 08ffe920349f580f6f702493201fbde203286ed7 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Wed, 11 Jun 2025 18:02:41 +0530 Subject: [PATCH 15/25] chore: override sortable-table-cell__resize-btn from table css --- .../SortableTableHeaderCell/sortableTableHeaderCell.scss | 1 - src/Shared/Components/Table/styles.scss | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss b/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss index eb5d34674..edbaf7d3c 100644 --- a/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss +++ b/src/Common/SortableTableHeaderCell/sortableTableHeaderCell.scss @@ -28,7 +28,6 @@ > div { height: 100% !important; background-color: var(--B500); - transform: scaleY(1.8); } } } diff --git a/src/Shared/Components/Table/styles.scss b/src/Shared/Components/Table/styles.scss index 1473ba0f4..2153d7c87 100644 --- a/src/Shared/Components/Table/styles.scss +++ b/src/Shared/Components/Table/styles.scss @@ -56,4 +56,10 @@ background-color: var(--B100); } } + + .sortable-table-header__resize-btn:hover { + > div { + transform: scaleY(1.8); + } + } } From c8de7d5ee7c6e82dd48ef0a2fb95a3d3d6bdd406 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Wed, 18 Jun 2025 23:09:34 +0530 Subject: [PATCH 16/25] feat(css): uat --- src/Shared/Components/Table/InternalTable.tsx | 2 +- src/Shared/Components/Table/TableContent.tsx | 2 +- src/Shared/Components/Table/styles.scss | 32 ++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Shared/Components/Table/InternalTable.tsx b/src/Shared/Components/Table/InternalTable.tsx index d6b48626f..53499b93c 100644 --- a/src/Shared/Components/Table/InternalTable.tsx +++ b/src/Shared/Components/Table/InternalTable.tsx @@ -80,7 +80,7 @@ const InternalTable = ({ ) : () => getRows(filterData), }) - }, [searchKey, sortBy, sortOrder, rows, JSON.stringify(otherFilters)]) + }, [searchKey, sortBy, sortOrder, rows, JSON.stringify(otherFilters), visibleColumns]) const areFilteredRowsLoading = _areFilteredRowsLoading || filteredRowsError === NO_ROWS_OR_GET_ROWS_ERROR diff --git a/src/Shared/Components/Table/TableContent.tsx b/src/Shared/Components/Table/TableContent.tsx index 32133157c..feab20fdf 100644 --- a/src/Shared/Components/Table/TableContent.tsx +++ b/src/Shared/Components/Table/TableContent.tsx @@ -288,7 +288,7 @@ const TableContent = ({ >
{loading ? (
diff --git a/src/Shared/Components/Table/styles.scss b/src/Shared/Components/Table/styles.scss index 2153d7c87..398f1f4bb 100644 --- a/src/Shared/Components/Table/styles.scss +++ b/src/Shared/Components/Table/styles.scss @@ -1,4 +1,6 @@ .generic-table { + --resize-btn-scale-multiplier: 2.25; + &__cell > * { height: 100%; width: 100%; @@ -24,12 +26,22 @@ } } - &--scrolled .generic-table__row > .generic-table__cell--sticky:not(:has(+ .generic-table__cell--sticky)) { - // Show a right border on the last sticky cell when the table is scrolled - // Using box-shadow to avoid layout issues with borders, since borders can affect the width of the cell - box-shadow: - 0px 0px 0px 0px transparent, - 1px 0px 0px 0px var(--border-primary); + &--scrolled { + .generic-table__header .generic-table__cell--sticky:not(:has(+ .generic-table__cell--sticky)) { + .sortable-table-header__resize-btn { + > div { + transform: scaleY(var(--resize-btn-scale-multiplier)); + } + } + } + + .generic-table__row > .generic-table__cell--sticky:not(:has(+ .generic-table__cell--sticky)) { + // Show a right border on the last sticky cell when the table is scrolled + // Using box-shadow to avoid layout issues with borders, since borders can affect the width of the cell + box-shadow: + 0px 0px 0px 0px transparent, + 1px 0px 0px 0px var(--border-primary); + } } &__row { @@ -57,9 +69,13 @@ } } - .sortable-table-header__resize-btn:hover { + .sortable-table-header__resize-btn:hover, + .sortable-table-header__resize-btn--dragging { > div { - transform: scaleY(1.8); + // NOTE: to reuse the same scale multiplier as the header cell + // fixing the height to 16px which is the default height + height: 16px !important; + transform: scaleY(var(--resize-btn-scale-multiplier)); } } } From 306753ea0e8cf49d25874ca319fa0cfefdd8b8b6 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Fri, 20 Jun 2025 01:55:09 +0530 Subject: [PATCH 17/25] fix: scrollTo func instead of scrollToTop prop --- src/Shared/Components/Button/types.ts | 5 +---- src/Shared/Components/Table/utils.ts | 7 +++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Shared/Components/Button/types.ts b/src/Shared/Components/Button/types.ts index f26ea57fc..240bf10ff 100644 --- a/src/Shared/Components/Button/types.ts +++ b/src/Shared/Components/Button/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AnchorHTMLAttributes, ButtonHTMLAttributes, MutableRefObject, ReactElement, RefCallback } from 'react' +import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactElement } from 'react' import { LinkProps } from 'react-router-dom' import { TooltipProps } from '@Common/Tooltip/types' @@ -141,9 +141,6 @@ export type ButtonProps - | MutableRefObject } & ( | { /** diff --git a/src/Shared/Components/Table/utils.ts b/src/Shared/Components/Table/utils.ts index c959d87c0..00a852301 100644 --- a/src/Shared/Components/Table/utils.ts +++ b/src/Shared/Components/Table/utils.ts @@ -148,16 +148,19 @@ export const scrollToShowActiveElementIfNeeded = ( // therefore we need to conditionally scroll and that too in the horizontal direction only const { bottom, top } = activeElement.getBoundingClientRect() const { bottom: parentBottom, top: parentTop } = parent.getBoundingClientRect() + let { scrollTop } = parent // NOTE: please look into https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect // for more information what left and right pertain to if (top < parentTop) { // eslint-disable-next-line no-param-reassign - parent.scrollTop += top - parentTop - topMargin + scrollTop += top - parentTop - topMargin } if (bottom > parentBottom) { // eslint-disable-next-line no-param-reassign - parent.scrollTop += bottom - parentBottom + scrollTop += bottom - parentBottom } + + parent.scrollTo({ top: scrollTop, behavior: 'smooth' }) } From d1bf390fff2bb9f179d1bb5e731a3d04ede7ceab Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Mon, 23 Jun 2025 08:40:02 +0530 Subject: [PATCH 18/25] fix: bulk select all if not paginated --- .../Components/BulkSelection/BulkSelection.tsx | 18 ++++++++++++++++-- src/Shared/Components/BulkSelection/types.tsx | 1 + .../Components/Table/Table.component.tsx | 6 +++++- src/Shared/Components/Table/TableContent.tsx | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Shared/Components/BulkSelection/BulkSelection.tsx b/src/Shared/Components/BulkSelection/BulkSelection.tsx index b55074a21..349b484c8 100644 --- a/src/Shared/Components/BulkSelection/BulkSelection.tsx +++ b/src/Shared/Components/BulkSelection/BulkSelection.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { forwardRef } from 'react' +import { forwardRef, MouseEvent } from 'react' import { ReactComponent as ICChevronDown } from '../../../Assets/Icon/ic-chevron-down.svg' import { Checkbox, noop } from '../../../Common' @@ -24,7 +24,10 @@ import { BULK_DROPDOWN_TEST_ID, BulkSelectionOptionsLabels } from './constants' import { BulkSelectionEvents, BulkSelectionProps } from './types' const BulkSelection = forwardRef( - ({ showPagination, disabled = false, showChevronDownIcon = true }, forwardedRef) => { + ( + { showPagination, disabled = false, showChevronDownIcon = true, selectAllIfNotPaginated = false }, + forwardedRef, + ) => { const { handleBulkSelection, isChecked, checkboxValue, getSelectedIdentifiersCount } = useBulkSelection() const areOptionsSelected = getSelectedIdentifiersCount() > 0 const BulkSelectionItems: ActionMenuItemType[] = [ @@ -60,6 +63,16 @@ const BulkSelection = forwardRef( }) } + const onSinglePageSelectAll = (e: MouseEvent) => { + e.stopPropagation() + + handleBulkSelection({ + action: areOptionsSelected + ? BulkSelectionEvents.CLEAR_ALL_SELECTIONS + : BulkSelectionEvents.SELECT_ALL_ON_PAGE, + }) + } + return ( ( type="button" className="dc__position-abs dc__left-0 dc__top-0 h-100 w-100 dc__zi-1 p-0 dc__no-border dc__outline-none dc__transparent--unstyled" aria-label="Bulk selection dropdown" + onClick={selectAllIfNotPaginated && !showPagination ? onSinglePageSelectAll : noop} />
diff --git a/src/Shared/Components/BulkSelection/types.tsx b/src/Shared/Components/BulkSelection/types.tsx index 13a901a9a..5f19f1206 100644 --- a/src/Shared/Components/BulkSelection/types.tsx +++ b/src/Shared/Components/BulkSelection/types.tsx @@ -54,6 +54,7 @@ export interface BulkSelectionProps { */ showChevronDownIcon?: boolean disabled?: boolean + selectAllIfNotPaginated?: boolean } export enum SelectAllDialogStatus { diff --git a/src/Shared/Components/Table/Table.component.tsx b/src/Shared/Components/Table/Table.component.tsx index 1ba8872b7..1fc18f462 100644 --- a/src/Shared/Components/Table/Table.component.tsx +++ b/src/Shared/Components/Table/Table.component.tsx @@ -203,7 +203,11 @@ const TableWrapper = (tableProps: TableProps) => { return } - return {renderContent()} + return ( + + {renderContent()} + + ) } export default TableWrapper diff --git a/src/Shared/Components/Table/TableContent.tsx b/src/Shared/Components/Table/TableContent.tsx index feab20fdf..92f78025a 100644 --- a/src/Shared/Components/Table/TableContent.tsx +++ b/src/Shared/Components/Table/TableContent.tsx @@ -334,6 +334,7 @@ const TableContent = ({ key={field} showPagination={showPagination} showChevronDownIcon={false} + selectAllIfNotPaginated />
) From da9d3d9cd628dad01d74a80add594d49f1686d49 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Tue, 24 Jun 2025 11:08:55 +0530 Subject: [PATCH 19/25] fix: new pagination const --- src/Common/Pagination/constants.ts | 6 ++++++ src/Common/Pagination/index.tsx | 1 + src/Pages/ResourceBrowser/ResourceBrowser.Types.ts | 4 ---- src/Shared/Components/Table/InternalTable.tsx | 1 + src/Shared/Components/Table/types.ts | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Common/Pagination/constants.ts b/src/Common/Pagination/constants.ts index 095369d79..8699fd500 100644 --- a/src/Common/Pagination/constants.ts +++ b/src/Common/Pagination/constants.ts @@ -20,3 +20,9 @@ export const FALLBACK_PAGE_SIZE_OPTIONS = [ { value: 40, selected: false }, { value: 50, selected: false }, ] + +export const LARGE_PAGE_SIZE_OPTIONS = [ + { value: 100, selected: true }, + { value: 150, selected: false }, + { value: 200, selected: false }, +] diff --git a/src/Common/Pagination/index.tsx b/src/Common/Pagination/index.tsx index c88c8594c..a51cd3184 100644 --- a/src/Common/Pagination/index.tsx +++ b/src/Common/Pagination/index.tsx @@ -16,5 +16,6 @@ /* eslint-disable import/prefer-default-export */ // Disabling since might need to export types as well +export { LARGE_PAGE_SIZE_OPTIONS } from './constants' export { default as Pagination } from './Pagination' export type { PaginationProps } from './types' diff --git a/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts b/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts index baad07dc7..cb2d50b79 100644 --- a/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts +++ b/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts @@ -205,14 +205,10 @@ export interface GVKOptionValueType { } export interface GetResourceRecommenderResourceListPropsType { - resourceList: K8sResourceDetailType - reloadResourceListData: () => void setShowAbsoluteValuesInResourceRecommender: Dispatch> showAbsoluteValuesInResourceRecommender: boolean gvkOptions: GroupBase>[] areGVKOptionsLoading: boolean reloadGVKOptions: () => void gvkOptionsError: ServerErrors - isResourceListLoading: boolean - resourceListError: ServerErrors } diff --git a/src/Shared/Components/Table/InternalTable.tsx b/src/Shared/Components/Table/InternalTable.tsx index 53499b93c..0ccacd1ea 100644 --- a/src/Shared/Components/Table/InternalTable.tsx +++ b/src/Shared/Components/Table/InternalTable.tsx @@ -147,6 +147,7 @@ const InternalTable = ({ ...filterData, ...additionalProps, areRowsLoading: areFilteredRowsLoading, + filteredRows, ...(areColumnsConfigurable ? { allColumns: columns, diff --git a/src/Shared/Components/Table/types.ts b/src/Shared/Components/Table/types.ts index 26ca82c62..ca811a5e4 100644 --- a/src/Shared/Components/Table/types.ts +++ b/src/Shared/Components/Table/types.ts @@ -174,6 +174,7 @@ export type ViewWrapperProps = PropsWithChildren< AdditionalProps & Partial & { areRowsLoading: boolean + filteredRows: RowsType | null } & (T extends FiltersTypeEnum.URL ? Pick, 'updateSearchParams'> : {}) > From eb2b1b05a62d93dcb02405f97ebf3883a8af8487 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Tue, 24 Jun 2025 13:11:10 +0530 Subject: [PATCH 20/25] fix: bulk selection count logic --- src/Shared/Components/Table/TableContent.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Shared/Components/Table/TableContent.tsx b/src/Shared/Components/Table/TableContent.tsx index 92f78025a..e0a419e80 100644 --- a/src/Shared/Components/Table/TableContent.tsx +++ b/src/Shared/Components/Table/TableContent.tsx @@ -83,8 +83,7 @@ const TableContent = ({ rowsContainerRef.current.addEventListener('keydown', preventScrollByKeyboard) }, []) - const bulkSelectionCount = - isBulkSelectionApplied && rows ? filteredRows.length : (getSelectedIdentifiersCount?.() ?? 0) + const bulkSelectionCount = isBulkSelectionApplied && rows ? rows.length : (getSelectedIdentifiersCount?.() ?? 0) const visibleRows = useMemo(() => { const normalizedFilteredRows = filteredRows ?? [] From fa075f845486dde267b643704eb89928c3a562b5 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Tue, 24 Jun 2025 15:09:02 +0530 Subject: [PATCH 21/25] feat: add download icon and update icon map; add ResourceRecommenderActionMenuProps interface --- src/Assets/IconV2/ic-download.svg | 3 +++ src/Pages/ResourceBrowser/ResourceBrowser.Types.ts | 7 ++++++- src/Shared/Components/Icon/Icon.tsx | 2 ++ src/Shared/Components/index.ts | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/Assets/IconV2/ic-download.svg diff --git a/src/Assets/IconV2/ic-download.svg b/src/Assets/IconV2/ic-download.svg new file mode 100644 index 000000000..d3c67c66e --- /dev/null +++ b/src/Assets/IconV2/ic-download.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts b/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts index cb2d50b79..5fc03d918 100644 --- a/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts +++ b/src/Pages/ResourceBrowser/ResourceBrowser.Types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Dispatch, RefObject, SetStateAction } from 'react' +import { Dispatch, ReactNode, RefObject, SetStateAction } from 'react' import { GroupBase } from 'react-select' import { ServerErrors } from '@Common/ServerError' @@ -212,3 +212,8 @@ export interface GetResourceRecommenderResourceListPropsType { reloadGVKOptions: () => void gvkOptionsError: ServerErrors } + +export interface ResourceRecommenderActionMenuProps { + children: ReactNode + lastScannedOn: string +} diff --git a/src/Shared/Components/Icon/Icon.tsx b/src/Shared/Components/Icon/Icon.tsx index f6cbccd63..4a6a44f50 100644 --- a/src/Shared/Components/Icon/Icon.tsx +++ b/src/Shared/Components/Icon/Icon.tsx @@ -67,6 +67,7 @@ import { ReactComponent as ICDevtronJob } from '@IconsV2/ic-devtron-job.svg' import { ReactComponent as ICDisconnect } from '@IconsV2/ic-disconnect.svg' import { ReactComponent as ICDiscordFill } from '@IconsV2/ic-discord-fill.svg' import { ReactComponent as ICDockerhub } from '@IconsV2/ic-dockerhub.svg' +import { ReactComponent as ICDownload } from '@IconsV2/ic-download.svg' import { ReactComponent as ICEcr } from '@IconsV2/ic-ecr.svg' import { ReactComponent as ICEdit } from '@IconsV2/ic-edit.svg' import { ReactComponent as ICEmail } from '@IconsV2/ic-email.svg' @@ -280,6 +281,7 @@ export const iconMap = { 'ic-disconnect': ICDisconnect, 'ic-discord-fill': ICDiscordFill, 'ic-dockerhub': ICDockerhub, + 'ic-download': ICDownload, 'ic-ecr': ICEcr, 'ic-edit': ICEdit, 'ic-email': ICEmail, diff --git a/src/Shared/Components/index.ts b/src/Shared/Components/index.ts index b085ca5bc..b7394f0e3 100644 --- a/src/Shared/Components/index.ts +++ b/src/Shared/Components/index.ts @@ -80,6 +80,7 @@ export * from './ModalSidebarPanel' export * from './NumbersCount' export * from './PhoneInput' export * from './Plugin' +export * from './Popover' export * from './ProgressBar' export { default as QRCode } from './QRCode' export * from './ReactSelect' From e15749b32da64d4b984a39c2ba8b347b7041fbd3 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Wed, 25 Jun 2025 12:40:43 +0530 Subject: [PATCH 22/25] fix: filter if filter func provided --- src/Shared/Components/Table/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shared/Components/Table/utils.ts b/src/Shared/Components/Table/utils.ts index 00a852301..89209a5da 100644 --- a/src/Shared/Components/Table/utils.ts +++ b/src/Shared/Components/Table/utils.ts @@ -23,9 +23,9 @@ export const searchAndSortRows = ( filterData: UseFiltersReturnType, comparator?: Column['comparator'], ) => { - const { sortBy, sortOrder, areFiltersApplied } = filterData ?? {} + const { sortBy, sortOrder } = filterData ?? {} - const filteredRows = areFiltersApplied ? rows.filter((row) => filter(row, filterData)) : rows + const filteredRows = filter ? rows.filter((row) => filter(row, filterData)) : rows return comparator && sortBy ? filteredRows.sort( From f22829a23bdd876c7e24fd2ac91d4c1bb5a2cab7 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Thu, 26 Jun 2025 09:45:57 +0530 Subject: [PATCH 23/25] fix: add new clearFilters prop to table props --- .../UseRegisterShortcutProvider.tsx | 6 +++-- src/Common/Hooks/UseRegisterShortcut/types.ts | 3 +++ src/Shared/Components/Badge/Badge.tsx | 2 +- src/Shared/Components/Table/InternalTable.tsx | 3 ++- .../Components/Table/Table.component.tsx | 13 ++++++--- src/Shared/Components/Table/TableContent.tsx | 27 +++++-------------- src/Shared/Components/Table/types.ts | 4 +++ 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx b/src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx index 64272e1c3..36c349812 100644 --- a/src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx +++ b/src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx @@ -25,6 +25,7 @@ const IGNORE_TAGS_FALLBACK = ['input', 'textarea', 'select'] const DEFAULT_TIMEOUT = 300 const UseRegisterShortcutProvider = ({ + containerRef, ignoreTags, preventDefault = false, shortcutTimeout, @@ -120,8 +121,9 @@ const UseRegisterShortcutProvider = ({ if ( // NOTE: in case of custom events generated by password managers autofill, the event.key is not set !event.key || - ignoredTags.map((tag) => tag.toUpperCase()).indexOf((event.target as HTMLElement).tagName?.toUpperCase()) > - -1 || + (ignoredTags.map((tag) => tag.toUpperCase()).indexOf((event.target as HTMLElement).tagName?.toUpperCase()) > + -1 && + (!containerRef || containerRef.current?.contains(event.target as HTMLElement))) || (event.target as HTMLElement)?.role === 'textbox' || disableShortcutsRef.current ) { diff --git a/src/Common/Hooks/UseRegisterShortcut/types.ts b/src/Common/Hooks/UseRegisterShortcut/types.ts index 51083b60e..13171cf9d 100644 --- a/src/Common/Hooks/UseRegisterShortcut/types.ts +++ b/src/Common/Hooks/UseRegisterShortcut/types.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import { RefObject } from 'react' + import { IS_PLATFORM_MAC_OS } from '@Common/Constants' // NOTE: check this link for more info on keyboard keys: https://w3c.github.io/uievents-key/ @@ -81,6 +83,7 @@ export interface UseRegisterShortcutContextType { } export interface UseRegisterShortcutProviderType { + containerRef?: RefObject children: React.ReactNode /** * Defines how long after holding the keys down do we trigger the callback in milliseconds diff --git a/src/Shared/Components/Badge/Badge.tsx b/src/Shared/Components/Badge/Badge.tsx index f4bce4879..f3128c865 100644 --- a/src/Shared/Components/Badge/Badge.tsx +++ b/src/Shared/Components/Badge/Badge.tsx @@ -29,7 +29,7 @@ const Badge = ({ : {})} > {startIconProps && } - {label} + {label && {label}} {endIconProps && } ) diff --git a/src/Shared/Components/Table/InternalTable.tsx b/src/Shared/Components/Table/InternalTable.tsx index 0ccacd1ea..eb6721390 100644 --- a/src/Shared/Components/Table/InternalTable.tsx +++ b/src/Shared/Components/Table/InternalTable.tsx @@ -31,6 +31,7 @@ const InternalTable = ({ paginationVariant, RowActionsOnHoverComponent, pageSizeOptions, + clearFilters: userGivenUrlClearFilters, }: InternalTableProps) => { const { sortBy, @@ -113,7 +114,7 @@ const InternalTable = ({ if (!areFilteredRowsLoading && !filteredRows?.length && !loading) { return filtersVariant !== FiltersTypeEnum.NONE && areFiltersApplied ? ( - + ) : ( ) diff --git a/src/Shared/Components/Table/Table.component.tsx b/src/Shared/Components/Table/Table.component.tsx index 1fc18f462..8bf897e25 100644 --- a/src/Shared/Components/Table/Table.component.tsx +++ b/src/Shared/Components/Table/Table.component.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from 'react' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { noop, @@ -190,6 +190,7 @@ const UseUrlFilterWrapper = (props: FilterWrapperProps) => { const TableWrapper = (tableProps: TableProps) => { const { filtersVariant } = tableProps + const tableContainerRef = useRef(null) const renderContent = () => { if (filtersVariant === FiltersTypeEnum.STATE) { @@ -204,8 +205,14 @@ const TableWrapper = (tableProps: TableProps) => { } return ( - - {renderContent()} + +
+ {renderContent()} +
) } diff --git a/src/Shared/Components/Table/TableContent.tsx b/src/Shared/Components/Table/TableContent.tsx index e0a419e80..38462cc0a 100644 --- a/src/Shared/Components/Table/TableContent.tsx +++ b/src/Shared/Components/Table/TableContent.tsx @@ -34,7 +34,6 @@ const TableContent = ({ }: TableContentProps) => { const rowsContainerRef = useRef(null) const parentRef = useRef(null) - const activeRowRef = useRef(null) const bulkSelectionButtonRef = useRef(null) const headerRef = useRef(null) @@ -109,11 +108,6 @@ const TableContent = ({ useEffectAfterMount(() => { setActiveRowIndex(0) - scrollToShowActiveElementIfNeeded( - activeRowRef.current, - rowsContainerRef.current, - headerRef.current?.offsetHeight, - ) }, [offset, visibleRows]) useEffect(() => { @@ -129,19 +123,12 @@ const TableContent = ({ handleSorting(newSortBy) } - useEffect(() => { - // Focus the active row only when activeRowIndex changes. This ensures that focus is not stolen from other elements, - // such as the search bar, when it is already focused. For example, when typing in the search bar, the rows may be replaced - // with loading shimmers, causing activeRowRef to be null. During this time, activeRowIndex might reset to 0, but focus - // will not shift. However, when navigating with arrow keys, activeRowIndex changes, and activeRowRef will point to the - // correct row once it is mounted, allowing focus to update appropriately. - activeRowRef.current?.focus({ preventScroll: true }) - scrollToShowActiveElementIfNeeded( - activeRowRef.current, - rowsContainerRef.current, - headerRef.current?.offsetHeight, - ) - }, [activeRowIndex]) + const focusActiveRow = (node: HTMLDivElement) => { + if (node && !['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName.toUpperCase())) { + node.focus({ preventScroll: true }) + scrollToShowActiveElementIfNeeded(node, rowsContainerRef.current, headerRef.current?.offsetHeight) + } + } const onBulkOperationModalClose = () => { setBulkActionState(null) @@ -203,7 +190,7 @@ const TableContent = ({ return (
boolean + clearFilters?: () => void } | { filtersVariant: FiltersTypeEnum.STATE additionalFilterProps?: AdditionalFilterPropsType filter: (row: RowType, filterData: UseFiltersReturnType) => boolean + clearFilters?: never } | { filtersVariant: FiltersTypeEnum.NONE additionalFilterProps?: never filter?: never + clearFilters?: never } ) & ( @@ -318,6 +321,7 @@ export type TableProps = Pick< | 'loading' | 'ViewWrapper' | 'pageSizeOptions' + | 'clearFilters' > export type BulkActionStateType = string | null From 74c4046ad9816d9b7ee9fe0b42a845af5ae4a864 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Thu, 26 Jun 2025 13:53:57 +0530 Subject: [PATCH 24/25] fix: update version from 1.15.3-pre-4 to 1.15.3-beta-3 in package.json and package-lock.json --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75466eab9..c71d97b45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-pre-4", + "version": "1.15.3-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-pre-4", + "version": "1.15.3-beta-3", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index be84c550e..2c660d715 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-pre-4", + "version": "1.15.3-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 2e1f3802243e7e5a7f0f280704ff6e69c1683ca4 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Thu, 26 Jun 2025 13:56:37 +0530 Subject: [PATCH 25/25] fix: update version from 1.15.3-beta-3 to 1.15.3-beta-4 in package.json and package-lock.json --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c71d97b45..435802e6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-beta-3", + "version": "1.15.3-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-beta-3", + "version": "1.15.3-beta-4", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 2c660d715..3736c8e59 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.15.3-beta-3", + "version": "1.15.3-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js",