Skip to content

Commit 4815d32

Browse files
author
Mukul Tayal
committed
Merge branch 'main' of https://github.com/devtron-labs/dashboard into feat/lock-config-release
2 parents 53d17a5 + f7a244f commit 4815d32

21 files changed

+881
-506
lines changed

src/components/apiTokens/authorization.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function getOptions(customDate) {
2424
export const PermissionType = [
2525
{ value: 'SPECIFIC', label: 'Specific permissions' },
2626
{ value: 'SUPERADMIN', label: 'Super admin permission' },
27-
]
27+
] as const
2828

2929
const millisecondsInDay = 86400000
3030

src/components/ciPipeline/ciPipeline.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function getInitData(
5454
webhookEvents: pipelineMetaConfig.result.webhookEvents,
5555
ciPipelineSourceTypeOptions: pipelineMetaConfig.result.ciPipelineSourceTypeOptions,
5656
webhookConditionList: pipelineMetaConfig.result.webhookConditionList,
57-
triggerType: TriggerType.Auto,
57+
triggerType: window._env_.DEFAULT_CI_TRIGGER_TYPE_MANUAL ? TriggerType.Manual : TriggerType.Auto,
5858
beforeDockerBuildScripts: [],
5959
afterDockerBuildScripts: [],
6060
preBuildStage: emptyStepsData(),

src/components/command/command.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ function getGlobalConfigArguments(args, options): Promise<CommandSuggestionType>
496496
ref: null,
497497
data: {
498498
group: undefined,
499-
url: '/global-config/login-service',
499+
url: '/global-config/auth/login-service',
500500
isEOC: false,
501501
},
502502
},

src/components/common/ToastBody.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { toast } from 'react-toastify'
3-
import { TOAST_ACCESS_DENIED } from '../../config/constantMessaging'
3+
import { TOAST_ACCESS_DENIED } from '@devtron-labs/devtron-fe-common-lib'
44

55
export class ToastBody extends React.Component<{
66
title: string
@@ -62,4 +62,4 @@ export const toastAccessDenied = (title?: string, subtitle?: string) => {
6262
className: 'devtron-toast unauthorized',
6363
},
6464
)
65-
}
65+
}

src/components/globalConfigurations/GlobalConfiguration.tsx

Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { lazy, useState, useEffect, Suspense, useContext } from 'react'
1+
import React, { lazy, useState, useEffect, Suspense, useContext, createContext } from 'react'
22
import { Route, NavLink, Router, Switch, Redirect } from 'react-router-dom'
33
import { useHistory, useLocation } from 'react-router'
44
import { URLS } from '../../config'
55
import { ErrorBoundary, importComponentFromFELibrary } from '../common'
6-
import { showError, Progressing, Toggle } from '@devtron-labs/devtron-fe-common-lib'
6+
import { showError, Progressing, Toggle, ConditionalWrap, TippyCustomized, TippyTheme } from '@devtron-labs/devtron-fe-common-lib'
77
import arrowTriangle from '../../assets/icons/ic-chevron-down.svg'
88
import { AddNotification } from '../notifications/AddNotification'
99
import { ReactComponent as FormError } from '../../assets/icons/ic-warning.svg'
@@ -25,6 +25,7 @@ import { ModuleStatus } from '../v2/devtronStackManager/DevtronStackManager.type
2525
import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service'
2626
import { BodyType, ProtectedInputType } from './globalConfiguration.type'
2727
import CodeEditor from '../CodeEditor/CodeEditor'
28+
import { GlobalConfigurationProvider, useGlobalConfiguration } from './GlobalConfigurationProvider'
2829

2930
const HostURLConfiguration = lazy(() => import('../hostURL/HostURL'))
3031
const GitOpsConfiguration = lazy(() => import('../gitOps/GitOpsConfiguration'))
@@ -35,7 +36,6 @@ const ChartRepo = lazy(() => import('../chartRepo/ChartRepo'))
3536
const Notifier = lazy(() => import('../notifications/Notifications'))
3637
const Project = lazy(() => import('../project/ProjectList'))
3738
const UserGroup = lazy(() => import('../userGroups/UserGroup'))
38-
const SSOLogin = lazy(() => import('../login/SSOLogin'))
3939
const CustomChartList = lazy(() => import('../CustomChart/CustomChartList'))
4040
const ScopedVariables = lazy(() => import('../scopedVariables/ScopedVariables'))
4141
const TagListContainer = importComponentFromFELibrary('TagListContainer')
@@ -125,22 +125,24 @@ export default function GlobalConfiguration(props) {
125125
<main className="global-configuration">
126126
<PageHeader headerName="Global configurations" />
127127
<Router history={useHistory()}>
128-
<section className="global-configuration__navigation">
129-
<NavItem serverMode={serverMode} />
130-
</section>
131-
<section className="global-configuration__component-wrapper">
132-
<Suspense fallback={<Progressing pageLoader />}>
133-
<ErrorBoundary>
134-
<Body
135-
isSuperAdmin={props.isSuperAdmin}
136-
getHostURLConfig={getHostURLConfig}
137-
checkList={checkList}
138-
serverMode={serverMode}
139-
handleChecklistUpdate={handleChecklistUpdate}
140-
/>
141-
</ErrorBoundary>
142-
</Suspense>
143-
</section>
128+
<GlobalConfigurationProvider>
129+
<section className="global-configuration__navigation">
130+
<NavItem serverMode={serverMode} />
131+
</section>
132+
<section className="global-configuration__component-wrapper">
133+
<Suspense fallback={<Progressing pageLoader />}>
134+
<ErrorBoundary>
135+
<Body
136+
isSuperAdmin={props.isSuperAdmin}
137+
getHostURLConfig={getHostURLConfig}
138+
checkList={checkList}
139+
serverMode={serverMode}
140+
handleChecklistUpdate={handleChecklistUpdate}
141+
/>
142+
</ErrorBoundary>
143+
</Suspense>
144+
</section>
145+
</GlobalConfigurationProvider>
144146
</Router>
145147
</main>
146148
)
@@ -154,6 +156,8 @@ function NavItem({ serverMode }) {
154156
const [collapsedState, setCollapsedState] = useState<Record<string, boolean>>({
155157
Authorization: location.pathname.startsWith('/global-config/auth') ? false : true,
156158
})
159+
const { tippyConfig, setTippyConfig } = useGlobalConfiguration()
160+
157161
let moduleStatusTimer = null
158162
const ConfigRequired = [
159163
{
@@ -193,12 +197,17 @@ function NavItem({ serverMode }) {
193197
component: CustomChartList,
194198
isAvailableInEA: false,
195199
},
196-
{ name: 'SSO Login Services', href: URLS.GLOBAL_CONFIG_LOGIN, component: SSOLogin, isAvailableInEA: true },
197200
{
198201
name: 'Authorization',
199202
href: `${URLS.GLOBAL_CONFIG_AUTH}/users`,
200203
preventDefaultKey: URLS.GLOBAL_CONFIG_AUTH,
201204
group: [
205+
{
206+
name: 'SSO Login Services',
207+
dataTestId: 'authorization-sso-login-link',
208+
href: `${URLS.GLOBAL_CONFIG_AUTH}/login-service`,
209+
isAvailableInEA: true,
210+
},
202211
{
203212
name: 'User Permissions',
204213
dataTestId: 'authorization-user-permissions-link',
@@ -261,28 +270,57 @@ function NavItem({ serverMode }) {
261270
}
262271

263272
const renderNavItem = (route, className = '', preventOnClickOp = false) => {
273+
const onTippyClose = () => {
274+
// Resetting the tippy state
275+
setTippyConfig({
276+
showTippy: false
277+
})
278+
}
279+
264280
return (
265-
<NavLink
266-
to={`${route.href}`}
267-
key={route.href}
268-
activeClassName="active-route"
269-
data-testid={route.dataTestId}
270-
className={`${
271-
route.name === 'API tokens' &&
272-
location.pathname.startsWith(`${URLS.GLOBAL_CONFIG_AUTH}/${Routes.API_TOKEN}`)
273-
? 'active-route'
274-
: ''
275-
}`}
276-
onClick={(e) => {
277-
if (!preventOnClickOp) {
278-
handleGroupCollapsedState(e, route)
279-
}
280-
}}
281+
// FIXME: Reuse the renderNavItem function for all nav item to extend the tippy support to all links
282+
<ConditionalWrap
283+
condition={tippyConfig.showTippy && tippyConfig.showOnRoute === route.href}
284+
wrap={(children) => (
285+
<TippyCustomized
286+
theme={TippyTheme.black}
287+
className="w-300 ml-2"
288+
placement="right"
289+
showCloseButton
290+
trigger="manual"
291+
interactive
292+
showOnCreate
293+
arrow
294+
animation="shift-toward-subtle"
295+
onClose={onTippyClose}
296+
{...tippyConfig}
297+
>
298+
{children}
299+
</TippyCustomized>
300+
)}
281301
>
282-
<div className={`flexbox flex-justify ${className || ''}`} data-testid={`${route.name}-page`}>
283-
<div>{route.name}</div>
284-
</div>
285-
</NavLink>
302+
<NavLink
303+
to={`${route.href}`}
304+
key={`${route.name}-${route.href}`}
305+
activeClassName="active-route"
306+
data-testid={route.dataTestId}
307+
className={`${
308+
route.name === 'API tokens' &&
309+
location.pathname.startsWith(`${URLS.GLOBAL_CONFIG_AUTH}/${Routes.API_TOKEN}`)
310+
? 'active-route'
311+
: ''
312+
}`}
313+
onClick={(e) => {
314+
if (!preventOnClickOp) {
315+
handleGroupCollapsedState(e, route)
316+
}
317+
}}
318+
>
319+
<div className={`flexbox flex-justify ${className || ''}`} data-testid={`${route.name}-page`}>
320+
<div>{route.name}</div>
321+
</div>
322+
</NavLink>
323+
</ConditionalWrap>
286324
)
287325
}
288326

@@ -539,13 +577,6 @@ function Body({ getHostURLConfig, checkList, serverMode, handleChecklistUpdate,
539577
<Route key={URLS.GLOBAL_CONFIG_CUSTOM_CHARTS} path={URLS.GLOBAL_CONFIG_CUSTOM_CHARTS}>
540578
<CustomChartList />
541579
</Route>,
542-
<Route
543-
key={URLS.GLOBAL_CONFIG_LOGIN}
544-
path={URLS.GLOBAL_CONFIG_LOGIN}
545-
render={(props) => {
546-
return <SSOLogin {...props} />
547-
}}
548-
/>,
549580
<Route
550581
key={URLS.GLOBAL_CONFIG_AUTH}
551582
path={URLS.GLOBAL_CONFIG_AUTH}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { createContext, useContext, useState } from 'react'
2+
import { GlobalConfiguration, TippyConfig } from './types'
3+
4+
const globalConfigurationContext = createContext<GlobalConfiguration>({} as GlobalConfiguration)
5+
6+
export const GlobalConfigurationProvider = ({ children }) => {
7+
const [tippyConfig, setTippyConfig] = useState<TippyConfig>({} as TippyConfig)
8+
9+
return (
10+
<globalConfigurationContext.Provider
11+
value={{
12+
tippyConfig,
13+
setTippyConfig,
14+
}}
15+
>
16+
{children}
17+
</globalConfigurationContext.Provider>
18+
)
19+
}
20+
21+
export const useGlobalConfiguration = () => useContext(globalConfigurationContext)
22+
23+
// For using the provider in class based components
24+
export const withGlobalConfiguration = (Component) => (props) => {
25+
const globalConfiguration = useGlobalConfiguration()
26+
return <Component {...props} globalConfiguration={globalConfiguration} />
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { TippyCustomizedProps } from "@devtron-labs/devtron-fe-common-lib"
2+
3+
export type TippyConfig =
4+
| (Omit<TippyCustomizedProps, 'theme' | 'children' | 'placement'> & {
5+
showTippy: true
6+
/**
7+
* The nav link route on which the Tippy should be shown
8+
*/
9+
showOnRoute: string
10+
})
11+
| {
12+
showTippy: false
13+
}
14+
15+
export interface GlobalConfiguration {
16+
tippyConfig: TippyConfig
17+
setTippyConfig: (tippyConfig: TippyConfig) => void
18+
}

0 commit comments

Comments
 (0)