Skip to content

Commit b1b95d8

Browse files
authored
Merge pull request #172 from devtron-labs/feat/deployment-window-gc-2
Feat/deployment window gc 2
2 parents 0d9ef4c + 54e38e3 commit b1b95d8

File tree

7 files changed

+84
-8
lines changed

7 files changed

+84
-8
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.0.86-beta-2",
3+
"version": "0.0.86-beta-9",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Hooks/useStateFilters/types.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ import { UseUrlFiltersProps, UseUrlFiltersReturnType } from '../useUrlFilters'
1919
export interface UseStateFiltersProps<T> extends Pick<UseUrlFiltersProps<T, never>, 'initialSortKey'> {}
2020

2121
export interface UseStateFiltersReturnType<T>
22-
extends Pick<UseUrlFiltersReturnType<T>, 'sortBy' | 'sortOrder' | 'handleSorting' | 'clearFilters'> {}
22+
extends Pick<
23+
UseUrlFiltersReturnType<T>,
24+
| 'sortBy'
25+
| 'sortOrder'
26+
| 'handleSorting'
27+
| 'clearFilters'
28+
| 'changePage'
29+
| 'changePageSize'
30+
| 'offset'
31+
| 'pageSize'
32+
> {}
33+
34+
export interface PaginationType<T> extends Pick<UseUrlFiltersReturnType<T>, 'pageSize'> {
35+
pageNumber: number
36+
}

src/Common/Hooks/useStateFilters/useStateFilters.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
*/
1616

1717
import { useState } from 'react'
18-
import { SortingOrder } from '../../Constants'
19-
import { UseStateFiltersProps, UseStateFiltersReturnType } from './types'
18+
import { DEFAULT_BASE_PAGE_SIZE, SortingOrder } from '../../Constants'
19+
import { PaginationType, UseStateFiltersProps, UseStateFiltersReturnType } from './types'
20+
import { DEFAULT_PAGE_NUMBER } from '../useUrlFilters/constants'
2021

2122
/**
2223
* Generic hook for implementing state based pagination, search, sorting.
@@ -38,9 +39,29 @@ const useStateFilters = <T = string,>({
3839
sortOrder: SortingOrder.ASC,
3940
sortBy: initialSortKey,
4041
})
41-
4242
const { sortBy, sortOrder } = sortingConfig
4343

44+
const [pagination, setPagination] = useState<PaginationType<T>>({
45+
pageSize: DEFAULT_BASE_PAGE_SIZE,
46+
pageNumber: DEFAULT_PAGE_NUMBER,
47+
})
48+
const offset = pagination.pageSize * (pagination.pageNumber - 1)
49+
50+
const changePage = (pageNo: number): void => {
51+
setPagination({
52+
...pagination,
53+
pageNumber: pageNo,
54+
})
55+
}
56+
57+
const changePageSize = (_pageSize: number): void => {
58+
setPagination({
59+
...pagination,
60+
pageSize: _pageSize,
61+
pageNumber: DEFAULT_PAGE_NUMBER,
62+
})
63+
}
64+
4465
const handleSorting = (_sortBy: T) => {
4566
let order: SortingOrder
4667

@@ -55,6 +76,10 @@ const useStateFilters = <T = string,>({
5576
sortBy: _sortBy,
5677
sortOrder: order,
5778
}))
79+
setPagination({
80+
...pagination,
81+
pageNumber: DEFAULT_PAGE_NUMBER,
82+
})
5883
}
5984

6085
const clearFilters = () => {
@@ -68,6 +93,10 @@ const useStateFilters = <T = string,>({
6893
...sortingConfig,
6994
handleSorting,
7095
clearFilters,
96+
...pagination,
97+
changePage,
98+
changePageSize,
99+
offset,
71100
}
72101
}
73102

src/Common/MultiSelectCustomization.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export const SingleSelectOption = (props) => {
6161
)
6262
}
6363

64+
/**
65+
* Multi value container
66+
*/
67+
6468
export const MultiValueContainer = (props) => {
6569
const { children, data, innerProps, selectProps } = props
6670
const { label, value } = data
@@ -71,6 +75,28 @@ export const MultiValueContainer = (props) => {
7175
</components.MultiValueContainer>
7276
)
7377
}
78+
/**
79+
*
80+
* Multi value container with count
81+
*/
82+
export const MultiValueContainerWithCount = (props: any) => {
83+
const { children, data, innerProps, selectProps } = props
84+
const selectedLen = selectProps.value?.length ?? 0
85+
86+
return (
87+
<components.MultiValueContainer {...{ data, innerProps, selectProps }}>
88+
{(!selectProps.menuIsOpen || !selectProps.inputValue) && (
89+
<span className="cn-9 fs-13 lh-20">
90+
{selectProps.placeholder}
91+
{selectedLen > 0 && (
92+
<span className="bcb-5 cn-0 fw-6 fs-12 br-8 ml-4 pr-8 pl-8">{selectedLen}</span>
93+
)}
94+
</span>
95+
)}
96+
{children[1]}
97+
</components.MultiValueContainer>
98+
)
99+
}
74100

75101
export const ClearIndicator = (props) => {
76102
const {

src/Shared/Components/FeatureDescription/FeatureTitleWithInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const FeatureTitleWithInfo = ({
4646
>
4747
<div className="flexbox dc__align-items-center dc__gap-4">
4848
<BreadCrumb breadcrumbs={breadCrumbs} />
49-
<ICHelpOutline className={`${iconClassName} icon-dim-20 cursor`} onClick={onClickInfoIcon} />
49+
<ICHelpOutline className={`${iconClassName} icon-dim-20 cursor fcn-6`} onClick={onClickInfoIcon} />
5050
</div>
5151

5252
{children}

src/Shared/Components/ReactSelect/utils.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import Tippy from '@tippyjs/react'
1818
import { components } from 'react-select'
1919
import { Progressing, stopPropagation } from '../../../Common'
20+
import { ReactComponent as ICCaretDown } from '../../../Assets/Icon/ic-chevron-down.svg'
2021

2122
export const getCommonSelectStyle = (styleOverrides = {}) => ({
2223
container: (base, state) => ({
@@ -165,4 +166,10 @@ export const GroupHeading = (props: any) => {
165166
)
166167
}
167168

169+
export const DropdownIndicator = (props) => (
170+
<components.DropdownIndicator {...props}>
171+
<ICCaretDown className="icon-dim-20 icon-n6" data-testId />
172+
</components.DropdownIndicator>
173+
)
174+
168175
export const commonSelectStyles = getCommonSelectStyle()

0 commit comments

Comments
 (0)