sadpandajoe commented on code in PR #45508: URL: https://github.com/apache/superset/pull/45508#discussion_r4372667916
########## superset-frontend/src/features/alerts/notificationMethods.ts: ########## @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { NotificationMethodOption, NotificationSetting } from './types'; + +const isSlackMethod = (method: NotificationMethodOption | undefined) => + method === NotificationMethodOption.Slack || + method === NotificationMethodOption.SlackV2; + +export function getNotificationMethodOptions( + available: NotificationMethodOption[], + settings: NotificationSetting[], + currentIndex?: number, +): NotificationMethodOption[] { + const selected = + currentIndex === undefined ? undefined : settings[currentIndex]?.method; + const options = available.filter( + method => + method === NotificationMethodOption.Teams || Review Comment: Teams is exempted from the one-per-method filter here, `TeamsDestinationSelect` doesn't hide keys already chosen in another row, and `validate_teams_recipients` in `commands/report/base.py` doesn't reject repeated keys. If an editor adds two Teams rows and picks `ops` in both, the save succeeds and each run posts two identical cards to the same channel. Should the select exclude keys used by other rows, or the backend reject duplicate Teams destination keys? ########## superset-frontend/src/features/alerts/AlertReportModal.test.tsx: ########## @@ -4662,3 +4665,406 @@ test('global attachment policy hides both the alert toggle and attachment contro ); } }); + +test('Teams preserves separate destination entries and serializes only their keys', async () => { Review Comment: This test saves two preloaded Teams rows without changing either row's method, so it doesn't cover the removal of the old "drop trailing rows when a method changes" behavior in `updateNotificationSetting`. If that truncation came back, the test would still pass. Could you add a case that loads `ops` and `finance`, switches the first row to Email with an address, saves, and asserts the PUT body contains both the new Email recipient and the unchanged `finance` Teams recipient? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
