Skip to content

Commit 3845cd1

Browse files
committed
Merge branch 'feature/application-template' of github.com:devtron-labs/devtron-fe-common-lib into feat/graph-visualizer
2 parents 49bd8c9 + bed42d4 commit 3845cd1

File tree

7 files changed

+170
-0
lines changed

7 files changed

+170
-0
lines changed

src/Common/Constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export const PATTERNS = {
5151
ALPHANUMERIC_WITH_SPECIAL_CHAR_AND_SLASH: /^[A-Za-z0-9._/-]+$/, // allow alphanumeric,(.) ,(-),(_),(/)
5252
}
5353

54+
const GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP = '/global-config/templates/devtron-apps'
55+
5456
export const URLS = {
5557
LOGIN_SSO: '/login/sso',
5658
PERMISSION_GROUPS: '/global-config/auth/groups',
@@ -81,6 +83,10 @@ export const URLS = {
8183
CONFIG_DRIFT: 'config-drift',
8284
RESOURCE_BROWSER: '/resource-browser',
8385
COMPARE_CLUSTERS: '/compare-clusters',
86+
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP,
87+
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_CREATE: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/create`,
88+
// NOTE: using appId since we are re-using AppConfig component
89+
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_DETAIL: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/detail/:appId`,
8490
}
8591

8692
export const ROUTES = {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { cloneElement } from 'react'
2+
import { Link } from 'react-router-dom'
3+
import { ReactComponent as ICCaretSmall } from '@Icons/ic-caret-left-small.svg'
4+
import { Tooltip } from '@Common/Tooltip'
5+
import { GenericInfoCardProps } from './types'
6+
import { getClassNameForBorderVariant } from './utils'
7+
import './styles.scss'
8+
9+
const GenericInfoCard = ({
10+
title,
11+
description,
12+
author,
13+
isLoading,
14+
borderVariant,
15+
Icon,
16+
onClick,
17+
linkProps,
18+
}: GenericInfoCardProps) => {
19+
const IconElement = isLoading ? <div className="shimmer" /> : Icon
20+
21+
const renderShimmerContent = () => (
22+
<>
23+
<div className="icon-dim-40 dc__no-shrink br-6">
24+
<div className="shimmer shimmer__fill-dimensions" />
25+
</div>
26+
27+
<div className="flexbox-col dc__gap-8 flex-grow-1">
28+
<div className="flexbox-col dc__gap-4">
29+
<span className={isLoading ? 'shimmer w-300' : ''} />
30+
<span className={isLoading ? 'shimmer w-150 pt-2' : ''} />
31+
</div>
32+
33+
<span className={isLoading ? 'shimmer w-600' : ''} />
34+
</div>
35+
</>
36+
)
37+
38+
const renderContent = () => (
39+
<div
40+
className={`flexbox dc__gap-16 p-12 bg__primary generic-info-card br-8 ${getClassNameForBorderVariant(borderVariant)}`}
41+
>
42+
{isLoading ? (
43+
renderShimmerContent()
44+
) : (
45+
<>
46+
{cloneElement(IconElement, {
47+
className: `${IconElement.props?.className ?? ''} icon-dim-40 dc__no-shrink br-6 dc__fill-available-space`,
48+
})}
49+
50+
<div className="flexbox-col dc__gap-8 flex-grow-1">
51+
<div className="flexbox-col">
52+
<div className="flexbox dc__align-items-center">
53+
<Tooltip content={title}>
54+
<h3 className="fw-6 fs-13 lh-20 cn-9 m-0 generic-info-card__title dc__truncate dc__mxw-600">
55+
{title}
56+
</h3>
57+
</Tooltip>
58+
59+
<div className="generic-info-card__arrow dc__no-shrink flex">
60+
<ICCaretSmall className="icon-dim-16 dc__flip-180 scb-5" />
61+
</div>
62+
</div>
63+
64+
<Tooltip content={author}>
65+
<h4 className="fw-4 fs-12 lh-16 cn-7 m-0 dc__truncate w-300">By {author}</h4>
66+
</Tooltip>
67+
</div>
68+
69+
<p className="fw-4 fs-12 lh-16 cn-7 m-0 dc__truncate--clamp-3">{description}</p>
70+
</div>
71+
</>
72+
)}
73+
</div>
74+
)
75+
76+
if (!linkProps && !onClick) {
77+
return renderContent()
78+
}
79+
80+
if (linkProps) {
81+
return <Link {...linkProps}>{renderContent()}</Link>
82+
}
83+
84+
return (
85+
<div role="button" tabIndex={0} onClick={onClick} className="dc__unset-button-styles dc__align-unset">
86+
{renderContent()}
87+
</div>
88+
)
89+
}
90+
91+
export default GenericInfoCard
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { type GenericInfoCardProps, GenericInfoCardBorderVariant } from './types'
2+
export { default as GenericInfoCard } from './GenericInfoCard.component'
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.generic-info-card {
2+
transition: box-shadow 0.2s ease-out;
3+
4+
&__title {
5+
transition: color 0.2s ease-out;
6+
}
7+
8+
&__arrow {
9+
transition: all 0.2s ease-out;
10+
transform: translateX(-20%);
11+
visibility: hidden;
12+
}
13+
14+
&:hover {
15+
position: relative;
16+
z-index: 1;
17+
box-shadow: var(--shadow-card-secondary);
18+
19+
// NOTE: &__title was not working here
20+
.generic-info-card__title {
21+
color: var(--B500);
22+
}
23+
24+
.generic-info-card__arrow {
25+
transform: translateX(30%);
26+
visibility: visible;
27+
}
28+
}
29+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { MouseEventHandler, ReactElement } from 'react'
2+
import { LinkProps } from 'react-router-dom'
3+
4+
type BaseGenericInfoCardProps = {
5+
title: string
6+
description: string
7+
author: string
8+
Icon: ReactElement
9+
} & (
10+
| {
11+
onClick?: never
12+
linkProps?: Pick<LinkProps, 'to' | 'target' | 'rel'>
13+
}
14+
| {
15+
onClick?: MouseEventHandler<HTMLDivElement>
16+
linkProps?: never
17+
}
18+
)
19+
20+
export enum GenericInfoCardBorderVariant {
21+
ROUNDED = 'rounded',
22+
NONE = 'none',
23+
}
24+
25+
export type GenericInfoCardProps = { borderVariant: GenericInfoCardBorderVariant } & (
26+
| ({
27+
isLoading: true
28+
} & Partial<Record<keyof BaseGenericInfoCardProps, never>>)
29+
| ({
30+
isLoading?: boolean
31+
} & BaseGenericInfoCardProps)
32+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { GenericInfoCardBorderVariant } from './types'
2+
3+
export const getClassNameForBorderVariant = (variant: GenericInfoCardBorderVariant) => {
4+
if (variant === GenericInfoCardBorderVariant.NONE) {
5+
return ''
6+
}
7+
8+
return 'dc__border-n1'
9+
}

src/Shared/Components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ export * from './TargetPlatforms'
7575
export * from './UnsavedChanges'
7676
export * from './UnsavedChangesDialog'
7777
export * from './GraphVisualizer'
78+
export * from './GenericInfoCard'

0 commit comments

Comments
 (0)