Skip to content

Commit 336815c

Browse files
committed
ref(project-creation): Extract a useIssueAlertNotificationOptions hook
Pull the shared shell out of IssueAlertNotificationOptions into a useIssueAlertNotificationOptions hook: the shouldRenderNotificationConfigs derivation, the setup-button impression analytics, and the querySuccess gate. The SCM layout can reuse the same logic and analytics instead of duplicating them. The classic component consumes the hook and renders identically.
1 parent 808048a commit 336815c

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

static/app/views/projectInstall/issueAlertNotificationOptions.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,19 @@ export function useCreateNotificationAction({
249249
};
250250
}
251251

252-
export function IssueAlertNotificationOptions(
253-
notificationProps: IssueAlertNotificationProps
254-
) {
255-
const {actions, setActions, querySuccess, shouldRenderSetupButton} = notificationProps;
256-
252+
/**
253+
* Shared shell for the project-creation notification options: derives which
254+
* sub-controls to show and reports the setup-button impression. The classic
255+
* (`IssueAlertNotificationOptions`) and SCM (`ScmIssueAlertNotificationOptions`)
256+
* layouts reuse this and differ only in presentation.
257+
*
258+
* @public Consumed by the SCM layout in a downstream PR.
259+
*/
260+
export function useIssueAlertNotificationOptions({
261+
actions,
262+
querySuccess,
263+
shouldRenderSetupButton,
264+
}: IssueAlertNotificationProps) {
257265
const shouldRenderNotificationConfigs = actions.some(
258266
v => v !== MultipleCheckboxOptions.EMAIL
259267
);
@@ -262,6 +270,20 @@ export function IssueAlertNotificationOptions(
262270
setup_message_integration_button_shown: shouldRenderSetupButton,
263271
});
264272

273+
return {
274+
querySuccess,
275+
shouldRenderNotificationConfigs,
276+
shouldRenderSetupButton,
277+
};
278+
}
279+
280+
export function IssueAlertNotificationOptions(
281+
notificationProps: IssueAlertNotificationProps
282+
) {
283+
const {actions, setActions} = notificationProps;
284+
const {querySuccess, shouldRenderNotificationConfigs, shouldRenderSetupButton} =
285+
useIssueAlertNotificationOptions(notificationProps);
286+
265287
if (!querySuccess) {
266288
return null;
267289
}

0 commit comments

Comments
 (0)