From db8b8ff1cd206bb2e59f5198b7b941d5e94ab067 Mon Sep 17 00:00:00 2001 From: arunjaindev Date: Tue, 28 Jan 2025 15:15:43 +0530 Subject: [PATCH 1/5] fix: config id is 0 in save notification payload --- src/components/notifications/AddNotification.tsx | 5 +++-- src/components/notifications/notifications.service.ts | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) 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 29b09dbca0..561931e1e0 100644 --- a/src/components/notifications/notifications.service.ts +++ b/src/components/notifications/notifications.service.ts @@ -35,7 +35,6 @@ interface SaveNotificationPayload { eventTypeIds: number[] }[] providers: { configId: number; dest: 'ses' | 'slack' | ''; recipient: string }[] - sesConfigId: number } interface SaveNotificationResponseType extends ResponseType { @@ -84,7 +83,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) { @@ -135,13 +134,12 @@ function createSaveNotificationPayload(selectedPipelines, providers, sesConfigId return { notificationConfigRequest: allPipelines, providers, - sesConfigId, } } -export function saveNotification(selectedPipelines, providers, sesConfigId): Promise { +export function saveNotification(selectedPipelines, providers): Promise { const URL = `${Routes.NOTIFIER}` - const payload = createSaveNotificationPayload(selectedPipelines, providers, sesConfigId) + const payload = createSaveNotificationPayload(selectedPipelines, providers) return post(URL, payload) } From 60afbb13f4cef65c5a019f10f9c5be7a7330580d Mon Sep 17 00:00:00 2001 From: arunjaindev Date: Tue, 28 Jan 2025 16:48:24 +0530 Subject: [PATCH 2/5] fix: remove notification config call from env trigger view --- .../Details/TriggerView/EnvTriggerView.tsx | 19 ------------------- 1 file changed, 19 deletions(-) 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} /> ) From a1d205ccc8212d3faca3f0203ed03cfeb7a5d924 Mon Sep 17 00:00:00 2001 From: arunjaindev Date: Thu, 30 Jan 2025 12:45:40 +0530 Subject: [PATCH 3/5] feat: add type in post api save notification --- src/components/notifications/notifications.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/notifications/notifications.service.ts b/src/components/notifications/notifications.service.ts index 561931e1e0..c54f6b404c 100644 --- a/src/components/notifications/notifications.service.ts +++ b/src/components/notifications/notifications.service.ts @@ -138,9 +138,8 @@ function createSaveNotificationPayload(selectedPipelines, providers): SaveNotifi } export function saveNotification(selectedPipelines, providers): Promise { - const URL = `${Routes.NOTIFIER}` const payload = createSaveNotificationPayload(selectedPipelines, providers) - return post(URL, payload) + return post(Routes.NOTIFIER, payload) } export function getChannelConfigs(): Promise { From 43b6df938b8a3c6297bd1c50a5dcdc3b58a9f34d Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Fri, 31 Jan 2025 12:05:44 +0530 Subject: [PATCH 4/5] feat: send recipient with configId as well --- .../notifications/notifications.service.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/notifications/notifications.service.ts b/src/components/notifications/notifications.service.ts index c54f6b404c..19776e1c50 100644 --- a/src/components/notifications/notifications.service.ts +++ b/src/components/notifications/notifications.service.ts @@ -118,17 +118,10 @@ function createSaveNotificationPayload(selectedPipelines, providers): SaveNotifi } }) 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 { @@ -139,6 +132,7 @@ function createSaveNotificationPayload(selectedPipelines, providers): SaveNotifi export function saveNotification(selectedPipelines, providers): Promise { const payload = createSaveNotificationPayload(selectedPipelines, providers) + console.log({payload}) return post(Routes.NOTIFIER, payload) } From e60b3e9ade591b43c94e516d29e9e08f37fa16e4 Mon Sep 17 00:00:00 2001 From: arunjaindev Date: Tue, 11 Feb 2025 15:42:08 +0530 Subject: [PATCH 5/5] chore: remove console log --- src/components/notifications/notifications.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/notifications/notifications.service.ts b/src/components/notifications/notifications.service.ts index e58b30fc88..f608f985da 100644 --- a/src/components/notifications/notifications.service.ts +++ b/src/components/notifications/notifications.service.ts @@ -131,7 +131,6 @@ function createSaveNotificationPayload(selectedPipelines, providers): SaveNotifi export function saveNotification(selectedPipelines, providers): Promise { const payload = createSaveNotificationPayload(selectedPipelines, providers) - console.log({payload}) return post(Routes.NOTIFIER, payload) }