Skip to content

Commit 9d23477

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into feat/plugin-policy
2 parents c6333b2 + fbd1c9d commit 9d23477

File tree

7 files changed

+57
-59
lines changed

7 files changed

+57
-59
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.6.1-beta-10",
3+
"version": "0.6.3-beta-1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CICDHistory/AppStatusDetailsChart.tsx

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { useMemo, useState } from 'react'
17+
import { useEffect, useMemo, useState } from 'react'
1818
import Tippy from '@tippyjs/react'
1919
import { useHistory } from 'react-router-dom'
2020
import { URLS } from '@Common/Constants'
2121
import { ReactComponent as InfoIcon } from '../../../Assets/Icon/ic-info-filled.svg'
2222
import { ReactComponent as Chat } from '../../../Assets/Icon/ic-chat-circle-dots.svg'
2323
import { AppStatusDetailsChartType, AggregatedNodes, STATUS_SORTING_ORDER, NodeFilters } from './types'
2424
import { StatusFilterButtonComponent } from './StatusFilterButtonComponent'
25-
import { DEPLOYMENT_STATUS, APP_STATUS_HEADERS, ComponentSizeType } from '../../constants'
25+
import { DEPLOYMENT_STATUS, APP_STATUS_HEADERS, ComponentSizeType, ALL_RESOURCE_KIND_FILTER } from '../../constants'
2626
import { IndexStore } from '../../Store'
2727
import { aggregateNodes } from '../../Helpers'
2828
import { Button, ButtonStyleType, ButtonVariantType } from '../Button'
@@ -35,7 +35,8 @@ const AppStatusDetailsChart = ({
3535
}: AppStatusDetailsChartType) => {
3636
const history = useHistory()
3737
const _appDetails = IndexStore.getAppDetails()
38-
const [currentFilter, setCurrentFilter] = useState('')
38+
const [currentFilter, setCurrentFilter] = useState<string>(ALL_RESOURCE_KIND_FILTER)
39+
const [flattenedNodes, setFlattenedNodes] = useState([])
3940

4041
const { appId, environmentId: envId } = _appDetails
4142

@@ -48,30 +49,35 @@ const AppStatusDetailsChart = ({
4849
() => aggregateNodes(_appDetails.resourceTree?.nodes || [], _appDetails.resourceTree?.podMetadata || []),
4950
[_appDetails],
5051
)
51-
const nodesKeyArray = Object.keys(nodes?.nodes || {})
52-
let flattenedNodes = []
53-
if (nodesKeyArray.length > 0) {
54-
for (let index = 0; index < nodesKeyArray.length; index++) {
55-
const element = nodes.nodes[nodesKeyArray[index]]
56-
// eslint-disable-next-line no-loop-func
57-
element.forEach((childElement) => {
58-
if (childElement.health) {
59-
flattenedNodes.push(childElement)
60-
}
61-
})
62-
}
63-
flattenedNodes.sort(
64-
(a, b) =>
65-
STATUS_SORTING_ORDER[a.health.status?.toLowerCase()] -
66-
STATUS_SORTING_ORDER[b.health.status?.toLowerCase()],
67-
)
6852

69-
if (filterRemoveHealth) {
70-
flattenedNodes = flattenedNodes.filter(
71-
(node) => node.health.status?.toLowerCase() !== DEPLOYMENT_STATUS.HEALTHY,
53+
useEffect(() => {
54+
const nodesKeyArray = Object.keys(nodes?.nodes || {})
55+
let newFlattenedNodes = []
56+
if (nodesKeyArray.length > 0) {
57+
for (let index = 0; index < nodesKeyArray.length; index++) {
58+
const element = nodes.nodes[nodesKeyArray[index]]
59+
// eslint-disable-next-line no-loop-func
60+
element.forEach((childElement) => {
61+
if (childElement.health) {
62+
newFlattenedNodes.push(childElement)
63+
}
64+
})
65+
}
66+
newFlattenedNodes.sort(
67+
(a, b) =>
68+
STATUS_SORTING_ORDER[a.health.status?.toLowerCase()] -
69+
STATUS_SORTING_ORDER[b.health.status?.toLowerCase()],
7270
)
71+
72+
if (filterRemoveHealth) {
73+
newFlattenedNodes = newFlattenedNodes.filter(
74+
(node) => node.health.status?.toLowerCase() !== DEPLOYMENT_STATUS.HEALTHY,
75+
)
76+
}
77+
78+
setFlattenedNodes(newFlattenedNodes)
7379
}
74-
}
80+
}, [`${nodes}`])
7581

7682
function getNodeMessage(kind: string, name: string) {
7783
if (
@@ -96,7 +102,11 @@ const AppStatusDetailsChart = ({
96102
<div className="pt-16 pl-20 pb-8">
97103
<div className="flexbox pr-20 w-100">
98104
<div>
99-
<StatusFilterButtonComponent nodes={flattenedNodes} handleFilterClick={onFilterClick} />
105+
<StatusFilterButtonComponent
106+
nodes={flattenedNodes}
107+
selectedTab={currentFilter}
108+
handleFilterClick={onFilterClick}
109+
/>
100110
</div>
101111
</div>
102112
</div>
@@ -115,7 +125,7 @@ const AppStatusDetailsChart = ({
115125
flattenedNodes
116126
.filter(
117127
(nodeDetails) =>
118-
currentFilter === 'all' ||
128+
currentFilter === ALL_RESOURCE_KIND_FILTER ||
119129
(currentFilter === NodeFilters.drifted && nodeDetails.hasDrift) ||
120130
nodeDetails.health.status?.toLowerCase() === currentFilter,
121131
)

src/Shared/Components/CICDHistory/StatusFilterButtonComponent.tsx

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
*/
1616

1717
/* eslint-disable eqeqeq */
18-
import { useEffect, useState } from 'react'
18+
import { ALL_RESOURCE_KIND_FILTER } from '@Shared/constants'
1919
import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
2020
import { PopupMenu, StyledRadioGroup as RadioGroup } from '../../../Common'
2121
import { NodeFilters, NodeStatus, StatusFilterButtonType } from './types'
22-
import { IndexStore } from '../../Store'
2322
import './StatusFilterButtonComponent.scss'
2423

25-
export const StatusFilterButtonComponent = ({ nodes, handleFilterClick }: StatusFilterButtonType) => {
26-
const [selectedTab, setSelectedTab] = useState('all')
27-
24+
export const StatusFilterButtonComponent = ({ nodes, selectedTab, handleFilterClick }: StatusFilterButtonType) => {
2825
const maxInlineFilterCount = 4
2926
let allNodeCount: number = 0
3027
let healthyNodeCount: number = 0
@@ -52,8 +49,12 @@ export const StatusFilterButtonComponent = ({ nodes, handleFilterClick }: Status
5249
allNodeCount += 1
5350
})
5451

52+
const handleInlineFilterClick = (e) => {
53+
handleFilterClick(e.target.value)
54+
}
55+
5556
const filterOptions = [
56-
{ status: 'all', count: allNodeCount, isSelected: selectedTab == 'all' },
57+
{ status: ALL_RESOURCE_KIND_FILTER, count: allNodeCount, isSelected: selectedTab == ALL_RESOURCE_KIND_FILTER },
5758
{ status: NodeStatus.Missing, count: missingNodeCount, isSelected: NodeStatus.Missing == selectedTab },
5859
{ status: NodeStatus.Degraded, count: failedNodeCount, isSelected: NodeStatus.Degraded == selectedTab },
5960
{
@@ -76,28 +77,6 @@ export const StatusFilterButtonComponent = ({ nodes, handleFilterClick }: Status
7677
const overflowFilters =
7778
validFilterOptions.length > maxInlineFilterCount ? validFilterOptions.slice(maxInlineFilterCount) : null
7879

79-
useEffect(() => {
80-
if (
81-
(selectedTab === NodeStatus.Healthy && healthyNodeCount === 0) ||
82-
(selectedTab === NodeStatus.Degraded && failedNodeCount === 0) ||
83-
(selectedTab === NodeStatus.Progressing && progressingNodeCount === 0) ||
84-
(selectedTab === NodeStatus.Missing && missingNodeCount === 0) ||
85-
(selectedTab === NodeFilters.drifted && driftedNodeCount === 0)
86-
) {
87-
setSelectedTab('all')
88-
} else if (handleFilterClick) {
89-
handleFilterClick(selectedTab)
90-
} else {
91-
IndexStore.updateFilterType(selectedTab.toUpperCase())
92-
}
93-
}, [nodes, selectedTab])
94-
95-
const handleTabSwitch = (event): void => {
96-
setSelectedTab(event.target.value)
97-
}
98-
99-
const handleMenuOptionClick = (status: string) => () => setSelectedTab(status)
100-
10180
const renderOverflowFilters = () =>
10281
overflowFilters ? (
10382
<PopupMenu autoClose>
@@ -113,7 +92,7 @@ export const StatusFilterButtonComponent = ({ nodes, handleFilterClick }: Status
11392
key={filter.status}
11493
type="button"
11594
className={`dc__transparent w-100 py-6 px-8 flex left dc__gap-8 fs-13 lh-20 fw-4 cn-9 ${filter.isSelected ? 'bcb-1' : 'bcn-0 dc__hover-n50'}`}
116-
onClick={handleMenuOptionClick(filter.status)}
95+
onClick={() => handleFilterClick(filter.status)}
11796
>
11897
<span
11998
className={`dc__app-summary__icon icon-dim-16 ${filter.status} ${filter.status}--node`}
@@ -134,7 +113,7 @@ export const StatusFilterButtonComponent = ({ nodes, handleFilterClick }: Status
134113
name="status-filter-button"
135114
initialTab={selectedTab}
136115
disabled={false}
137-
onChange={handleTabSwitch}
116+
onChange={handleInlineFilterClick}
138117
>
139118
{displayedInlineFilters.map((filter, index) => (
140119
<RadioGroup.Radio

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ export interface AppStatusDetailsChartType {
525525

526526
export interface StatusFilterButtonType {
527527
nodes: Array<Node>
528+
selectedTab: string
528529
handleFilterClick?: (selectedFilter: string) => void
529530
}
530531

src/Shared/constants.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,5 @@ export const DEFAULT_LOCKED_KEYS_CONFIG: Readonly<ConfigKeysWithLockType> = {
497497
config: [],
498498
allowed: false,
499499
}
500+
501+
export const ALL_RESOURCE_KIND_FILTER = 'all'

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export interface customEnv {
7777
FEATURE_STEP_WISE_LOGS_ENABLE?: boolean
7878
FEATURE_IMAGE_PROMOTION_ENABLE?: boolean
7979
FEATURE_CD_MANDATORY_PLUGINS_ENABLE?: boolean
80+
/**
81+
* If true, the direct permissions are hidden for non-super admins in user permissions
82+
*
83+
* @default false
84+
*/
85+
FEATURE_HIDE_USER_DIRECT_PERMISSIONS_FOR_NON_SUPER_ADMINS?: boolean
8086
FEATURE_CONFIG_DRIFT_ENABLE: boolean
8187
FEATURE_PROMO_EMBEDDED_BUTTON_TEXT?: string
8288
FEATURE_PROMO_EMBEDDED_MODAL_TITLE?: string

0 commit comments

Comments
 (0)