Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8bffec1
feat: add support for state based collapsible list
arunjaindev Sep 27, 2024
4f408af
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Oct 7, 2024
da3edaa
feat: add key for drift in Node
arunjaindev Oct 8, 2024
a2e1a61
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Oct 8, 2024
40330c2
Merge branch 'feat/collapsible-list-state' of https://github.com/devt…
arunjaindev Oct 8, 2024
02b5542
feat: add filter for drifted nodes in status filter button
arunjaindev Oct 9, 2024
df994f6
chore: use enum for drifted node
arunjaindev Oct 9, 2024
9551c44
chore: version bump
arunjaindev Oct 9, 2024
7115262
chore: edit typing for collapsible list
arunjaindev Oct 9, 2024
03ce4a3
Merge branch 'feat/collapsible-list-state' of https://github.com/devt…
arunjaindev Oct 9, 2024
858e259
chore: version bump
arunjaindev Oct 9, 2024
3ddb76c
chore: version bump
arunjaindev Oct 9, 2024
3e119ee
chore: rename Drifted filter to drifted
arunjaindev Oct 10, 2024
69cab58
chore: version bump
arunjaindev Oct 10, 2024
eca0ef1
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Oct 16, 2024
3ec13ae
feat: add flag for config drift feature
arunjaindev Oct 17, 2024
16e71b5
Merge pull request #361 from devtron-labs/feat/config-drift-flag
arunjaindev Oct 17, 2024
4f98578
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Oct 17, 2024
da74177
Merge branch 'feat/collapsible-list-state' of https://github.com/devt…
arunjaindev Oct 17, 2024
5df60eb
Merge branch 'feat/config-drift' of https://github.com/devtron-labs/d…
arunjaindev Oct 17, 2024
4a6ca3d
chore: version bump
arunjaindev Oct 17, 2024
2e4f158
chore: version bump
arunjaindev Oct 17, 2024
387d6e4
fix: hide drift filter when flag is off
arunjaindev Oct 18, 2024
fe512a6
Merge pull request #342 from devtron-labs/feat/config-drift
arunjaindev Oct 21, 2024
d7a667d
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Oct 21, 2024
ae14f5c
chore: version bump
arunjaindev Oct 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ConditionalWrap } from '@Common/Helper'
import { ReactComponent as ICExpand } from '@Icons/ic-expand.svg'

import { Collapse } from '../Collapse'
import { CollapsibleListProps } from './CollapsibleList.types'
import { CollapsibleListItem, CollapsibleListProps } from './CollapsibleList.types'
import './CollapsibleList.scss'

