-
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
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,134 @@ | ||
| /** | ||
| * 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 { | ||
| 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()); | ||
| dispatch( | ||
| snackbarSuccessHandler({ | ||
| title: T.translate("general.success"), | ||
| html: T.translate("sponsor_pages.global_page_popup.success") | ||
| }) | ||
| ); | ||
| }) | ||
| .catch(() => {}); // need to catch promise reject | ||
|
Comment on lines
+95
to
+133
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
Suggested fix 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());
dispatch(
snackbarSuccessHandler({
title: T.translate("general.success"),
html: T.translate("sponsor_pages.global_page_popup.success")
})
);
})
- .catch(() => {}); // need to catch promise reject
+ .catch(() => {})
+ .finally(() => {
+ dispatch(stopLoading());
+ });
};🤖 Prompt for AI Agents |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,15 @@ import { | |
| FormHelperText, | ||
| FormControl, | ||
| InputAdornment, | ||
| IconButton | ||
| IconButton, | ||
| InputLabel | ||
| } from "@mui/material"; | ||
| import ClearIcon from "@mui/icons-material/Clear"; | ||
| import { useField } from "formik"; | ||
|
|
||
| const MuiFormikSelect = ({ | ||
| name, | ||
| label, | ||
| placeholder, | ||
| children, | ||
| isClearable, | ||
|
|
@@ -24,12 +26,23 @@ const MuiFormikSelect = ({ | |
| helpers.setValue(""); | ||
| }; | ||
|
|
||
| const hasValue = | ||
| field.value !== "" && field.value !== undefined && field.value !== null; | ||
|
|
||
| return ( | ||
| <FormControl fullWidth error={meta.touched && Boolean(meta.error)}> | ||
| {label && ( | ||
| <InputLabel htmlFor={name} id={`${name}-label`} shrink={hasValue}> | ||
| {label} | ||
| </InputLabel> | ||
| )} | ||
| <Select | ||
| name={name} | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...field} | ||
| labelId={`${name}-label`} | ||
| label={label} | ||
| notched={hasValue} | ||
|
Comment on lines
+34
to
+45
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: cat -n src/components/mui/formik-inputs/mui-formik-select.jsRepository: fntechgit/summit-admin Length of output: 2702 🏁 Script executed: rg "MuiFormikSelect" --type js --type jsx -A 3 -B 1 | head -100Repository: fntechgit/summit-admin Length of output: 93 🏁 Script executed: rg "MuiFormikSelect" -A 3 -B 1 | head -150Repository: fntechgit/summit-admin Length of output: 12188 🏁 Script executed: rg "MuiFormikSelect" -B 5 -A 8 "src/components/mui/formik-inputs/additional-input/additional-input.js"Repository: fntechgit/summit-admin Length of output: 1516 Label and placeholder text may visually overlap when no value is selected. When The label should always shrink when a placeholder is present: Suggested fix const hasValue =
field.value !== "" && field.value !== undefined && field.value !== null;
+ const shouldShrink = hasValue || Boolean(placeholder);
return (
<FormControl fullWidth error={meta.touched && Boolean(meta.error)}>
{label && (
- <InputLabel htmlFor={name} id={`${name}-label`} shrink={hasValue}>
+ <InputLabel htmlFor={name} id={`${name}-label`} shrink={shouldShrink}>
{label}
</InputLabel>
)}
<Select
name={name}
// eslint-disable-next-line react/jsx-props-no-spreading
{...field}
labelId={`${name}-label`}
label={label}
- notched={hasValue}
+ notched={shouldShrink}🤖 Prompt for AI Agents |
||
| displayEmpty | ||
| renderValue={(selected) => { | ||
| if (!selected || selected === "") { | ||
|
|
||
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.
getSponsorFormsis not imported - this will cause a runtime error.The function
getSponsorForms()is called but never imported. This will throw aReferenceErrorat runtime whencloneGlobalPagesucceeds.Suggested fix
Add the missing import at the top of the file:
+import { getSponsorForms } from "./sponsor-actions";Or, if the intent was to refresh sponsor pages instead:
.then(() => { - dispatch(getSponsorForms()); + dispatch(getSponsorPages());📝 Committable suggestion
🤖 Prompt for AI Agents