Skip to content

Commit 858529f

Browse files
author
Amrit Kashyap Borah
committed
chore: update common-lib version
2 parents 4fc11b3 + 85df074 commit 858529f

20 files changed

Lines changed: 370 additions & 85 deletions

File tree

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": "1.17.0-pre-8",
3+
"version": "1.17.0-pre-11",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { getNoMatchingResultText, SelectPicker, SelectPickerVariantType } from '@Shared/Components'
2+
import { ComponentSizeType } from '@Shared/constants'
3+
4+
import { ContextSwitcherTypes } from './types'
5+
import { customSelectFilterOption, getDisabledOptions } from './utils'
6+
7+
export const ContextSwitcher = ({
8+
inputId,
9+
options = [],
10+
inputValue,
11+
onInputChange,
12+
isLoading,
13+
value,
14+
onChange,
15+
placeholder,
16+
filterOption,
17+
formatOptionLabel,
18+
optionListError,
19+
reloadOptionList,
20+
classNamePrefix,
21+
}: ContextSwitcherTypes) => {
22+
const selectedOptions = options?.map((section) => ({
23+
...section,
24+
options: section?.label === 'Recently Visited' ? section.options?.slice(1) : section.options,
25+
}))
26+
return (
27+
<SelectPicker
28+
inputId={inputId}
29+
options={selectedOptions || []}
30+
inputValue={inputValue}
31+
onInputChange={onInputChange}
32+
isLoading={isLoading}
33+
noOptionsMessage={getNoMatchingResultText}
34+
onChange={onChange}
35+
value={value}
36+
variant={SelectPickerVariantType.BORDER_LESS}
37+
placeholder={placeholder}
38+
isOptionDisabled={getDisabledOptions}
39+
size={ComponentSizeType.xl}
40+
filterOption={filterOption || customSelectFilterOption}
41+
formatOptionLabel={formatOptionLabel}
42+
optionListError={optionListError}
43+
reloadOptionList={reloadOptionList}
44+
classNamePrefix={classNamePrefix}
45+
/>
46+
)
47+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { ContextSwitcher } from './ContextSwitcher'
2+
export type { ContextSwitcherTypes, RecentlyVisitedGroupedOptionsType, RecentlyVisitedOptions } from './types'
3+
export { getMinCharSearchPlaceholderGroup } from './utils'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { GroupBase } from 'react-select'
2+
3+
import { SelectPickerOptionType, SelectPickerProps } from '../SelectPicker'
4+
5+
export interface ContextSwitcherTypes
6+
extends Pick<
7+
SelectPickerProps,
8+
| 'placeholder'
9+
| 'onChange'
10+
| 'value'
11+
| 'isLoading'
12+
| 'onInputChange'
13+
| 'inputValue'
14+
| 'inputId'
15+
| 'formatOptionLabel'
16+
| 'filterOption'
17+
| 'optionListError'
18+
| 'reloadOptionList'
19+
| 'classNamePrefix'
20+
> {
21+
options: GroupBase<SelectPickerOptionType<string | number>>[]
22+
isAppDataAvailable?: boolean
23+
}
24+
25+
export interface RecentlyVisitedOptions extends SelectPickerOptionType<number> {
26+
isDisabled?: boolean
27+
isRecentlyVisited?: boolean
28+
}
29+
30+
export interface RecentlyVisitedGroupedOptionsType extends GroupBase<SelectPickerOptionType<number>> {
31+
label: string
32+
options: RecentlyVisitedOptions[]
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { SelectPickerProps } from '../SelectPicker'
2+
import { RecentlyVisitedGroupedOptionsType, RecentlyVisitedOptions } from './types'
3+
4+
export const getDisabledOptions = (option: RecentlyVisitedOptions): SelectPickerProps['isDisabled'] => option.isDisabled
5+
6+
export const customSelectFilterOption: SelectPickerProps['filterOption'] = (option, searchText: string) => {
7+
const label = option.data.label as string
8+
return option.data.value === 0 || label.toLowerCase().includes(searchText.toLowerCase())
9+
}
10+
11+
export const getMinCharSearchPlaceholderGroup = (resourceKind: string): RecentlyVisitedGroupedOptionsType => ({
12+
label: `All ${resourceKind}`,
13+
options: [{ value: 0, label: 'Type 3 characters to search', isDisabled: true }],
14+
})

src/Shared/Components/DocLink/DocLink.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MouseEvent } from 'react'
33
import { DOCUMENTATION_HOME_PAGE } from '@Common/Constants'
44
import { Button, ButtonComponentType, ButtonVariantType, Icon } from '@Shared/Components'
55
import { ComponentSizeType } from '@Shared/constants'
6+
import { useIsSecureConnection } from '@Shared/Hooks'
67
import { SidePanelTab, useMainContext } from '@Shared/Providers'
78

89
import { DocLinkProps } from './types'
@@ -24,6 +25,7 @@ export const DocLink = <T extends boolean = false>({
2425
}: DocLinkProps<T>) => {
2526
// HOOKS
2627
const { isEnterprise, setSidePanelConfig, isLicenseDashboard } = useMainContext()
28+
const isSecureConnection = useIsSecureConnection()
2729

2830
// CONSTANTS
2931
const documentationLink = getDocumentationUrl({
@@ -36,6 +38,7 @@ export const DocLink = <T extends boolean = false>({
3638
// HANDLERS
3739
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
3840
if (
41+
isSecureConnection &&
3942
!isExternalLink &&
4043
!openInNewTab &&
4144
!e.metaKey &&

src/Shared/Components/DocLink/utils.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export const getDocumentationUrl = <T extends boolean = false>({
1919
return docPath
2020
}
2121

22-
const utmPath = !isLicenseDashboard ? `?utm-source=product_${isEnterprise ? 'ent' : 'oss'}` : ''
22+
const utmPath = !isLicenseDashboard
23+
? `?utm_source=product_${isEnterprise ? 'ent' : 'oss'}&utm_medium=product_app&utm_campaign=docs_navigation`
24+
: ''
2325

2426
return `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/${docPath || ''}${utmPath}`
2527
}

src/Shared/Components/Header/HelpButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SliderButton } from '@typeform/embed-react'
55
import { DOCUMENTATION_HOME_PAGE, MAX_LOGIN_COUNT, URLS } from '@Common/Constants'
66
import { handleAnalyticsEvent } from '@Shared/Analytics'
77
import { ComponentSizeType } from '@Shared/constants'
8+
import { useIsSecureConnection } from '@Shared/Hooks'
89
import { AppThemeType, SidePanelTab, useMainContext, useTheme } from '@Shared/Providers'
910
import { InstallationType } from '@Shared/types'
1011

@@ -54,6 +55,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin
5455
showGettingStartedCard,
5556
} = useMainContext()
5657
const { appTheme } = useTheme()
58+
const isSecureConnection = useIsSecureConnection()
5759

5860
// REFS
5961
const typeFormSliderButtonRef = useRef(null)
@@ -73,7 +75,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin
7375

7476
const handleViewDocumentationClick: HelpButtonActionMenuProps['onClick'] = (_, e) => {
7577
// Opens documentation in side panel when clicked normally, or in a new tab when clicked with the meta/command key
76-
if (!e.metaKey) {
78+
if (isSecureConnection && !e.metaKey) {
7779
e.preventDefault()
7880
setSidePanelConfig((prev) => ({
7981
...prev,

src/Shared/Components/Header/ProfileMenu.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export const ProfileMenu = ({ user, onClick }: ProfileMenuProps) => {
5757
<div className="flex dc__content-space dc__gap-8 px-8 py-6">
5858
<div>
5959
<p className="m-0 fs-13 lh-1-5 fw-4 cn-9 dc__truncate">{user}</p>
60-
<p className="m-0 fs-12 lh-1-5 fw-4 cn-7 dc__truncate">{user}</p>
6160
</div>
6261
{getAlphabetIcon(user, 'dc__no-shrink m-0-imp fs-16 icon-dim-36')}
6362
</div>

0 commit comments

Comments
 (0)