const renderWithTippy = (tippyProps: TippyProps) => (children: React.ReactElement) => (
Expand All @@ -18,6 +18,68 @@ const renderWithTippy = (tippyProps: TippyProps) => (children: React.ReactElemen
export const CollapsibleList = ({ config, onCollapseBtnClick }: CollapsibleListProps) => {
const { pathname } = useLocation()

const getTabContent = (item: CollapsibleListItem) => {
const { title, subtitle, iconConfig } = item
return (
<>
<div className="flexbox-col flex-grow-1 mw-none dc__align-start">
<span className="collapsible__item__title dc__truncate fs-13 lh-20">{title}</span>
{subtitle && <span className="dc__truncate fw-4 lh-1-5 cn-7">{subtitle}</span>}
</div>
{iconConfig && (
<ConditionalWrap
condition={!!iconConfig.tooltipProps}
wrap={renderWithTippy(iconConfig.tooltipProps)}
>
<iconConfig.Icon
{...iconConfig.props}
className={`icon-dim-20 dc__no-shrink cursor ${iconConfig.props?.className || ''}`}
/>
</ConditionalWrap>
)}
</>
)
}

const getTabItem = (item: CollapsibleListItem) => {
const { title, href, isActive, onClick, tabType } = item
if (tabType === 'navLink') {
return (
<NavLink
key={title}
to={href}
className="collapsible__item flexbox dc__align-items-center dc__gap-8 dc__no-decor br-4 py-6 px-8 cursor"
onClick={(e) => {
// Prevent navigation to the same page
if (href === pathname) {
e.preventDefault()
}
onClick?.(e)
}}
>
{getTabContent(item)}
</NavLink>
)
}
// Since is active is boolean we need to explicitly handle for null
return (
<button
key={title}
className={`collapsible__item flexbox dc__align-items-center dc__gap-8 dc__no-decor br-4 py-6 px-8 cursor ${isActive ? 'active' : ''} dc__unset-button-styles w-100`}
onClick={(e) => {
// Prevent navigation to the same page
if (isActive) {
e.preventDefault()
}
onClick?.(e)
}}
type="button"
>
{getTabContent(item)}
</button>
)
}

return (
<div className="mw-none bcn-0">
{config.map(({ id, header, headerIconConfig, items, noItemsText, isExpanded }) => (
Expand Down Expand Up @@ -61,40 +123,7 @@ export const CollapsibleList = ({ config, onCollapseBtnClick }: CollapsibleListP
</span>
</div>
) : (
items.map(({ title, href, iconConfig, subtitle, onClick }) => (
<NavLink
key={title}
to={href}
className="collapsible__item flexbox dc__align-items-center dc__gap-8 dc__no-decor br-4 py-6 px-8 cursor"
onClick={(e) => {
// Prevent navigation to the same page
if (href === pathname) {
e.preventDefault()
}
onClick?.(e)
}}
>
<div className="flexbox-col flex-grow-1 mw-none">
<span className="collapsible__item__title dc__truncate fs-13 lh-20">
{title}
</span>
{subtitle && (
<span className="dc__truncate fw-4 lh-1-5 cn-7">{subtitle}</span>
)}
</div>
{iconConfig && (
<ConditionalWrap
condition={!!iconConfig.tooltipProps}
wrap={renderWithTippy(iconConfig.tooltipProps)}
>
<iconConfig.Icon
{...iconConfig.props}
className={`icon-dim-20 dc__no-shrink cursor ${iconConfig.props?.className || ''}`}
/>
</ConditionalWrap>
)}
</NavLink>
))
items.map((item) => getTabItem(item))
)}
</div>
</Collapse>
Expand Down
38 changes: 29 additions & 9 deletions src/Shared/Components/CollapsibleList/CollapsibleList.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import React from 'react'
import { TippyProps } from '@tippyjs/react'

export interface CollapsibleListItem {
interface ButtonTab {
tabType: 'button'
/**
* Is tab active ( for button tab )
*/
isActive: boolean
/**
* The callback function to handle click events on the button.
*/
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void
href?: never
}

interface NavLinkTab {
tabType: 'navLink'
/**
* The URL of the nav link.
*/
href: string
/**
* The callback function to handle click events on the nav link.
*/
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void
isActive?: never
}

type ConditionalTabType = ButtonTab | NavLinkTab

export type CollapsibleListItem = ConditionalTabType & {
/**
* The title of the list item.
*/
Expand All @@ -27,14 +55,6 @@ export interface CollapsibleListItem {
*/
tooltipProps?: TippyProps
}
/**
* The URL of the nav link.
*/
href?: string
/**
* The callback function to handle click events on the nav link.
*/
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void
}

export interface CollapsibleListConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export type DeploymentConfigDiffSelectPickerProps =
selectPickerProps: SelectPickerProps
}

export interface DeploymentConfigDiffNavigationItem extends Pick<CollapsibleListItem, 'href' | 'title' | 'onClick'> {
export interface DeploymentConfigDiffNavigationItem extends Pick<CollapsibleListItem, 'title'> {
hasDiff?: boolean
href: string
onClick: (e: React.MouseEvent<HTMLAnchorElement>) => void
}

export interface DeploymentConfigDiffNavigationCollapsibleItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReactComponent as ICInfoOutlined } from '@Icons/ic-info-outlined.svg'
import { ReactComponent as ICDiffFileUpdated } from '@Icons/ic-diff-file-updated.svg'
import { StyledRadioGroup } from '@Common/index'

import { CollapsibleList } from '../CollapsibleList'
import { CollapsibleList, CollapsibleListConfig } from '../CollapsibleList'
import { DeploymentConfigDiffNavigationProps } from './DeploymentConfigDiff.types'

// LOADING SHIMMER
Expand All @@ -34,10 +34,11 @@ export const DeploymentConfigDiffNavigation = ({
}, [collapsibleNavList])

/** Collapsible List Config. */
const collapsibleListConfig = collapsibleNavList.map(({ items, ...resListItem }) => ({
const collapsibleListConfig: CollapsibleListConfig[] = collapsibleNavList.map(({ items, ...resListItem }) => ({
...resListItem,
isExpanded: expandedIds[resListItem.id],
items: items.map(({ hasDiff, ...resItem }) => ({
tabType: 'navLink',
...resItem,
...(hasDiff
? {
Expand Down