-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/summit sponsor pages #755
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
base: master
Are you sure you want to change the base?
Changes from all commits
4285f53
325571c
436d709
05a0fa3
c924e22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /** | ||
| * Copyright 2018 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 { | ||
| authErrorHandler, | ||
| createAction, | ||
| getRequest, | ||
| postRequest, | ||
| startLoading, | ||
| stopLoading | ||
| } from "openstack-uicore-foundation/lib/utils/actions"; | ||
| import T from "i18n-react/dist/i18n-react"; | ||
| import { escapeFilterValue, getAccessTokenSafely } from "../utils/methods"; | ||
| import { getSponsorForms } from "./sponsor-forms-actions"; | ||
| import { | ||
| DEFAULT_CURRENT_PAGE, | ||
| DEFAULT_ORDER_DIR, | ||
| DEFAULT_PER_PAGE | ||
| } from "../utils/constants"; | ||
| import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions"; | ||
|
|
||
| export const REQUEST_SPONSOR_PAGES = "REQUEST_SPONSOR_PAGES"; | ||
| export const RECEIVE_SPONSOR_PAGES = "RECEIVE_SPONSOR_PAGES"; | ||
|
|
||
| export const GLOBAL_PAGE_CLONED = "GLOBAL_PAGE_CLONED"; | ||
|
|
||
| export const getSponsorPages = | ||
| ( | ||
| term = "", | ||
| page = DEFAULT_CURRENT_PAGE, | ||
| perPage = DEFAULT_PER_PAGE, | ||
| order = "id", | ||
| orderDir = DEFAULT_ORDER_DIR, | ||
| hideArchived = false, | ||
| sponsorshipTypesId = [] | ||
| ) => | ||
| async (dispatch, getState) => { | ||
| const { currentSummitState } = getState(); | ||
| const { currentSummit } = currentSummitState; | ||
| const accessToken = await getAccessTokenSafely(); | ||
| const filter = []; | ||
|
|
||
| dispatch(startLoading()); | ||
|
|
||
| if (term) { | ||
| const escapedTerm = escapeFilterValue(term); | ||
| filter.push(`name=@${escapedTerm},code=@${escapedTerm}`); | ||
| } | ||
|
|
||
| const params = { | ||
| page, | ||
| per_page: perPage, | ||
| access_token: accessToken, | ||
| expand: "sponsorship_types" | ||
| }; | ||
|
|
||
| if (hideArchived) filter.push("is_archived==0"); | ||
|
|
||
| if (sponsorshipTypesId?.length > 0) { | ||
| const formattedSponsorships = sponsorshipTypesId.join("&&"); | ||
| filter.push("applies_to_all_tiers==0"); | ||
| filter.push(`sponsorship_type_id_not_in==${formattedSponsorships}`); | ||
| } | ||
|
|
||
| if (filter.length > 0) { | ||
| params["filter[]"] = filter; | ||
| } | ||
|
|
||
| // order | ||
| if (order != null && orderDir != null) { | ||
| const orderDirSign = orderDir === 1 ? "" : "-"; | ||
| params.order = `${orderDirSign}${order}`; | ||
| } | ||
|
|
||
| return getRequest( | ||
| createAction(REQUEST_SPONSOR_PAGES), | ||
| createAction(RECEIVE_SPONSOR_PAGES), | ||
| `${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/show-pages`, | ||
| authErrorHandler, | ||
| { order, orderDir, page, term, hideArchived } | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
| }; | ||
|
|
||
| export const cloneGlobalPage = | ||
| (pagesIds, sponsorIds, allSponsors) => async (dispatch, getState) => { | ||
| const { currentSummitState } = getState(); | ||
| const accessToken = await getAccessTokenSafely(); | ||
| const { currentSummit } = currentSummitState; | ||
|
|
||
| dispatch(startLoading()); | ||
|
|
||
| const params = { | ||
| access_token: accessToken | ||
| }; | ||
|
|
||
| const normalizedEntity = { | ||
| page_template_ids: pagesIds, | ||
| sponsorship_types: sponsorIds, | ||
| apply_to_all_types: allSponsors | ||
| }; | ||
|
|
||
| if (allSponsors) { | ||
| delete normalizedEntity.sponsorship_types; | ||
| } | ||
|
|
||
| return postRequest( | ||
| null, | ||
| createAction(GLOBAL_PAGE_CLONED), | ||
| `${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/show-pages/clone`, | ||
| normalizedEntity, | ||
| snackbarErrorHandler | ||
| )(params)(dispatch) | ||
| .then(() => { | ||
| dispatch(getSponsorForms()); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| dispatch( | ||
| snackbarSuccessHandler({ | ||
| title: T.translate("general.success"), | ||
| html: T.translate("sponsor_pages.global_page_popup.success") | ||
| }) | ||
| ); | ||
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing finally stopLoading |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; | |
| import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment"; | ||
| import { useField } from "formik"; | ||
|
|
||
| const MuiFormikDatepicker = ({ name, label, required }) => { | ||
| const MuiFormikDatepicker = ({ name, label, required, ...props }) => { | ||
| const [field, meta, helpers] = useField(name); | ||
| const requiredLabel = `${label} *`; | ||
| return ( | ||
|
|
@@ -19,8 +19,7 @@ const MuiFormikDatepicker = ({ name, label, required }) => { | |
| label: required ? requiredLabel : label, | ||
| error: meta.touched && Boolean(meta.error), | ||
| helperText: meta.touched && meta.error, | ||
| fullWidth: true, | ||
| margin: "normal" | ||
| fullWidth: true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "mui-formik-datepicker.js" -type fRepository: fntechgit/summit-admin Length of output: 125 🏁 Script executed: head -50 src/components/mui/formik-inputs/mui-formik-datepicker.jsRepository: fntechgit/summit-admin Length of output: 1536 🌐 Web query:
💡 Result: In MUI X DatePicker, the
Sources: Citations:
🌐 Web query:
💡 Result: To set the <DatePicker
label="Start date"
slotProps={{
textField: { margin: 'dense' }, // or 'normal' | 'none'
}}
/>
MUI X DatePicker does not accept a 🐛 Proposed fix slotProps={{
textField: {
name,
label: required ? requiredLabel : label,
error: meta.touched && Boolean(meta.error),
helperText: meta.touched && meta.error,
- fullWidth: true
+ fullWidth: true,
+ margin: "normal"
},
day: {
sx: {
fontSize: "1.2rem",
fontWeight: 600
}
},
layout: {
sx: {
"& .MuiDayCalendar-weekDayLabel": {
fontSize: "1rem"
}
}
}
}}
- margin="normal"
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}🤖 Prompt for AI Agents |
||
| }, | ||
| day: { | ||
| sx: { | ||
|
|
@@ -36,6 +35,9 @@ const MuiFormikDatepicker = ({ name, label, required }) => { | |
| } | ||
| } | ||
| }} | ||
| margin="normal" | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| /> | ||
| </LocalizationProvider> | ||
| ); | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 975
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
# Check imports in the file to see where getRequest comes from head -30 src/actions/sponsor-pages-actions.jsRepository: fntechgit/summit-admin
Length of output: 1180
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 1204
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 6135
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 2526
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 4194
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 2389
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 1336
Ensure loading state clears on request failure.
stopLoading()runs only on success; ifgetRequestrejects, the spinner can remain stuck. Similar functions in the codebase explicitly handle rejection with.catch()and.finally()patterns (see sponsor-forms-actions.js with comments "need to catch promise reject").🐛 Proposed fix
return getRequest( createAction(REQUEST_SPONSOR_PAGES), createAction(RECEIVE_SPONSOR_PAGES), `${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/show-pages`, authErrorHandler, { order, orderDir, page, term, hideArchived } - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); + )(params)(dispatch).finally(() => { + dispatch(stopLoading()); + });📝 Committable suggestion
🤖 Prompt for AI Agents