diff --git a/src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx b/src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx index 671621fdc0..6310b1df31 100644 --- a/src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx +++ b/src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx @@ -33,7 +33,6 @@ import { WorkflowNodeType, CommonNodeAttr, WorkflowType, - getDefaultConfig, abortPreviousRequests, getIsRequestAborted, handleUTCTime, @@ -189,8 +188,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou const [responseList, setResponseList] = useState([]) const [isSelectAll, setSelectAll] = useState(false) const [selectAllValue, setSelectAllValue] = useState(CHECKBOX_VALUE.CHECKED) - const [isConfigPresent, setConfigPresent] = useState(false) - const [isDefaultConfigPresent, setDefaultConfig] = useState(false) // Mapping pipelineId (in case of CI) and appId (in case of CD) to runtime params const [runtimeParams, setRuntimeParams] = useState>({}) const [runtimeParamsErrorState, setRuntimeParamsErrorState] = useState>({}) @@ -202,10 +199,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou usePrompt({ shouldPrompt: enableRoutePrompt }) useEffect(() => { - if (ApprovalMaterialModal) { - getConfigs() - } - return () => { handledLocation.current = false } @@ -309,16 +302,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou } }, [filteredWorkflows]) - // TODO: This call should not be here rather inside ApprovalMaterialModal - const getConfigs = () => { - getDefaultConfig().then((response) => { - const isConfigPresent = response.result.isConfigured - const _isDefaultConfig = response.result.is_default_configured - setDefaultConfig(_isDefaultConfig) - setConfigPresent(isConfigPresent) - }) - } - const preserveSelection = (_workflows: WorkflowType[]) => { if (!workflows || !_workflows) { return @@ -2268,8 +2251,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou pipelineId={selectedCDNode?.id} getModuleInfo={getModuleInfo} ciPipelineId={node?.connectingCiPipelineId} - configs={isConfigPresent} - isDefaultConfigPresent={isDefaultConfigPresent} history={history} /> ) diff --git a/src/components/notifications/AddNotification.tsx b/src/components/notifications/AddNotification.tsx index a98896cbac..389a888719 100644 --- a/src/components/notifications/AddNotification.tsx +++ b/src/components/notifications/AddNotification.tsx @@ -433,6 +433,7 @@ export class AddNotification extends Component { + saveNotification(selectedPipelines, selectedChannels) + .then(() => { this.props.history.push(`${URLS.GLOBAL_CONFIG_NOTIFIER}/channels`) ToastManager.showToast({ variant: ToastVariantType.success, diff --git a/src/components/notifications/notifications.service.ts b/src/components/notifications/notifications.service.ts index 31a72ce81c..f608f985da 100644 --- a/src/components/notifications/notifications.service.ts +++ b/src/components/notifications/notifications.service.ts @@ -34,7 +34,6 @@ interface SaveNotificationPayload { eventTypeIds: number[] }[] providers: { configId: number; dest: 'ses' | 'slack' | ''; recipient: string }[] - sesConfigId: number } interface SaveNotificationResponseType extends ResponseType { @@ -83,7 +82,7 @@ interface SESConfigResponseType extends ResponseType { } } -function createSaveNotificationPayload(selectedPipelines, providers, sesConfigId: number): SaveNotificationPayload { +function createSaveNotificationPayload(selectedPipelines, providers): SaveNotificationPayload { const allPipelines = selectedPipelines.map((config) => { const eventTypeIds = [] if (config.trigger) { @@ -118,30 +117,21 @@ function createSaveNotificationPayload(selectedPipelines, providers, sesConfigId } }) providers = providers.map((p) => { - if (p.data.configId) { - return { - configId: p.data.configId, - dest: p.data.dest, - recipient: '', - } - } return { - configId: 0, + configId: p.data.configId || 0, dest: p.data.dest || '', - recipient: p.data.recipient, + recipient: p.data.recipient || '', } }) return { notificationConfigRequest: allPipelines, providers, - sesConfigId, } } -export function saveNotification(selectedPipelines, providers, sesConfigId): Promise { - const URL = `${Routes.NOTIFIER}` - const payload = createSaveNotificationPayload(selectedPipelines, providers, sesConfigId) - return post(URL, payload) +export function saveNotification(selectedPipelines, providers): Promise { + const payload = createSaveNotificationPayload(selectedPipelines, providers) + return post(Routes.NOTIFIER, payload) } export function getChannelConfigs(): Promise {