Skip to content

Commit 088c0f3

Browse files
Merge pull request #692 from devtron-labs/feat/poll-release-status
feat: poll release status
2 parents c48078e + ce2c6a9 commit 088c0f3

File tree

13 files changed

+149
-12
lines changed

13 files changed

+149
-12
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.11.0-pre-1",
3+
"version": "1.11.0-pre-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { useEffect } from 'react'
2+
import { animate, motion, useMotionValue, useTransform } from 'framer-motion'
3+
4+
import { Tooltip } from '@Common/Tooltip'
5+
6+
import { CX, CY, END_ANGLE, RADIUS, START_ANGLE } from './constants'
7+
import { AnimatedTimerProps } from './types'
8+
9+
const polarToCartesian = (cx: number, cy: number, r: number, angleInDegrees: number) => {
10+
const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0
11+
return {
12+
x: cx + r * Math.cos(angleInRadians),
13+
y: cy + r * Math.sin(angleInRadians),
14+
}
15+
}
16+
17+
const describeArcPath = (cx: number, cy: number, r: number, endAngle: number) => {
18+
const startAngle = 0
19+
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1'
20+
const start = polarToCartesian(cx, cy, r, endAngle)
21+
const end = polarToCartesian(cx, cy, r, startAngle)
22+
23+
return `
24+
M ${cx} ${cy}
25+
L ${start.x} ${start.y}
26+
A ${r} ${r} 0 ${largeArcFlag} 0 ${end.x} ${end.y}
27+
Z
28+
`
29+
}
30+
31+
const AnimatedTimer = ({ duration, onComplete, size = 24, tooltipContent }: AnimatedTimerProps) => {
32+
const angle = useMotionValue<number>(START_ANGLE)
33+
const d = useTransform(angle, (currentAngle) => describeArcPath(CX, CY, RADIUS, currentAngle))
34+
useEffect(() => {
35+
const controls = animate(angle, END_ANGLE, {
36+
duration,
37+
ease: 'easeInOut',
38+
onComplete,
39+
})
40+
return controls.stop
41+
}, [duration])
42+
43+
return (
44+
<Tooltip alwaysShowTippyOnHover={!!tooltipContent} content={tooltipContent}>
45+
<div className="flex">
46+
<svg
47+
width={CX * 2}
48+
height={CY * 2}
49+
viewBox={`0 0 ${CX * 2} ${CY * 2}`}
50+
fill="none"
51+
xmlns="http://www.w3.org/2000/svg"
52+
className={`icon-dim-${size}`}
53+
>
54+
<path
55+
fillRule="evenodd"
56+
clipRule="evenodd"
57+
d="M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
58+
fill="var(--O500)"
59+
/>
60+
61+
<motion.path fill="var(--O200)" d={d} />
62+
</svg>
63+
</div>
64+
</Tooltip>
65+
)
66+
}
67+
68+
export default AnimatedTimer
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const CX = 12
2+
export const CY = 12
3+
export const RADIUS = 6
4+
export const START_ANGLE = 0
5+
export const END_ANGLE = 360
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as AnimatedTimer } from './AnimatedTimer.component'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { animate } from 'framer-motion'
2+
3+
import { TooltipProps } from '@Common/Tooltip'
4+
import { IconBaseSizeType } from '@Shared/index'
5+
6+
export interface AnimatedTimerProps extends Pick<Parameters<typeof animate>[2], 'onComplete'> {
7+
/**
8+
* The time in seconds for the timer to animate.
9+
*/
10+
duration: number
11+
onComplete?: () => void
12+
/**
13+
* @default 24
14+
*/
15+
size?: IconBaseSizeType
16+
tooltipContent?: TooltipProps['content']
17+
}

src/Shared/Components/CICDHistory/LogStageAccordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const LogStageAccordion = ({
5353
}
5454

5555
const getFormattedTimeDifference = (): string => {
56-
const timeDifference = getTimeDifference(startTime, endTime)
56+
const timeDifference = getTimeDifference({ startTime, endTime })
5757
if (timeDifference === '0s') {
5858
return '< 1s'
5959
}

src/Shared/Components/Icon/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ReactComponent as ICAborted } from '@IconsV2/ic-aborted.svg'
55
import { ReactComponent as ICAdd } from '@IconsV2/ic-add.svg'
66
import { ReactComponent as ICApica } from '@IconsV2/ic-apica.svg'
77
import { ReactComponent as ICAppGroup } from '@IconsV2/ic-app-group.svg'
8+
import { ReactComponent as ICArrowClockwise } from '@IconsV2/ic-arrow-clockwise.svg'
89
import { ReactComponent as ICArrowRight } from '@IconsV2/ic-arrow-right.svg'
910
import { ReactComponent as ICArrowsLeftRight } from '@IconsV2/ic-arrows-left-right.svg'
1011
import { ReactComponent as ICAther } from '@IconsV2/ic-ather.svg'
@@ -113,6 +114,7 @@ export const iconMap = {
113114
'ic-add': ICAdd,
114115
'ic-apica': ICApica,
115116
'ic-app-group': ICAppGroup,
117+
'ic-arrow-clockwise': ICArrowClockwise,
116118
'ic-arrow-right': ICArrowRight,
117119
'ic-arrows-left-right': ICArrowsLeftRight,
118120
'ic-ather': ICAther,

src/Shared/Components/Icon/types.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FC, SVGProps } from 'react'
1818

1919
import { TooltipProps } from '@Common/Tooltip/types'
20+
import { IconBaseColorType, IconBaseSizeType } from '@Shared/index'
2021

2122
type IconMap = Record<string, FC<SVGProps<SVGSVGElement>>>
2223

@@ -29,17 +30,13 @@ export interface IconBaseProps {
2930
* The size of the icon in pixels.
3031
* @default 16
3132
*/
32-
size?: 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 28 | 30 | 32 | 34 | 36 | 40 | 42 | 44 | 48 | 72 | 80
33+
size?: IconBaseSizeType
3334
/** Props to configure the tooltip when hovering over the icon. */
3435
tooltipProps?: TooltipProps
3536
/**
3637
* The color of the icon (color tokens). \
3738
* If `null`, the default color present in icon is used.
3839
* @example `'B500'`, `'N200'`, `'G50'`, `'R700'`
3940
*/
40-
color:
41-
| `${'B' | 'N' | 'G' | 'Y' | 'R' | 'V' | 'O'}${`${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00` | '50' | '0'}`
42-
| 'white'
43-
| 'black'
44-
| null
41+
color: IconBaseColorType
4542
}

0 commit comments

Comments
 (0)