fixed ui: [UI] Data Insights UI does not show scheduling options and range selector not including last day bug (#11288)

* fixed ui: [UI] Data Insights UI does not show scheduling options and range selector not including last day bug

* removing subtraction logic

* fixed time range issue

* cypress fix
This commit is contained in:
Shailesh Parmar 2023-04-26 17:31:48 +05:30 committed by GitHub
parent 84c4e38136
commit 1e4231f2f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 8 deletions

View File

@ -778,6 +778,7 @@ const AddIngestion = ({
{activeIngestionStep === 4 && ( {activeIngestionStep === 4 && (
<ScheduleInterval <ScheduleInterval
disabledCronChange={pipelineType === PipelineType.DataInsight}
includePeriodOptions={ includePeriodOptions={
pipelineType === PipelineType.DataInsight ? ['day'] : undefined pipelineType === PipelineType.DataInsight ? ['day'] : undefined
} }

View File

@ -20,6 +20,7 @@ import CronEditor from '../../common/CronEditor/CronEditor';
import { ScheduleIntervalProps } from '../addIngestion.interface'; import { ScheduleIntervalProps } from '../addIngestion.interface';
const ScheduleInterval = ({ const ScheduleInterval = ({
disabledCronChange,
includePeriodOptions, includePeriodOptions,
onBack, onBack,
onChange, onChange,
@ -39,6 +40,7 @@ const ScheduleInterval = ({
<Col span={24}> <Col span={24}>
<div> <div>
<CronEditor <CronEditor
disabledCronChange={disabledCronChange}
includePeriodOptions={includePeriodOptions} includePeriodOptions={includePeriodOptions}
value={repeatFrequency} value={repeatFrequency}
onChange={handleRepeatFrequencyChange} onChange={handleRepeatFrequencyChange}

View File

@ -83,6 +83,7 @@ export type ScheduleIntervalProps = {
repeatFrequency: string; repeatFrequency: string;
includePeriodOptions?: string[]; includePeriodOptions?: string[];
submitButtonLabel: string; submitButtonLabel: string;
disabledCronChange?: boolean;
onBack: () => void; onBack: () => void;
onDeploy: () => void; onDeploy: () => void;
}; };

View File

@ -19,6 +19,7 @@ import {
DEFAULT_SELECTED_RANGE, DEFAULT_SELECTED_RANGE,
PROFILER_FILTER_RANGE, PROFILER_FILTER_RANGE,
} from 'constants/profiler.constant'; } from 'constants/profiler.constant';
import { isUndefined } from 'lodash';
import { MenuInfo } from 'rc-menu/lib/interface'; import { MenuInfo } from 'rc-menu/lib/interface';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -56,9 +57,9 @@ function DatePickerMenu({
dateStrings dateStrings
) => { ) => {
if (values) { if (values) {
const startTs = Date.parse(dateStrings[0]) / 1000; const startTs = values[0]?.set({ h: 0, m: 0 }).utc().unix() ?? 0;
const endTs = Date.parse(dateStrings[1]) / 1000; const endTs = values[1]?.set({ h: 23, m: 59 }).utc().unix() ?? 0;
const daysCount = getDaysCount(dateStrings[0], dateStrings[1]); const daysCount = getDaysCount(dateStrings[0], dateStrings[1]);
@ -78,8 +79,13 @@ function DatePickerMenu({
}; };
const handleOptionClick = ({ key }: MenuInfo) => { const handleOptionClick = ({ key }: MenuInfo) => {
const selectedNumberOfDays = const filterRange =
PROFILER_FILTER_RANGE[key as keyof typeof PROFILER_FILTER_RANGE].days; PROFILER_FILTER_RANGE[key as keyof typeof PROFILER_FILTER_RANGE];
if (isUndefined(filterRange)) {
return;
}
const selectedNumberOfDays = filterRange.days;
const keyString = key as keyof typeof PROFILER_FILTER_RANGE; const keyString = key as keyof typeof PROFILER_FILTER_RANGE;
const startTs = getPastDatesTimeStampFromCurrentDate(selectedNumberOfDays); const startTs = getPastDatesTimeStampFromCurrentDate(selectedNumberOfDays);
@ -108,6 +114,7 @@ function DatePickerMenu({
<DatePicker.RangePicker <DatePicker.RangePicker
bordered={false} bordered={false}
clearIcon={<CloseCircleOutlined />} clearIcon={<CloseCircleOutlined />}
format={(value) => value.utc().format('YYYY-MM-DD')}
open={isMenuOpen} open={isMenuOpen}
placement="bottomRight" placement="bottomRight"
suffixIcon={null} suffixIcon={null}

View File

@ -88,6 +88,7 @@ export interface CronEditorProp {
value?: string; value?: string;
className?: string; className?: string;
disabled?: boolean; disabled?: boolean;
disabledCronChange?: boolean;
includePeriodOptions?: string[]; includePeriodOptions?: string[];
} }

View File

@ -142,7 +142,7 @@ const CronEditor: FC<CronEditorProp> = (props) => {
} }
}, [props, periodOptions]); }, [props, periodOptions]);
const { className, disabled } = props; const { className, disabled, disabledCronChange } = props;
const { selectedPeriod } = state; const { selectedPeriod } = state;
const startText = t('label.schedule-to-run-every'); const startText = t('label.schedule-to-run-every');
@ -557,7 +557,7 @@ const CronEditor: FC<CronEditorProp> = (props) => {
<Select <Select
className="w-full" className="w-full"
data-testid="cron-type" data-testid="cron-type"
disabled={disabled} disabled={disabledCronChange || disabled}
id="cronType" id="cronType"
options={filteredPeriodOptions.map(({ label, value }) => ({ options={filteredPeriodOptions.map(({ label, value }) => ({
label, label,

View File

@ -196,7 +196,10 @@ export const getPastDaysDateTimeMillis = (days: number) =>
export const getFormattedDateFromSeconds = ( export const getFormattedDateFromSeconds = (
timeStamp: number, timeStamp: number,
format?: string format?: string
) => DateTime.fromSeconds(timeStamp || 0).toFormat(format || 'dd/MMM HH:mm'); ) =>
DateTime.fromSeconds(timeStamp || 0)
.toUTC()
.toFormat(format || 'dd/MMM HH:mm');
/** /**
* It takes a timestamp in milliseconds and returns a formatted date string * It takes a timestamp in milliseconds and returns a formatted date string
* @param {number} timeStamp - The timeStamp in milliseconds. * @param {number} timeStamp - The timeStamp in milliseconds.
@ -205,7 +208,10 @@ export const getFormattedDateFromSeconds = (
export const getFormattedDateFromMilliSeconds = ( export const getFormattedDateFromMilliSeconds = (
timeStamp: number, timeStamp: number,
format?: string format?: string
) => DateTime.fromMillis(timeStamp || 0).toFormat(format || 'dd/MMM'); ) =>
DateTime.fromMillis(timeStamp || 0)
.toUTC()
.toFormat(format || 'dd/MMM');
/** /**
* It takes a timestamp in milliseconds and returns a formatted date like 'Oct 14, 1983, 9:30 AM'. * It takes a timestamp in milliseconds and returns a formatted date like 'Oct 14, 1983, 9:30 AM'.