Skip to content

Commit

Permalink
remove notifications references from create and edit report definitio…
Browse files Browse the repository at this point in the history
…n pages (opensearch-project#212)

Signed-off by: David Cui <davidcui@amazon.com>
  • Loading branch information
davidcui1225 authored Nov 3, 2021
1 parent 41f9551 commit d5f298b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { ReportSettings } from '../report_settings';
import { ReportDelivery } from '../delivery';
import { generateReportFromDefinitionId } from '../../main/main_utils';
import { converter } from '../utils';
import {
Expand Down Expand Up @@ -159,29 +158,6 @@ export function CreateReport(props: { [x: string]: any; setBreadcrumbs?: any; ht
setShowTriggerIntervalNaNError,
] = useState(false);
const [showCronError, setShowCronError] = useState(false);
const [showDeliveryChannelError, setShowDeliveryChannelError] = useState(
false
);
const [
deliveryChannelError,
setDeliveryChannelError,
] = useState('');
const [
showDeliverySubjectError,
setShowDeliverySubjectError
] = useState(false);
const [
deliverySubjectError,
setDeliverySubjectError
] = useState('');
const [
showDeliveryTextError,
setShowDeliveryTextError
] = useState(false);
const [
deliveryTextError,
setDeliveryTextError
] = useState('');
const [showTimeRangeError, setShowTimeRangeError] = useState(false);

// preserve the state of the request after an invalid create report definition request
Expand Down Expand Up @@ -287,12 +263,6 @@ export function CreateReport(props: { [x: string]: any; setBreadcrumbs?: any; ht
timeRange,
setShowTimeRangeError,
setShowCronError,
setShowDeliveryChannelError,
setDeliveryChannelError,
setShowDeliverySubjectError,
setDeliverySubjectError,
setShowDeliveryTextError,
setDeliveryTextError
).then((response) => {
error = response;
});
Expand Down Expand Up @@ -385,19 +355,6 @@ export function CreateReport(props: { [x: string]: any; setBreadcrumbs?: any; ht
showCronError={showCronError}
/>
<EuiSpacer />
<ReportDelivery
edit={false}
editDefinitionId={''}
httpClientProps={props['httpClient']}
reportDefinitionRequest={createReportDefinitionRequest}
showDeliveryChannelError={showDeliveryChannelError}
deliveryChannelError={deliveryChannelError}
showDeliverySubjectError={showDeliverySubjectError}
deliverySubjectError={deliverySubjectError}
showDeliveryTextError={showDeliveryTextError}
deliveryTextError={deliveryTextError}
/>
<EuiSpacer />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
EuiGlobalToastList,
} from '@elastic/eui';
import { ReportSettings } from '../report_settings';
import { ReportDelivery } from '../delivery';
import { ReportTrigger } from '../report_trigger';
import { ReportDefinitionSchemaType } from 'server/model';
import { converter } from '../utils';
Expand Down Expand Up @@ -74,13 +73,6 @@ export function EditReportDefinition(props: { [x: string]: any; setBreadcrumbs?:
setShowTriggerIntervalNaNError,
] = useState(false);
const [showCronError, setShowCronError] = useState(false);
const [showDeliveryChannelError, setShowDeliveryChannelError] = useState(
false
);
const [
deliveryChannelError,
setDeliveryChannelError,
] = useState('');
const [showTimeRangeError, setShowTimeRangeError] = useState(false);

const addPermissionsMissingViewEditPageToastHandler = (errorType: string) => {
Expand Down Expand Up @@ -262,8 +254,6 @@ export function EditReportDefinition(props: { [x: string]: any; setBreadcrumbs?:
timeRange,
setShowTimeRangeError,
setShowCronError,
setShowDeliveryChannelError,
setDeliveryChannelError
).then((response) => {
error = response;
});
Expand Down Expand Up @@ -347,15 +337,6 @@ export function EditReportDefinition(props: { [x: string]: any; setBreadcrumbs?:
showCronError={showCronError}
/>
<EuiSpacer />
<ReportDelivery
edit={true}
editDefinitionId={reportDefinitionId}
reportDefinitionRequest={editReportDefinitionRequest}
httpClientProps={props['httpClient']}
showDeliveryChannelError={showDeliveryChannelError}
deliveryChannelError={deliveryChannelError}
/>
<EuiSpacer />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
Expand Down
44 changes: 1 addition & 43 deletions public/components/report_definitions/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ export const definitionInputValidation = async (
setShowTriggerIntervalNaNError,
timeRange,
setShowTimeRangeError,
setShowCronError,
setShowDeliveryChannelError,
setDeliveryChannelsErrorMessage,
setShowDeliverySubjectError,
setDeliverySubjectError,
setShowDeliveryTextError,
setDeliveryTextError
setShowCronError
) => {
// check report name
// allow a-z, A-Z, 0-9, (), [], ',' - and _ and spaces
Expand Down Expand Up @@ -104,41 +98,5 @@ export const definitionInputValidation = async (
error = true;
}
}
// delivery
if (includeDelivery) {
if (metadata.delivery.configIds.length === 0) {
// no channels are listed
setShowDeliveryChannelError(true);
setDeliveryChannelsErrorMessage(
i18n.translate(
'opensearch.reports.error.channelListCannotBeEmpty',
{ defaultMessage: 'Channels list cannot be empty.' }
)
);
error = true;
}
// subject is empty
if (metadata.delivery.title === '') {
setShowDeliverySubjectError(true);
setDeliverySubjectError(
i18n.translate(
'opensearch.reports.error.deliverySubjectCannotBeEmpty',
{ defaultMessage: 'Subject cannot be empty.' }
)
);
error = true;
}
// message is empty
if (metadata.delivery.textDescription === '') {
setShowDeliveryTextError(true);
setDeliveryTextError(
i18n.translate(
'opensearch.reports.error.deliverySubjectCannotBeEmpty',
{ defaultMessage: 'Subject cannot be empty.' }
)
);
error = true;
}
}
return error;
};

0 comments on commit d5f298b

Please sign in to comment.