Skip to content

Commit 81f6547

Browse files
authored
Merge pull request #2702 from devtron-labs/feat/banner-fix
Feat/banner fix
2 parents f5e850a + f1dc706 commit 81f6547

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

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.13.0-pre-0",
7+
"@devtron-labs/devtron-fe-common-lib": "1.13.0-pre-1",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,21 @@ const App = () => {
7575
exact: true,
7676
condition: isDirectApprovalNotification && GenericDirectApprovalModal,
7777
component: <GenericDirectApprovalModal approvalType={approvalType} approvalToken={approvalToken} />,
78+
eligibleLocation: `/${approvalType?.toLowerCase()}/approve`,
7879
},
7980
{
8081
path: CommonURLS.LICENSE_AUTH,
8182
exact: false,
8283
condition: true,
8384
component: <ActivateLicense />,
85+
eligibleLocation: CommonURLS.LICENSE_AUTH,
8486
},
8587
{
8688
path: URLS.LOGIN,
8789
exact: false,
8890
condition: !window._env_.K8S_CLIENT,
8991
component: <Login />,
92+
eligibleLocation: URLS.LOGIN_SSO || URLS.LOGIN_ADMIN,
9093
},
9194
]
9295

src/components/common/Banner/Banner.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,9 @@ export const Banner = () => {
164164
const baseClassName = `w-100 ${config?.rootClassName || ''} ${getBannerTextColor(bannerVariant)} ${config?.isDismissible ? 'dc__grid banner--row dc__column-gap-16' : 'flex'}`
165165

166166
const shouldShowActionButton = () => {
167-
if (bannerVariant === BannerVariant.OFFLINE) return true
168167
if (bannerVariant === BannerVariant.ANNOUNCEMENT) return !!ANNOUNCEMENT_CONFIG.buttonLink
169-
if (
170-
bannerVariant === BannerVariant.VERSION_UPDATE ||
171-
bannerVariant === BannerVariant.INCOMPATIBLE_MICROSERVICES
172-
)
173-
return true
174-
return false
168+
if (bannerVariant === BannerVariant.ONLINE) return false
169+
return true
175170
}
176171

177172
const onClickCloseAnnouncementBanner = () => {

src/components/common/hooks/useVersionUpdate/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export interface VersionUpdateProps {
44
exact: boolean
55
condition: boolean
66
component: JSX.Element
7+
eligibleLocation: string
78
}[]
89
}

src/components/common/hooks/useVersionUpdate/useVersionUpdateReload.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export const useVersionUpdateReload = ({ toastEligibleRoutes }: VersionUpdatePro
3030

3131
const updateToastRef = useRef(null)
3232

33-
const toastEligibleRoutesMap = toastEligibleRoutes.reduce((acc, { path }) => {
34-
acc[path] = true
33+
const toastEligibleRoutesMap = toastEligibleRoutes.reduce((acc, { eligibleLocation }) => {
34+
acc[eligibleLocation] = true
3535
return acc
3636
}, {})
3737

@@ -127,7 +127,7 @@ export const useVersionUpdateReload = ({ toastEligibleRoutes }: VersionUpdatePro
127127

128128
const handleAppUpdate = () => {
129129
dismissToast({ updateToastRef })
130-
130+
refreshing.current = true
131131
// eslint-disable-next-line @typescript-eslint/no-floating-promises
132132
updateServiceWorker(true)
133133
}
@@ -140,7 +140,6 @@ export const useVersionUpdateReload = ({ toastEligibleRoutes }: VersionUpdatePro
140140
handleAppUpdate()
141141
refreshing.current = true
142142
} else {
143-
if (typeof setBGUpdated !== 'function') return
144143
setBGUpdated(true)
145144
}
146145
}
@@ -149,7 +148,6 @@ export const useVersionUpdateReload = ({ toastEligibleRoutes }: VersionUpdatePro
149148
if (!bgUpdated) {
150149
return
151150
}
152-
dismissToast({ updateToastRef })
153151
if (toastEligibleRoutesMap[location.pathname]) {
154152
updateToastRef.current = ToastManager.showToast(
155153
{
@@ -198,9 +196,7 @@ export const useVersionUpdateReload = ({ toastEligibleRoutes }: VersionUpdatePro
198196
.getRegistrations()
199197
.then((registrations) => registrations.forEach((reg) => reg.update()))
200198
if (doesNeedRefresh && !refreshing.current) {
201-
handleNeedRefresh(updateServiceWorker)
202-
} else if (bgUpdated) {
203-
dismissToast({ updateToastRef })
199+
handleAppUpdate()
204200
}
205201
}
206202
}, [location])

src/components/material/MaterialList.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class MaterialList extends Component<MaterialListProps, MaterialListState> {
217217
return <ErrorScreenManager code={this.state.statusCode} />
218218
}
219219
return (
220-
<div className={!this.props.isCreateAppView ? 'form__app-compose' : ''}>
220+
<div className={!this.props.isCreateAppView ? 'form__app-compose' : 'flexbox-col dc__gap-16'}>
221221
{!this.props.isCreateAppView && (
222222
<>
223223
{this.renderPageHeader()}
@@ -255,8 +255,7 @@ class MaterialList extends Component<MaterialListProps, MaterialListState> {
255255
isTemplateView={this.props.isTemplateView}
256256
isCreateAppView={this.props.isCreateAppView}
257257
handleSingleGitMaterialUpdate={this.handleSingleGitMaterialUpdate(mat.id)}
258-
/>
259-
)
258+
/> )
260259
})}
261260
</div>
262261
)

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,10 +1126,10 @@
11261126
dependencies:
11271127
"@jridgewell/trace-mapping" "0.3.9"
11281128

1129-
"@devtron-labs/[email protected]0":
1130-
version "1.13.0-pre-0"
1131-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.13.0-pre-0.tgz#38089a2a7ed4e19d9135a9e83b694908e70aaf8c"
1132-
integrity sha512-+2VLsrsxLLIu4iCeCFixif3rC8+xUvhSdPSb13vez15OT5k7XBAkUYAyHnDqBVh3uTQ3XyQwUONIRv4ffdAg5w==
1129+
"@devtron-labs/[email protected]1":
1130+
version "1.13.0-pre-1"
1131+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.13.0-pre-1.tgz#f84a94fdea17cc4054073d744a176bf63029015f"
1132+
integrity sha512-LZCcvTpp4knJBL4LhET1XD+eOK8u6etiUooxaTt7GcI8cQLU68dMuAKKqi6wXVVoJ0QSywq5AUadIycRE075XQ==
11331133
dependencies:
11341134
"@codemirror/lang-json" "6.0.1"
11351135
"@codemirror/lang-yaml" "6.1.2"

0 commit comments

Comments
 (0)