forked from OpenStackweb/summit-admin
-
Notifications
You must be signed in to change notification settings - Fork 4
FE: CFP reopen notification, recipient selection and Notify button #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caseylocker
wants to merge
17
commits into
master
Choose a base branch
from
feature/cfp-reopen-notify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e239bf3
feat(event-form): derive CFP reopen notification recipient rows
caseylocker 5f48334
fix(event-form): key the speaker dedupe map by the string row key
caseylocker 667c601
feat(event-actions): add notifySubmissionReopened thunk
caseylocker f088748
test(event-actions): assert translate params so the recipient-count t…
caseylocker ca305f5
feat(event-form): notify selected recipients about a CFP reopen window
caseylocker f5520a0
fix(event-form): gate notify-send button on the actual sendable selec…
caseylocker d27bb42
fix(event-form): fix merged recipient names and stale notify payload
caseylocker 8de08a3
fix(event-form): intersect pre/post-dialog notify selections
caseylocker 2c99229
chore(event-form): convention pass on notify recipients
caseylocker f1a7386
fix(i18n): use recipient(s) in the notify confirm title
caseylocker 08e8fdc
fix(event-form): derive notify rows from persisted entity
caseylocker 75beb7d
fix(event-form): restore empty-notify-payload guard
caseylocker 71bd1f3
fix(event-form): separate recipient name from roles with a dash
caseylocker 38ea895
style(event-form): space notify recipient rows and send button
caseylocker 3e209c3
chore(event-form): drop dupe comment, vacuous test, and a rotting rat…
caseylocker 8f4c952
chore(event-form): convention pass on notify tail
caseylocker 1b7ace9
refactor(event-form): address review, extract notify panel and trim t…
caseylocker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import configureStore from "redux-mock-store"; | ||
| import thunk from "redux-thunk"; | ||
| import { putRequest } from "openstack-uicore-foundation/lib/utils/actions"; | ||
| import T from "i18n-react/dist/i18n-react"; | ||
| import * as methods from "../../utils/methods"; | ||
| import { notifySubmissionReopened } from "../event-actions"; | ||
|
|
||
| jest.mock("i18n-react/dist/i18n-react", () => ({ | ||
| __esModule: true, | ||
| default: { translate: jest.fn((key) => key) } | ||
| })); | ||
|
|
||
| jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({ | ||
| __esModule: true, | ||
| ...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"), | ||
| putRequest: jest.fn() | ||
| })); | ||
|
|
||
| const mockStore = configureStore([thunk]); | ||
|
|
||
| describe("notifySubmissionReopened", () => { | ||
| const summitId = 5; | ||
| let store; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| window.API_BASE_URL = "https://api.test"; | ||
| store = mockStore({ | ||
| currentSummitState: { currentSummit: { id: summitId } } | ||
| }); | ||
| jest.spyOn(methods, "getAccessTokenSafely").mockResolvedValue("TOKEN"); | ||
| }); | ||
|
|
||
| const arrangeRequest = ( | ||
| result = Promise.resolve({ response: { recipients: 3 } }) | ||
| ) => { | ||
| putRequest.mockReturnValue(() => () => result); | ||
| }; | ||
|
|
||
| it("PUTs the selection to the notify endpoint in the API's snake_case shape", async () => { | ||
| arrangeRequest(); | ||
|
|
||
| await store.dispatch( | ||
| notifySubmissionReopened(42, { | ||
| speakerIds: [7, 12], | ||
| includeSubmitter: true | ||
| }) | ||
| ); | ||
|
|
||
| expect(putRequest).toHaveBeenCalledTimes(1); | ||
| const [requestAction, , url, body] = putRequest.mock.calls[0]; | ||
| expect(requestAction).toBeNull(); | ||
| expect(url).toBe( | ||
| `https://api.test/api/v1/summits/${summitId}/presentations/42/submission-period/reopen/notify` | ||
| ); | ||
| expect(body).toEqual({ speaker_ids: [7, 12], include_submitter: true }); | ||
| }); | ||
|
|
||
| it("reports the recipient count from the response, not a client tally", async () => { | ||
| arrangeRequest(Promise.resolve({ response: { recipients: 3 } })); | ||
|
|
||
| await store.dispatch( | ||
| notifySubmissionReopened(42, { speakerIds: [7], includeSubmitter: false }) | ||
| ); | ||
|
|
||
| expect(T.translate).toHaveBeenCalledWith( | ||
| "edit_event.notify_speakers_success", | ||
| { count: 3 } | ||
| ); | ||
|
|
||
| const snackbar = store | ||
| .getActions() | ||
| .find((a) => a.type === "SET_SNACKBAR_MESSAGE"); | ||
| expect(snackbar).toBeDefined(); | ||
| expect(snackbar.payload.type).toBe("success"); | ||
| }); | ||
|
|
||
| it("stops loading even when the request rejects", async () => { | ||
| arrangeRequest(Promise.reject(new Error("412"))); | ||
|
|
||
| await expect( | ||
| store.dispatch( | ||
| notifySubmissionReopened(42, { | ||
| speakerIds: [7], | ||
| includeSubmitter: false | ||
| }) | ||
| ) | ||
| ).rejects.toThrow(); | ||
|
|
||
| expect(store.getActions().map((a) => a.type)).toContain("STOP_LOADING"); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed 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 React from "react"; | ||
| import PropTypes from "prop-types"; | ||
| import T from "i18n-react/dist/i18n-react"; | ||
| import { ROLE } from "./utils"; | ||
|
|
||
| const ROLE_LABEL = { | ||
| [ROLE.SUBMITTER]: "edit_event.notify_role_submitter", | ||
| [ROLE.MODERATOR]: "edit_event.notify_role_moderator", | ||
| [ROLE.SPEAKER]: "edit_event.notify_role_speaker" | ||
| }; | ||
|
|
||
| const ReopenNotifyPanel = ({ | ||
| rows, | ||
| checked, | ||
| onToggle, | ||
| canNotify, | ||
| onNotify | ||
| }) => ( | ||
| <div style={{ flexBasis: "100%" }}> | ||
| <label>{T.translate("edit_event.notify_recipients_label")}</label> | ||
| <div | ||
| style={{ | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| gap: 10, | ||
| marginTop: 10 | ||
| }} | ||
| > | ||
| {rows.map((row) => ( | ||
| <div className="form-check abc-checkbox" key={row.key}> | ||
| <input | ||
| type="checkbox" | ||
| id={`notify_recipient_${row.key}`} | ||
| className="form-check-input" | ||
| disabled={row.disabled} | ||
| checked={checked.includes(row.key)} | ||
| onChange={() => onToggle(row.key)} | ||
| /> | ||
| <label | ||
| className="form-check-label" | ||
| htmlFor={`notify_recipient_${row.key}`} | ||
| > | ||
| {row.name} | ||
| - | ||
| {row.roles.map((role) => T.translate(ROLE_LABEL[role])).join(", ")} | ||
| </label> | ||
| {row.disabled && ( | ||
| <span> | ||
| | ||
| {T.translate("edit_event.notify_no_email")} | ||
| </span> | ||
| )} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| <button | ||
| type="button" | ||
| className="btn btn-primary" | ||
| style={{ marginTop: 10 }} | ||
| disabled={!canNotify} | ||
| onClick={onNotify} | ||
| > | ||
| {T.translate("edit_event.notify_speakers")} | ||
| </button> | ||
| </div> | ||
| ); | ||
|
|
||
| ReopenNotifyPanel.propTypes = { | ||
| rows: PropTypes.array.isRequired, | ||
| checked: PropTypes.array.isRequired, | ||
| onToggle: PropTypes.func.isRequired, | ||
| canNotify: PropTypes.bool.isRequired, | ||
| onNotify: PropTypes.func.isRequired | ||
| }; | ||
|
|
||
| export default ReopenNotifyPanel; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please lets only have meaningful tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cut from 37 to 19. Gone: the ordering assertion on
startLoading, tests for inputs the API cannot produce (speaker ids are serialised as ints), render tests that re-asserted row-model behaviour already covered at the unit level, and four that only reached their state by callingrerenderdirectly, which bypasses the page'sif (loading) return null. That gate also meant the post-confirm intersection could never narrow anything in the running app, so that code is gone too, along with its tests.Kept the one you flagged here. The thunk's
.finallyis the only thing that clears loading on rejection, and the page rendersnullwhile loading is set, so a stuck flag blanks the page rather than leaving a spinner.