Skip to content

Commit ca32621

Browse files
Merge pull request #707 from devtron-labs/feat/app-status-modal
feat: app status modal
2 parents 5238955 + 69a523c commit ca32621

39 files changed

+879
-385
lines changed

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.13.0-pre-1",
3+
"version": "1.13.0-pre-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/IconV2/ic-expand-sm.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Common/Constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const DOCUMENTATION = {
3030
GLOBAL_CONFIG_BUILD_INFRA: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/global-configurations/build-infra`,
3131
ENTERPRISE_LICENSE: `${DOCUMENTATION_HOME_PAGE}/enterprise-license`,
3232
KUBE_CONFIG: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/resource-browser#running-kubectl-commands-locally`,
33+
TENANT_INSTALLATION: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/software-distribution-hub/tenants`,
3334
}
3435

3536
export const PATTERNS = {
@@ -86,7 +87,6 @@ export const URLS = {
8687
COMPARE_CLUSTERS: '/compare-clusters',
8788
APP_CONFIG: 'edit',
8889
GLOBAL_CONFIG: '/global-config',
89-
CONFIG_DRIFT: 'config-drift',
9090
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP,
9191
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_CREATE: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/create`,
9292
// NOTE: using appId since we are re-using AppConfig component
@@ -135,6 +135,7 @@ export const ROUTES = {
135135
ATTRIBUTES_CREATE: 'attributes/create',
136136
ATTRIBUTES_UPDATE: 'attributes/update',
137137
APP_LIST_MIN: 'app/min',
138+
APP_DETAIL: 'app/detail',
138139
CLUSTER_LIST_MIN: 'cluster/autocomplete',
139140
CLUSTER_LIST_RAW: 'k8s/capacity/cluster/list/raw',
140141
PLUGIN_GLOBAL_LIST_DETAIL_V2: 'plugin/global/list/detail/v2',

src/Common/Drawer/Drawer.tsx

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

17-
import React, { useRef, useEffect } from 'react'
17+
import { useRef, useEffect } from 'react'
1818
import { preventBodyScroll } from '../../Shared'
1919
import { VisibleModal } from '../Modals/VisibleModal'
2020
import './Drawer.scss'

src/Common/Drawer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Drawer'

src/Common/EmptyState/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as GenericEmptyState } from './GenericEmptyState'
2+
export { default as GenericFilterEmptyState } from './GenericFilterEmptyState'

src/Common/Helper.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
ToastVariantType,
4444
versionComparatorBySortOrder,
4545
WebhookEventNameType,
46+
AppType,
4647
} from '../Shared'
4748
import { ReactComponent as ArrowDown } from '@Icons/ic-chevron-down.svg'
4849
import { ReactComponent as ICWebhook } from '@Icons/ic-webhook.svg'
@@ -679,6 +680,7 @@ export const applyCompareDiffOnUneditedDocument = (uneditedDocument: object, edi
679680

680681
/**
681682
* Returns a debounced variant of the function
683+
* @deprecated - It should use useRef instead, pls use useDebounce
682684
*/
683685
export const debounce = (func, timeout = 500) => {
684686
let timer
@@ -693,6 +695,17 @@ export const debounce = (func, timeout = 500) => {
693695
}
694696
}
695697

698+
export const useDebounce = <Callback extends (...args: any[]) => void>(cb: Callback, delay: number) => {
699+
const timeoutId = useRef<ReturnType<typeof setTimeout>>(null)
700+
701+
return (...args: Parameters<Callback>) => {
702+
if (timeoutId.current) {
703+
clearTimeout(timeoutId.current)
704+
}
705+
timeoutId.current = setTimeout(() => cb(...args), delay)
706+
}
707+
}
708+
696709
/**
697710
* Returns a capitalized string with first letter in uppercase and rest in lowercase
698711
*/
@@ -1083,4 +1096,23 @@ export const getTTLInHumanReadableFormat = (ttl: number): string => {
10831096
const humanizedDuration = moment.duration(absoluteTTL, 'seconds').humanize(false)
10841097
// Since moment.js return "a" or "an" for singular values so replacing with 1.
10851098
return humanizedDuration.replace(/^(a|an) /, '1 ');
1086-
}
1099+
}
1100+
1101+
const getAppTypeCategory = (appType: AppType) => {
1102+
switch (appType) {
1103+
case AppType.DEVTRON_APP:
1104+
return 'DA'
1105+
case AppType.DEVTRON_HELM_CHART:
1106+
case AppType.EXTERNAL_HELM_CHART:
1107+
return 'HA'
1108+
case AppType.EXTERNAL_ARGO_APP:
1109+
return 'ACD'
1110+
case AppType.EXTERNAL_FLUX_APP:
1111+
return 'FCD'
1112+
default:
1113+
return 'DA'
1114+
}
1115+
}
1116+
1117+
export const getAIAnalyticsEvents = (context: string, appType?: AppType) =>
1118+
`AI_${appType ? `${getAppTypeCategory(appType)}_` : ''}${context}`

