forked from SigNoz/signoz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [SIG-543]: add time selection in the custom date selection (Sig…
…Noz#4658) * feat: [SIG-543]: inital commit * feat: [SIG-543]: refactor date time modal to separate component * feat: [SIG-543]: refactor date time modal to separate component * feat: add back the time support according to the older designs in the date time picker * fix: custom time picker minor UI fixes
- Loading branch information
1 parent
9ace374
commit 49aba4f
Showing
6 changed files
with
91 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
frontend/src/components/CustomTimePicker/RangePickerModal.styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.custom-date-picker { | ||
display: flex; | ||
flex-direction: column; | ||
} |
68 changes: 68 additions & 0 deletions
68
frontend/src/components/CustomTimePicker/RangePickerModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import './RangePickerModal.styles.scss'; | ||
|
||
import { DatePicker } from 'antd'; | ||
import { DateTimeRangeType } from 'container/TopNav/CustomDateTimeModal'; | ||
import { LexicalContext } from 'container/TopNav/DateTimeSelectionV2/config'; | ||
import dayjs, { Dayjs } from 'dayjs'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { AppState } from 'store/reducers'; | ||
import { GlobalReducer } from 'types/reducer/globalTime'; | ||
|
||
interface RangePickerModalProps { | ||
setCustomDTPickerVisible: Dispatch<SetStateAction<boolean>>; | ||
setIsOpen: Dispatch<SetStateAction<boolean>>; | ||
onCustomDateHandler: ( | ||
dateTimeRange: DateTimeRangeType, | ||
lexicalContext?: LexicalContext | undefined, | ||
) => void; | ||
selectedTime: string; | ||
} | ||
|
||
function RangePickerModal(props: RangePickerModalProps): JSX.Element { | ||
const { | ||
setCustomDTPickerVisible, | ||
setIsOpen, | ||
onCustomDateHandler, | ||
selectedTime, | ||
} = props; | ||
const { RangePicker } = DatePicker; | ||
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>( | ||
(state) => state.globalTime, | ||
); | ||
|
||
const disabledDate = (current: Dayjs): boolean => { | ||
const currentDay = dayjs(current); | ||
return currentDay.isAfter(dayjs()); | ||
}; | ||
|
||
const onPopoverClose = (visible: boolean): void => { | ||
if (!visible) { | ||
setCustomDTPickerVisible(false); | ||
} | ||
setIsOpen(visible); | ||
}; | ||
|
||
const onModalOkHandler = (date_time: any): void => { | ||
if (date_time?.[1]) { | ||
onPopoverClose(false); | ||
} | ||
onCustomDateHandler(date_time, LexicalContext.CUSTOM_DATE_PICKER); | ||
}; | ||
return ( | ||
<div className="custom-date-picker"> | ||
<RangePicker | ||
disabledDate={disabledDate} | ||
allowClear | ||
showTime | ||
onOk={onModalOkHandler} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...(selectedTime === 'custom' && { | ||
defaultValue: [dayjs(minTime / 1000000), dayjs(maxTime / 1000000)], | ||
})} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default RangePickerModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters