Skip to content

Commit 117c9a6

Browse files
committed
chore: misc comments
1 parent 99849a5 commit 117c9a6

File tree

9 files changed

+19
-21
lines changed

9 files changed

+19
-21
lines changed

src/Shared/Components/DevtronLicenseCard/types.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DevtronLicenseBaseDTO, LicenseErrorStruct } from '@Shared/index'
1+
import { DevtronLicenseBaseDTO, DevtronLicenseDTO } from '@Shared/index'
22

33
export enum LicenseStatus {
44
ACTIVE = 'ACTIVE',
@@ -23,11 +23,8 @@ export type DevtronLicenseCardProps = {
2323
}
2424
)
2525

26-
export type DevtronLicenseInfo = DevtronLicenseCardProps & {
27-
fingerprint: string
28-
showLicenseData: boolean
29-
licenseStatusError?: LicenseErrorStruct
30-
}
26+
export type DevtronLicenseInfo = DevtronLicenseCardProps &
27+
Pick<DevtronLicenseDTO, 'fingerprint' | 'showLicenseData' | 'licenseStatusError'>
3128

3229
export interface InstallFingerprintInfoProps extends Pick<DevtronLicenseBaseDTO, 'fingerprint'> {
3330
showHelpTooltip?: boolean

src/Shared/Components/Header/HeaderWithCreateButton/HeaderWithCreateButon.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { ReactComponent as DropDown } from '@Icons/ic-caret-down-small.svg'
2121
import { ReactComponent as ChartIcon } from '@Icons/ic-charts.svg'
2222
import { ReactComponent as AddIcon } from '@Icons/ic-add.svg'
2323
import { ReactComponent as JobIcon } from '@Icons/ic-k8s-job.svg'
24-
import { LicenseStatus } from '@Shared/Components/DevtronLicenseCard'
2524
import PageHeader from '../PageHeader'
2625
import { Modal, SERVER_MODE, URLS } from '../../../../Common'
2726
import { AppListConstants, ComponentSizeType } from '../../../constants'
2827
import './HeaderWithCreateButton.scss'
2928
import { useMainContext } from '../../../Providers'
29+
import { getIsShowingLicenseData } from '../utils'
3030

3131
export interface HeaderWithCreateButtonProps {
3232
headerName: string
@@ -39,8 +39,7 @@ export const HeaderWithCreateButton = ({ headerName }: HeaderWithCreateButtonPro
3939
const { serverMode, licenseData } = useMainContext()
4040
const [showCreateSelectionModal, setShowCreateSelectionModal] = useState(false)
4141

42-
const showingLicenseBar =
43-
licenseData && licenseData && (licenseData.licenseStatus !== LicenseStatus.ACTIVE || licenseData.isTrial)
42+
const showingLicenseBar = getIsShowingLicenseData(licenseData)
4443

4544
const handleCreateButton = () => {
4645
setShowCreateSelectionModal((prevState) => !prevState)

src/Shared/Components/Header/PageHeader.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
import { useEffect, useState } from 'react'
1818
import Tippy from '@tippyjs/react'
19-
import './pageHeader.css'
2019
import ReactGA from 'react-ga4'
2120
import { ReactComponent as ICMediumPaintBucket } from '@IconsV2/ic-medium-paintbucket.svg'
2221
import { ReactComponent as ICCaretDownSmall } from '@Icons/ic-caret-down-small.svg'
2322
import { ReactComponent as Close } from '@Icons/ic-close.svg'
2423
import { ReactComponent as Question } from '@Icons/ic-help-outline.svg'
2524
import { getAlphabetIcon, TippyCustomized, TippyTheme } from '../../../Common'
2625
import LogoutCard from '../LogoutCard'
27-
import { setActionWithExpiry, handlePostHogEventUpdate } from './utils'
26+
import { setActionWithExpiry, handlePostHogEventUpdate, getIsShowingLicenseData } from './utils'
2827
import { InstallationType, ServerInfo, PageHeaderType } from './types'
2928
import { getServerInfo } from './service'
3029
import GettingStartedCard from '../GettingStartedCard/GettingStarted'
@@ -34,7 +33,7 @@ import AnnouncementBanner from '../AnnouncementBanner/AnnouncementBanner'
3433
import { useMainContext, useTheme, useUserEmail } from '../../Providers'
3534
import { InfoIconTippy } from '../InfoIconTippy'
3635
import { IframePromoButton } from './IframePromoButton'
37-
import { LicenseStatus } from '../DevtronLicenseCard'
36+
import './pageHeader.scss'
3837

3938
const PageHeader = ({
4039
headerName,
@@ -198,7 +197,7 @@ const PageHeader = ({
198197
<span className="fs-12 fw-4 lh-18 pt-1 pb-1 pl-6 pr-6 ml-8 cn-9 bcy-5 br-4">Beta</span>
199198
)
200199

201-
const showingLicenseBar = licenseData && (licenseData.licenseStatus !== LicenseStatus.ACTIVE || licenseData.isTrial)
200+
const showingLicenseBar = getIsShowingLicenseData(licenseData)
202201

203202
const renderIframeButton = () => <IframePromoButton />
204203

src/Shared/Components/Header/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { updatePostHogEvent } from './service'
1818
import { LOGIN_COUNT } from '../../../Common'
19+
import { DevtronLicenseInfo, LicenseStatus } from '../DevtronLicenseCard'
1920

2021
const millisecondsInDay = 86400000
2122
export const getDateInMilliseconds = (days) => 1 + new Date().valueOf() + (days ?? 0) * millisecondsInDay
@@ -33,3 +34,6 @@ export const handlePostHogEventUpdate = async (eventName: string): Promise<void>
3334
export const setActionWithExpiry = (key: string, days: number): void => {
3435
localStorage.setItem(key, `${getDateInMilliseconds(days)}`)
3536
}
37+
38+
export const getIsShowingLicenseData = (licenseData: DevtronLicenseInfo) =>
39+
licenseData && (licenseData.licenseStatus !== LicenseStatus.ACTIVE || licenseData.isTrial)

src/Shared/Helpers.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
WebhookEventNameType,
6363
} from './types'
6464
import {
65-
CENTRAL_API_CONNECTIVITY_KEY,
65+
CENTRAL_API_LOCAL_STORAGE_KEY,
6666
DEPLOYMENT_STATUS,
6767
TIMELINE_STATUS,
6868
UNSAVED_CHANGES_PROMPT_MESSAGE,
@@ -1079,7 +1079,7 @@ export const clearCookieOnLogout = () => {
10791079

10801080
export const getCentralAPIHealthObjectFromLocalStorage = (): CentralAPILocalConfig => {
10811081
try {
1082-
const localStorageString = localStorage.getItem(CENTRAL_API_CONNECTIVITY_KEY)
1082+
const localStorageString = localStorage.getItem(CENTRAL_API_LOCAL_STORAGE_KEY)
10831083
const healthObj: CentralAPILocalConfig = JSON.parse(localStorageString)
10841084

10851085
const { lastUpdatedDate, isConnected, updateCount } = healthObj
@@ -1090,7 +1090,7 @@ export const getCentralAPIHealthObjectFromLocalStorage = (): CentralAPILocalConf
10901090
isConnected: isConnected || null,
10911091
}
10921092
} catch {
1093-
localStorage.removeItem(CENTRAL_API_CONNECTIVITY_KEY)
1093+
localStorage.removeItem(CENTRAL_API_LOCAL_STORAGE_KEY)
10941094
return {
10951095
lastUpdatedDate: '',
10961096
updateCount: 0,

src/Shared/constants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,4 @@ export const Routes = {
536536

537537
export const ENTERPRISE_SUPPORT_LINK = 'enterprise@devtron.ai'
538538

539-
export const CENTRAL_API_CONNECTIVITY_KEY = 'centralAPIConfig'
539+
export const CENTRAL_API_LOCAL_STORAGE_KEY = 'centralAPIConfig'

src/Shared/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ export type DevtronLicenseDTO<isCentralDashboard extends boolean = false> = Devt
10981098
export type CountryISO2Type = ParsedCountry['iso2']
10991099

11001100
export interface CentralAPILocalConfig {
1101-
lastUpdatedDate: string
1102-
isConnected: boolean | null
1103-
updateCount: number
1101+
lastUpdatedDate: string // date on which local storage is updated
1102+
isConnected: boolean | null // true/false acc to connection, null for first time
1103+
updateCount: number // number of times it has been updated, max 3
11041104
}

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export interface customEnv {
6363
NODE_REACT_APP_GIT_SHA?: string
6464
REACT_APP_GIT_SHA?: string
6565
NODE_ENV?: string
66-
LOGIN_DT_LOGO?: string
6766
SIDEBAR_DT_LOGO?: string
6867
ENABLE_EXTERNAL_ARGO_CD: boolean
6968
API_BATCH_SIZE: number

0 commit comments

Comments
 (0)