src/Common/SegmentedControl/Segment.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { ReactElement } from 'react'
1+
import { ReactElement, useMemo } from 'react'
22

33
import { Tooltip } from '@Common/Tooltip'
44
import { Icon } from '@Shared/Components'
55
import { ComponentSizeType } from '@Shared/constants'
6+
import { getUniqueId } from '@Shared/Helpers'
67

78
import { ConditionalWrap } from '../Helper'
89
import { COMPONENT_SIZE_TO_ICON_CLASS_MAP, COMPONENT_SIZE_TO_SEGMENT_CLASS_MAP } from './constants'
@@ -24,6 +25,8 @@ const Segment = ({
2425
size,
2526
disabled,
2627
}: SegmentProps) => {
28+
const inputId = useMemo(getUniqueId, [])
29+
2730
const { value, icon, isError, label, tooltipProps, ariaLabel } = segment
2831
const handleChange = () => {
2932
onChange(segment)
@@ -32,13 +35,13 @@ const Segment = ({
3235
return (
3336
<ConditionalWrap key={value} condition={!!tooltipProps?.content} wrap={wrapWithTooltip(tooltipProps)}>
3437
<div
35-
className={`dc__position-rel dc__text-center ${fullWidth ? 'flex-grow-1' : ''}`}
38+
className={`dc__position-rel dc__text-center dc__no-shrink ${fullWidth ? 'flex-grow-1' : ''}`}
3639
ref={selectedSegmentRef}
3740
>
3841
<input
3942
type="radio"
4043
value={value}
41-
id={`${name}-${value}`}
44+
id={inputId}
4245
name={name}
4346
onChange={handleChange}
4447
checked={isSelected}
@@ -47,7 +50,7 @@ const Segment = ({
4750
/>
4851

4952
<label
50-
htmlFor={`${name}-${value}`}
53+
htmlFor={inputId}
5154
className={`pointer m-0 flex ${!fullWidth ? 'left' : ''} dc__gap-4 br-4 segmented-control__segment segmented-control__segment--${size} ${isSelected ? 'fw-6 segmented-control__segment--selected' : 'fw-4'} ${segment.isError ? 'cr-5' : 'cn-9'} ${disabled ? 'cursor-not-allowed' : ''} ${COMPONENT_SIZE_TO_SEGMENT_CLASS_MAP[size]}`}
5255
aria-label={ariaLabel}
5356
>

src/Common/Toggle/Toggle.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
background-color: var(--white);
6464
transition: all 0.4s ease;
6565
}
66+
67+
&.intermediate::before {
68+
width: 0px;
69+
height: 0px;
70+
}
71+
6672
&.with-icon {
6773
background-color: var(--bg-primary) !important;
6874
svg {

0 commit comments

Comments
 (0)