Skip to content

Commit 377b7d2

Browse files
Merge pull request #2712 from devtron-labs/feat/switch
feat: switch
2 parents f94f49b + 4e30c40 commit 377b7d2

File tree

12 files changed

+320
-188
lines changed

12 files changed

+320
-188
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ FEATURE_DEFAULT_AUTHENTICATED_VIEW_ENABLE=false
6969
GATEKEEPER_URL=https://license.devtron.ai/dashboard
7070
FEATURE_AI_INTEGRATION_ENABLE=false
7171
LOGIN_PAGE_IMAGE=
72-
FEATURE_REDFISH_NODE_ENABLE=false
72+
FEATURE_REDFISH_NODE_ENABLE=false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.14.1-pre-1",
7+
"@devtron-labs/devtron-fe-common-lib": "1.14.1-pre-2",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/Sidebar.tsx

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { generatePath, NavLink, useParams, useRouteMatch } from 'react-router-dom'
1818

19-
import { Icon, IconName, ModalSidebarPanel } from '@devtron-labs/devtron-fe-common-lib'
19+
import { Icon, IconName, ModalSidebarPanel, SERVER_MODE, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
2020

2121
import { importComponentFromFELibrary } from '@Components/common'
2222

@@ -27,47 +27,53 @@ const isFELibAvailable = importComponentFromFELibrary('isFELibAvailable', null,
2727

2828
const Sidebar = () => {
2929
const { path } = useRouteMatch()
30+
const { serverMode } = useMainContext()
3031
const { type } = useParams<CreateClusterParams>()
3132

3233
const selectedSidebarElement = SIDEBAR_CONFIG[type]
3334

3435
return (
3536
<div className="w-250 p-20 flexbox-col dc__gap-24 dc__no-shrink dc__overflow-auto">
3637
<div className="flexbox-col">
37-
{Object.entries(SIDEBAR_CONFIG).map(([key, { title, iconName, isEnterprise, dataTestId }]) => {
38-
const isSelected = type.toLowerCase() === key.toLowerCase()
38+
{Object.entries(SIDEBAR_CONFIG).map(
39+
([key, { title, iconName, isEnterprise, dataTestId, hideInEAMode }]) => {
40+
if (hideInEAMode && serverMode === SERVER_MODE.EA_ONLY) {
41+
return null
42+
}
43+
const isSelected = type.toLowerCase() === key.toLowerCase()
3944

40-
return (
41-
<NavLink
42-
data-testid={dataTestId}
43-
key={key}
44-
className={`dc__transparent flex left dc__gap-8 py-6 px-8 br-4 ${isSelected ? 'bcb-1' : 'dc__hover-n50'}`}
45-
to={generatePath(path, { type: key })}
46-
>
47-
<span className="dc__fill-available-space dc__no-shrink icon-dim-16">
48-
<Icon name={iconName as IconName} color={isSelected ? 'B500' : 'N600'} />
49-
</span>
50-
51-
<span
52-
className={`fs-13 lh-20 dc__truncate flex-grow-1 ${isSelected ? 'cb-5 fw-6' : 'cn-9'}`}
45+
return (
46+
<NavLink
47+
data-testid={dataTestId}
48+
key={key}
49+
className={`dc__transparent flex left dc__gap-8 py-6 px-8 br-4 ${isSelected ? 'bcb-1' : 'dc__hover-n50'}`}
50+
to={generatePath(path, { type: key })}
5351
>
54-
{title}
55-
</span>
52+
<span className="dc__fill-available-space dc__no-shrink icon-dim-16">
53+
<Icon name={iconName as IconName} color={isSelected ? 'B500' : 'N600'} />
54+
</span>
55+
56+
<span
57+
className={`fs-13 lh-20 dc__truncate flex-grow-1 ${isSelected ? 'cb-5 fw-6' : 'cn-9'}`}
58+
>
59+
{title}
60+
</span>
5661

57-
{isEnterprise && !isFELibAvailable && (
58-
<Icon
59-
name="ic-enterprise-feat"
60-
color="Y700"
61-
tooltipProps={{
62-
content: 'This is an enterprise only feature',
63-
placement: 'right',
64-
alwaysShowTippyOnHover: true,
65-
}}
66-
/>
67-
)}
68-
</NavLink>
69-
)
70-
})}
62+
{isEnterprise && !isFELibAvailable && (
63+
<Icon
64+
name="ic-enterprise-feat"
65+
color="Y700"
66+
tooltipProps={{
67+
content: 'This is an enterprise only feature',
68+
placement: 'right',
69+
alwaysShowTippyOnHover: true,
70+
}}
71+
/>
72+
)}
73+
</NavLink>
74+
)
75+
},
76+
)}
7177
</div>
7278

7379
<div className="divider__secondary--horizontal" />

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/constants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ export const SIDEBAR_CONFIG: SidebarConfigType = {
4444
</>
4545
),
4646
isEnterprise: true,
47+
hideInEAMode: true,
4748
},
4849
} as const

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type SidebarConfigType = Record<
1515
dataTestId: string
1616
documentationHeader?: string
1717
isEnterprise?: true
18+
hideInEAMode?: true
1819
}
1920
>
2021

src/components/login/Login.tsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { TOKEN_COOKIE_NAME, URLS } from '../../config'
4343
import { getSSOConfigList } from '../../Pages/GlobalConfigurations/Authorization/SSOLoginServices/service'
4444
import { dashboardAccessed } from '../../services/service'
4545
import { LOGIN_CARD_ANIMATION_VARIANTS, SSOProvider } from './constants'
46-
import { SSOConfigLoginList } from './login.types'
4746
import { LoginForm } from './LoginForm'
4847

4948
import './login.scss'
@@ -54,13 +53,14 @@ const getTermsAndConditions = importComponentFromFELibrary('getTermsAndCondition
5453

5554
const Login = () => {
5655
const [continueUrl, setContinueUrl] = useState('')
57-
const [loginList, setLoginList] = useState<SSOConfigLoginList[]>([])
5856

5957
const { searchParams } = useSearchString()
6058
const location = useLocation()
6159
const history = useHistory()
6260

63-
const [initLoading, initResult] = useAsync(() => Promise.allSettled([getSSOConfigList(), dashboardAccessed()]), [])
61+
const [ssoListLoading, ssoListResponse] = useAsync(getSSOConfigList, [])
62+
63+
const loginList = ssoListResponse?.result ?? []
6464

6565
const setLoginNavigationURL = () => {
6666
let queryParam = searchParams.continue
@@ -96,26 +96,10 @@ const Login = () => {
9696

9797
useEffect(() => {
9898
setLoginNavigationURL()
99+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
100+
dashboardAccessed()
99101
}, [])
100102

101-
useEffect(() => {
102-
if (initResult && !initLoading) {
103-
const [ssoLoginListResponse, dashboardAccessesResponse] = initResult
104-
if (ssoLoginListResponse.status === 'fulfilled' && ssoLoginListResponse.value.result) {
105-
setLoginList(ssoLoginListResponse.value.result as SSOConfigLoginList[])
106-
}
107-
108-
if (
109-
typeof Storage !== 'undefined' &&
110-
!localStorage.getItem('isDashboardAccessed') &&
111-
dashboardAccessesResponse.status === 'fulfilled' &&
112-
dashboardAccessesResponse.value.result
113-
) {
114-
localStorage.setItem('isDashboardAccessed', 'true')
115-
}
116-
}
117-
}, [initLoading, initResult])
118-
119103
const onClickSSO = () => {
120104
if (typeof Storage !== 'undefined') {
121105
localStorage.setItem('isSSOLogin', 'true')
@@ -127,7 +111,7 @@ const Login = () => {
127111

128112
const renderSSOLoginPage = () => (
129113
<div className="flexbox-col dc__gap-12 p-36">
130-
{initLoading && !loginList.length && (
114+
{ssoListLoading && !loginList.length && (
131115
<Button
132116
variant={ButtonVariantType.secondary}
133117
text="Checking SSO"

src/components/login/login.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export interface SSOConfigLoginList extends Pick<SSOConfigDTO, 'id' | 'active' |
2121
}
2222

2323
export interface LoginFormType {
24-
loginList: SSOConfigLoginList[]
24+
loginList: SSOConfigDTO[]
2525
}

src/components/v2/values/chartValuesDiff/ChartValuesView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const ChartValuesView = ({
160160
presetValueId: string
161161
envId: string
162162
}>()
163-
const { serverMode, isManifestScanningEnabled } = useMainContext()
163+
const { serverMode } = useMainContext()
164164
const { handleDownload } = useDownload()
165165
const chartValuesAbortRef = useRef<AbortController>(new AbortController())
166166
const [chartValuesList, setChartValuesList] = useState<ChartValuesType[]>(chartValuesListFromParent || [])
@@ -1810,7 +1810,7 @@ const ChartValuesView = ({
18101810
)}
18111811
</div>
18121812
{!isExternalApp &&
1813-
isManifestScanningEnabled &&
1813+
serverMode === SERVER_MODE.FULL &&
18141814
(isDeployChartView || isUpdateAppView) &&
18151815
ToggleSecurityScan && (
18161816
<ToggleSecurityScan

src/css/base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,10 @@ button.anchor {
28632863
width: 10px;
28642864
}
28652865

2866+
.w-12 {
2867+
width: 12px;
2868+
}
2869+
28662870
.w-14 {
28672871
width: 14px;
28682872
}

src/services/service.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,17 @@ export function getClusterListMinWithoutAuth(): Promise<ClusterListResponse> {
525525
return get(URL)
526526
}
527527

528-
export function dashboardAccessed() {
529-
return get(Routes.DASHBOARD_ACCESSED)
528+
export const dashboardAccessed = async () => {
529+
try {
530+
const isDashboardAccessed = localStorage.getItem('isDashboardAccessed')
531+
if (isDashboardAccessed) {
532+
return
533+
}
534+
await get(Routes.DASHBOARD_ACCESSED)
535+
localStorage.setItem('isDashboardAccessed', 'true')
536+
} catch {
537+
// do noting
538+
}
530539
}
531540

532541
export function dashboardLoggedIn() {

0 commit comments

Comments
 (0)