Skip to content

Commit 18ef98a

Browse files
authored
Merge pull request #967 from devtron-labs/release-candidate-v0.43.0
feat: release candidate v0.43.0
2 parents 568a7d2 + 01e0d21 commit 18ef98a

File tree

15 files changed

+297
-13
lines changed

15 files changed

+297
-13
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.20.7",
3+
"version": "1.21.0",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

src/Common/BreadCrumb/BreadCrumb.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import React, { useMemo, useEffect } from 'react'
1818
import { Link, useRouteMatch, useParams } from 'react-router-dom'
19-
import { useBreadcrumbContext } from './BreadcrumbStore'
19+
import { getBreadCrumbSeparator, useBreadcrumbContext } from './BreadcrumbStore'
2020
import { ConditionalWrap } from '../Helper'
2121
import { Breadcrumb, Breadcrumbs, UseBreadcrumbOptionalProps, UseBreadcrumbState } from './Types'
2222

@@ -90,7 +90,7 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
9090
export const BreadCrumb: React.FC<Breadcrumbs> = ({
9191
breadcrumbs,
9292
sep = '/',
93-
className = 'dc__devtron-breadcrumb__item',
93+
className = 'dc__devtron-breadcrumb__item fs-16 fw-4 lh-1-5 dc__ellipsis-right dc__mxw-155',
9494
}) => {
9595
const { url } = useRouteMatch()
9696
const filteredCrumbs = breadcrumbs.filter((crumb) => !!crumb.name)
@@ -114,9 +114,7 @@ export const BreadCrumb: React.FC<Breadcrumbs> = ({
114114
{breadcrumb.name}
115115
</ConditionalWrap>
116116

117-
{idx + 1 !== filteredCrumbs.length && breadcrumb.name && (
118-
<span className={`${className}__separator cn-5`}>{sep}</span>
119-
)}
117+
{idx + 1 !== filteredCrumbs.length && breadcrumb.name && getBreadCrumbSeparator()}
120118
</React.Fragment>
121119
))}
122120
</>

src/Common/BreadCrumb/BreadcrumbStore.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ const initialState = {
2222
}
2323

2424
export const BreadcrumbText = ({ heading, isActive, shouldTruncate = false }: BreadcrumbTextProps) => (
25-
<h2 className={`m-0 fs-16 fw-6 lh-32 ${shouldTruncate ? 'dc__truncate' : ''} ${isActive ? 'cn-9' : 'cb-5'}`}>{heading}</h2>
25+
<span className={`dc__breadcrumb-text cb-5 fs-16 lh-1-5 ${shouldTruncate ? 'dc__truncate' : ''} ${isActive ? 'cn-9 fw-6' : 'cb-5 fw-4 dc__mxw-155 dc__ellipsis-right'}`}>{heading}</span>
2626
)
2727

