Skip to content

Commit bcc1570

Browse files
fix(ui): grey out advanced box when putting hashmark
1 parent 32fb307 commit bcc1570

File tree

1 file changed

+27
-37
lines changed

1 file changed

+27
-37
lines changed

datahub-web-react/src/app/ingest/source/builder/CreateScheduleStep.tsx

+27-37
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Cron } from 'react-js-cron';
55
import 'react-js-cron/dist/styles.css';
66
import styled from 'styled-components';
77
import cronstrue from 'cronstrue';
8-
import { CheckCircleOutlined, WarningOutlined, InfoCircleOutlined } from '@ant-design/icons';
8+
import { CheckCircleOutlined } from '@ant-design/icons';
99
import { SourceBuilderState, StepProps } from './types';
1010
import { TimezoneSelect } from './TimezoneSelect';
1111
import { ANTD_GRAY, REDESIGN_COLORS } from '../../../entity/shared/constants';
@@ -76,27 +76,11 @@ const WarningContainer = styled.div`
7676
color: ${ANTD_GRAY[7]};
7777
`;
7878

79-
const StyledWarningOutlined = styled(WarningOutlined)`
79+
const StyledWarningOutlined = styled(CheckCircleOutlined)`
8080
margin-right: 4px;
8181
margin-top: 12px;
8282
`;
8383

84-
const HashmarkNotice = styled.div`
85-
margin-top: 8px;
86-
padding: 8px;
87-
background-color: #e6f7ff;
88-
border: 1px solid #91d5ff;
89-
border-radius: 4px;
90-
display: flex;
91-
align-items: flex-start;
92-
`;
93-
94-
const InfoIcon = styled(InfoCircleOutlined)`
95-
color: #1890ff;
96-
margin-right: 8px;
97-
margin-top: 3px;
98-
`;
99-
10084
const containsHashmark = (cronExpression: string): boolean => {
10185
return cronExpression.includes('#');
10286
};
@@ -197,26 +181,32 @@ export const CreateScheduleStep = ({ state, updateState, goTo, prev }: StepProps
197181
/>
198182
)}
199183
<AdvancedSchedule>
200-
<AdvancedCheckBox type="secondary">Show Advanced</AdvancedCheckBox>
201-
<Checkbox
202-
checked={advancedCronCheck}
203-
onChange={(event) => setAdvancedCronCheck(event.target.checked)}
204-
/>
184+
<div style={{ display: 'flex', alignItems: 'center' }}>
185+
{advancedCronCheck && hasHashmark && (
186+
<Typography.Text
187+
style={{
188+
color: '#1890ff',
189+
marginRight: '8px',
190+
fontSize: '12px',
191+
}}
192+
>
193+
(Unsupported syntax detected)
194+
</Typography.Text>
195+
)}
196+
<AdvancedCheckBox type="secondary">Show Advanced</AdvancedCheckBox>
197+
<Checkbox
198+
checked={advancedCronCheck}
199+
onChange={(event) => {
200+
if (hasHashmark && advancedCronCheck && !event.target.checked) {
201+
return;
202+
}
203+
setAdvancedCronCheck(event.target.checked);
204+
}}
205+
disabled={hasHashmark && advancedCronCheck}
206+
/>
207+
</div>
205208
</AdvancedSchedule>
206209
</Schedule>
207-
{advancedCronCheck && hasHashmark && (
208-
<HashmarkNotice>
209-
<InfoIcon />
210-
<div>
211-
<Typography.Text strong>Special schedule syntax detected</Typography.Text>
212-
<Typography.Paragraph style={{ marginBottom: 0 }}>
213-
Your schedule uses special syntax (# character) to run on a specific occurrence of a day each month.
214-
Please combine the day of the month with the day of the week to achieve this schedule.
215-
For example use '0 0 8-14 0 1' instead of '0 0 0 0 1#2' for the 2nd Monday of the month
216-
</Typography.Paragraph>
217-
</div>
218-
</HashmarkNotice>
219-
)}
220210
<CronText>
221211
{cronAsText.error && <>Invalid cron schedule. Cron must be of UNIX form:</>}
222212
{!cronAsText.text && (
@@ -244,7 +234,7 @@ export const CreateScheduleStep = ({ state, updateState, goTo, prev }: StepProps
244234
<div>
245235
<Button
246236
data-testid="ingestion-schedule-next-button"
247-
disabled={!interval || interval.length === 0 || cronAsText.error}
237+
disabled={!scheduleCronInterval || scheduleCronInterval.length === 0 || cronAsText.error}
248238
onClick={onClickNext}
249239
>
250240
Next

0 commit comments

Comments
 (0)