Skip to content

Commit e5ea790

Browse files
author
Amrit Kashyap Borah
committed
Merge branch 'feature/create-cluster' of github.com:devtron-labs/devtron-fe-common-lib into feat/edit-cluster
2 parents 67cc30e + c495ff5 commit e5ea790

10 files changed

Lines changed: 98 additions & 43 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.10.0-patch-6",
3+
"version": "1.10.0-patch-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CodeMirror/CodeEditorRenderer.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Progressing } from '@Common/Progressing'
2323

2424
import { useCodeEditorContext } from './CodeEditor.context'
2525
import { CodeEditorRendererProps } from './types'
26-
import { getCodeEditorHeight, getRevertControlButton, updateDiffMinimapValues } from './utils'
26+
import { getCodeEditorHeight, getRevertControlButton, getScanLimit, updateDiffMinimapValues } from './utils'
2727
import { DiffMinimap } from './Extensions'
2828

2929
export const CodeEditorRenderer = ({
@@ -180,6 +180,8 @@ export const CodeEditorRenderer = ({
180180
useEffect(() => {
181181
// DIFF VIEW INITIALIZATION
182182
if (!loading && codeMirrorMergeParentRef.current) {
183+
const scanLimit = getScanLimit(lhsValue, value)
184+
183185
codeMirrorMergeInstance?.destroy()
184186

185187
const codeMirrorMergeView = new MergeView({
@@ -192,7 +194,7 @@ export const CodeEditorRenderer = ({
192194
extensions: [...modifiedViewExtensions, modifiedUpdateListener],
193195
},
194196
...(!readOnly ? { revertControls: 'a-to-b', renderRevertControl: getRevertControlButton } : {}),
195-
diffConfig: { scanLimit: 5000 },
197+
diffConfig: { scanLimit, timeout: 5000 },
196198
parent: codeMirrorMergeParentRef.current,
197199
})
198200
setCodeMirrorMergeInstance(codeMirrorMergeView)
@@ -212,7 +214,7 @@ export const CodeEditorRenderer = ({
212214
extensions: diffMinimapExtensions,
213215
},
214216
gutter: false,
215-
diffConfig: { scanLimit: 5000 },
217+
diffConfig: { scanLimit, timeout: 5000 },
216218
parent: diffMinimapParentRef.current,
217219
})
218220

@@ -272,6 +274,11 @@ export const CodeEditorRenderer = ({
272274

273275
return diffMode ? (
274276
<div className={`flexbox w-100 ${componentSpecificThemeClass} ${codeEditorParentClassName}`}>
277+
{!codeMirrorMergeInstance && (
278+
<div className="flex h-100 w-100">
279+
<p>Calculating diff for large file. Please wait...</p>
280+
</div>
281+
)}
275282
<div
276283
ref={codeMirrorMergeParentRef}
277284
className={`cm-merge-theme flex-grow-1 h-100 dc__overflow-hidden ${readOnly ? 'code-editor__read-only' : ''}`}

src/Common/CodeMirror/Extensions/findAndReplace.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,11 @@ export const codeEditorFindReplace = (view: EditorView): Panel => {
457457
}
458458

459459
const mount = () => {
460-
const findField = document.querySelector('[data-code-editor-find]') as HTMLInputElement
461-
findField?.focus()
462-
findField?.select()
460+
requestAnimationFrame(() => {
461+
const findField = document.querySelector('[data-code-editor-find]') as HTMLInputElement
462+
findField?.focus()
463+
findField?.select()
464+
})
463465
}
464466

465467
const update = ({ transactions, docChanged, state, startState }: ViewUpdate) => {

src/Common/CodeMirror/codeEditor.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@
267267
&.cm-merge-a .cm-changedText,
268268
.cm-deletedChunk .cm-deletedText,
269269
&.cm-merge-a .cm-changedLineGutter {
270-
background: var(--R300);
270+
background: var(--R500);
271271
}
272272

273273
&.cm-merge-b .cm-changedLine,
274274
&.cm-merge-b .cm-changedText,
275275
&.cm-merge-b .cm-changedLineGutter {
276-
background: var(--G300);
276+
background: var(--G500);
277277
}
278278
}
279279

src/Common/CodeMirror/utils.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,28 @@ export const updateDiffMinimapValues = (view: MergeView, transactions: readonly
168168
})
169169
}
170170

171+
export const getScanLimit = (lhsValue: string, value: string) => {
172+
const numberOfLines = Math.max((lhsValue ?? '').split('\n').length, (value ?? '').split('\n').length)
173+
174+
if (numberOfLines <= 5000) {
175+
return 5000
176+
}
177+
178+
if (numberOfLines <= 10000) {
179+
return 10000
180+
}
181+
182+
if (numberOfLines <= 15000) {
183+
return 15000
184+
}
185+
186+
if (numberOfLines <= 20000) {
187+
return 20000
188+
}
189+
190+
return 500
191+
}
192+
171193
// DOM HELPERS
172194
export const getFoldGutterElement = (open: boolean) => {
173195
const icon = document.createElement('span')

src/Shared/Components/DevtronLicenseCard/InstallationFingerprintInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ClipboardButton } from '@Common/index'
22

3-
import { DOCUMENTATION_HOME_PAGE } from '@Common/Constants'
3+
import { DOCUMENTATION } from '@Common/Constants'
44
import { InfoIconTippy } from '..'
55
import { InstallFingerprintInfoProps } from './types'
66

@@ -15,7 +15,7 @@ const InstallationFingerprintInfo = ({ fingerprint, showHelpTooltip = false }: I
1515
documentationLinkText="Documentation"
1616
iconClassName="icon-dim-20 fcn-6"
1717
placement="right"
18-
documentationLink={DOCUMENTATION_HOME_PAGE}
18+
documentationLink={DOCUMENTATION.ENTERPRISE_LICENSE}
1919
/>
2020
)}
2121
</div>

src/Shared/Components/Header/HelpNav.tsx

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ import { Fragment } from 'react'
1818
import ReactGA from 'react-ga4'
1919
import { NavLink } from 'react-router-dom'
2020
import { SliderButton } from '@typeform/embed-react'
21-
import { stopPropagation, DOCUMENTATION_HOME_PAGE, URLS, DISCORD_LINK } from '../../../Common'
21+
import { stopPropagation, URLS } from '../../../Common'
2222
import { InstallationType, HelpNavType, HelpOptionType } from './types'
23-
import { EnterpriseHelpOptions, OSSHelpOptions } from './constants'
2423
import { ReactComponent as GettingStartedIcon } from '../../../Assets/Icon/ic-onboarding.svg'
2524
import { ReactComponent as Feedback } from '../../../Assets/Icon/ic-feedback.svg'
26-
import { ReactComponent as Discord } from '../../../Assets/Icon/ic-discord-fill.svg'
27-
import { ReactComponent as File } from '../../../Assets/Icon/ic-file-text.svg'
2825
import { useMainContext } from '../../Providers'
2926
import { Icon } from '../Icon'
27+
import { getHelpOptions } from './utils'
3028

3129
const HelpNav = ({
3230
className,
@@ -38,22 +36,10 @@ const HelpNav = ({
3836
}: HelpNavType) => {
3937
const { currentServerInfo, handleOpenLicenseInfoDialog, licenseData } = useMainContext()
4038
const isEnterprise = currentServerInfo?.serverInfo?.installationType === InstallationType.ENTERPRISE
39+
const isTrial = licenseData?.isTrial ?? false
4140
const FEEDBACK_FORM_ID = `UheGN3KJ#source=${window.location.hostname}`
4241

43-
const CommonHelpOptions: HelpOptionType[] = [
44-
{
45-
name: 'View documentation',
46-
link: DOCUMENTATION_HOME_PAGE,
47-
icon: File,
48-
},
49-
50-
{
51-
name: 'Join discord community',
52-
link: DISCORD_LINK,
53-
icon: Discord,
54-
},
55-
...(isEnterprise ? EnterpriseHelpOptions : OSSHelpOptions),
56-
]
42+
const CommonHelpOptions: HelpOptionType[] = getHelpOptions(isEnterprise, isTrial)
5743

5844
const onClickGettingStarted = (): void => {
5945
setGettingStartedClicked(true)
@@ -114,17 +100,19 @@ const HelpNav = ({
114100
<div className="ml-12 cn-9 fs-14">{option.name}</div>
115101
</a>
116102
{/* licenseData is only set when showLicenseData is received true */}
117-
{isEnterprise && licenseData && index === 1 && (
103+
{isEnterprise && index === 1 && (
118104
<>
119-
<button
120-
type="button"
121-
className="dc__transparent help-card__option flexbox dc__align-items-center cn-9 dc__gap-12 fs-14"
122-
onClick={handleOpenLicenseDialog}
123-
data-testid="about-devtron"
124-
>
125-
<Icon name="ic-devtron" color="N600" size={20} />
126-
About Devtron
127-
</button>
105+
{licenseData && (
106+
<button
107+
type="button"
108+
className="dc__transparent help-card__option flexbox dc__align-items-center cn-9 dc__gap-12 fs-14"
109+
onClick={handleOpenLicenseDialog}
110+
data-testid="about-devtron"
111+
>
112+
<Icon name="ic-devtron" color="N600" size={20} />
113+
About Devtron
114+
</button>
115+
)}
128116
<div className="help__enterprise pl-8 pb-4-imp pt-4-imp dc__gap-12 flexbox dc__align-items-center h-28">
129117
Enterprise Support
130118
</div>

src/Shared/Components/Header/constants.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { OPEN_NEW_TICKET, RAISE_ISSUE, VIEW_ALL_TICKETS } from '@Shared/constants'
17+
import { CONTACT_SUPPORT_LINK, OPEN_NEW_TICKET, RAISE_ISSUE, VIEW_ALL_TICKETS } from '@Shared/constants'
1818
import { HelpOptionType } from './types'
1919
import { ReactComponent as Chat } from '../../../Assets/Icon/ic-chat-circle-dots.svg'
2020
import { ReactComponent as EditFile } from '../../../Assets/Icon/ic-edit-file.svg'
@@ -47,3 +47,11 @@ export const OSSHelpOptions: HelpOptionType[] = [
4747
icon: EditFile,
4848
},
4949
]
50+
51+
export const TrialHelpOptions: HelpOptionType[] = [
52+
{
53+
name: 'Request Support',
54+
link: CONTACT_SUPPORT_LINK,
55+
icon: EditFile,
56+
},
57+
]

src/Shared/Components/Header/utils.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ReactComponent as File } from '@Icons/ic-file-text.svg'
18+
import { ReactComponent as Discord } from '@Icons/ic-discord-fill.svg'
1719
import { updatePostHogEvent } from './service'
18-
import { LOGIN_COUNT } from '../../../Common'
20+
import { DISCORD_LINK, DOCUMENTATION_HOME_PAGE, LOGIN_COUNT } from '../../../Common'
1921
import { DevtronLicenseInfo, LicenseStatus } from '../DevtronLicenseCard'
22+
import { EnterpriseHelpOptions, OSSHelpOptions, TrialHelpOptions } from './constants'
2023

2124
const millisecondsInDay = 86400000
2225
export const getDateInMilliseconds = (days) => 1 + new Date().valueOf() + (days ?? 0) * millisecondsInDay
@@ -37,3 +40,28 @@ export const setActionWithExpiry = (key: string, days: number): void => {
3740

3841
export const getIsShowingLicenseData = (licenseData: DevtronLicenseInfo) =>
3942
licenseData && (licenseData.licenseStatus !== LicenseStatus.ACTIVE || licenseData.isTrial)
43+
44+
const getInstallationSpecificHelpOptions = (isEnterprise: boolean, isTrial: boolean) => {
45+
if (isEnterprise) {
46+
return isTrial ? TrialHelpOptions : EnterpriseHelpOptions
47+
}
48+
return OSSHelpOptions
49+
}
50+
51+
export const getHelpOptions = (isEnterprise: boolean, isTrial: boolean) => {
52+
const HelpOptions = getInstallationSpecificHelpOptions(isEnterprise, isTrial)
53+
return [
54+
{
55+
name: 'View documentation',
56+
link: DOCUMENTATION_HOME_PAGE,
57+
icon: File,
58+
},
59+
60+
{
61+
name: 'Join discord community',
62+
link: DISCORD_LINK,
63+
icon: Discord,
64+
},
65+
...HelpOptions,
66+
]
67+
}

0 commit comments

Comments
 (0)