28+
export const getBreadCrumbSeparator = (sep: string = '/') => (
29+
<span className="dc__devtron-breadcrumb__item__separator">{sep}</span>
30+
)
31+
32+
2833
const Store = ({ children }) => {
2934
const [state, setState] = useState(initialState)
3035
return <BreadcrumbContext.Provider value={{ state, setState }}>{children}</BreadcrumbContext.Provider>

src/Common/Constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const PATTERNS = {
4949
}
5050

5151
const GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP = '/global-config/templates/devtron-apps'
52+
const OBSERVABILITY_ROOT = '/observability'
5253

5354
export const URLS = {
5455
LOGIN: '/login',
@@ -88,6 +89,10 @@ export const URLS = {
8889
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_DETAIL: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/detail/:appId`,
8990
LICENSE_AUTH: '/license-auth',
9091
GLOBAL_CONFIG_EDIT_CLUSTER: '/global-config/cluster-env/edit/:clusterId',
92+
// OBSERVABILITY
93+
OBSERVABILITY: OBSERVABILITY_ROOT,
94+
OBSERVABILITY_OVERVIEW: `${OBSERVABILITY_ROOT}/overview`,
95+
OBSERVABILITY_CUSTOMER_LIST: `${OBSERVABILITY_ROOT}/tenants`,
9196
} as const
9297

9398
export const ROUTES = {

src/Pages/ResourceBrowser/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@ export enum ResourceBrowserActionMenuEnum {
168168
terminal = 'terminal',
169169
delete = 'delete',
170170
vulnerability = 'vulnerability',
171+
restart = 'restart',
171172
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { useState } from 'react'
18+
import { DayPickerRangeController, isInclusivelyBeforeDay } from 'react-dates'
19+
// eslint-disable-next-line import/extensions
20+
import CustomizableCalendarDay from 'react-dates/esm/components/CustomizableCalendarDay.js'
21+
import moment, { Moment } from 'moment'
22+
23+
import { ComponentSizeType } from '@Shared/constants'
24+
25+
import 'react-dates/initialize'
26+
27+
import { Button } from '../Button'
28+
import { Icon } from '../Icon'
29+
import { customDayStyles, DayPickerCalendarInfoHorizontal, DayPickerRangeControllerPresets, styles } from './constants'
30+
import { DatePickerRangeControllerProps } from './types'
31+
32+
import 'react-dates/lib/css/_datepicker.css'
33+
34+
export const DatePickerRangeController = ({
35+
handlePredefinedRange,
36+
handleApply,
37+
calendar,
38+
calendarInputs,
39+
handleDateInput,
40+
handleDatesChange,
41+
calendarValue,
42+
focusedInput,
43+
handleFocusChange,
44+
}: DatePickerRangeControllerProps) => {
45+
const [showCalendar, setShowCalender] = useState(false)
46+
const onClickApplyTimeChange = () => {
47+
setShowCalender(false)
48+
handleApply()
49+
}
50+
51+
const onClickPredefinedTimeRange = (startDate: Moment, endDate: Moment, endStr: string) => () => {
52+
handlePredefinedRange(startDate, endDate, endStr)
53+
setShowCalender(false)
54+
}
55+
56+
const renderDatePresets = () => (
57+
<div
58+
className="flex left top"
59+
style={{
60+
...styles.PresetDateRangePicker_panel,
61+
...DayPickerCalendarInfoHorizontal,
62+
...{
63+
PresetDateRangePicker_panel: {
64+
padding: '0px',
65+
width: '200px',
66+
height: '100%',
67+
},
68+
...styles.DayPicker__horizontal,
69+
},
70+
}}
71+
>
72+
<div className="w-300 h-300 p-16">
73+
<p className="mb-16 fw-6">Pick time range</p>
74+
<div>
75+
<div className="w-100 mb-16">
76+
<span>From</span>
77+
<input
78+
type="text"
79+
className="dc__block w-100 dc__border"
80+
value={calendarInputs.startDate}
81+
onChange={(event) => {
82+
handleDateInput('startDate', event.target.value)
83+
}}
84+
/>
85+
</div>
86+
<div className="w-100 mb-16">
87+
<span>To</span>
88+
<input
89+
type="text"
90+
className="dc__block w-100 dc__border"
91+
value={calendarInputs.endDate}
92+
onChange={(event) => {
93+
handleDateInput('endDate', event.target.value)
94+
}}
95+
/>
96+
</div>
97+
<Button
98+
text="Apply Time Range"
99+
onClick={onClickApplyTimeChange}
100+
dataTestId="apply-time-range"
101+
size={ComponentSizeType.medium}
102+
/>
103+
</div>
104+
</div>
105+
<div className="w-200 p-16 h-300">
106+
{DayPickerRangeControllerPresets.map(({ text, startDate, endDate, endStr }) => {
107+
const isSelected =
108+
startDate.isSame(calendar.startDate, 'minute') &&
109+
startDate.isSame(calendar.startDate, 'hour') &&
110+
startDate.isSame(calendar.startDate, 'day') &&
111+
endDate.isSame(calendar.endDate, 'day')
112+
let buttonStyles = {
113+
...styles.PresetDateRangePicker_button,
114+
}
115+
if (isSelected) {
116+
buttonStyles = {
117+
...buttonStyles,
118+
...styles.PresetDateRangePicker_button__selected,
119+
}
120+
}
121+
return (
122+
<button
123+
type="button"
124+
key={text}
125+
style={{ ...buttonStyles, textAlign: 'left' }}
126+
onClick={onClickPredefinedTimeRange(startDate, endDate, endStr)}
127+
>
128+
{text}
129+
</button>
130+
)
131+
})}
132+
</div>
133+
</div>
134+
)
135+
136+
const toggleCalender = () => {
137+
setShowCalender(!showCalendar)
138+
}
139+
140+
const hideCalender = () => setShowCalender(false)
141+
142+
return (
143+
<>
144+
<div
145+
data-testid="app-metrics-range-picker-box"
146+
className="flex h-36"
147+
style={{ borderRadius: '4px', border: 'solid 1px var(--N200)' }}
148+
onClick={toggleCalender}
149+
>
150+
<p className="cursor mb-0 h-32 p-6">{calendarValue}</p>
151+
<Icon name="ic-caret-down-small" color="N600" />
152+
</div>
153+
{showCalendar && (
154+
<DayPickerRangeController
155+
startDate={calendar.startDate}
156+
endDate={calendar.endDate}
157+
focusedInput={focusedInput}
158+
onDatesChange={handleDatesChange}
159+
onFocusChange={handleFocusChange}
160+
numberOfMonths={1}
161+
withPortal
162+
renderCalendarInfo={renderDatePresets}
163+
calendarInfoPosition="after"
164+
hideKeyboardShortcutsPanel
165+
isOutsideRange={(day) => !isInclusivelyBeforeDay(day, moment())} // enable past dates
166+
renderCalendarDay={(props) => <CustomizableCalendarDay {...props} {...customDayStyles} />}
167+
onOutsideClick={hideCalender}
168+
initialVisibleMonth={() => moment().subtract(2, 'd')} //
169+
/>
170+
)}
171+
</>
172+
)
173+
}

0 commit comments

Comments
 (0)