-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add sponsor pages tab, add customized and managed tables #771
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
0a2f11d
b6f85e5
83cc52e
b1ef29b
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 |
|---|---|---|
|
|
@@ -13,16 +13,28 @@ | |
|
|
||
| import { | ||
| createAction, | ||
| getRequest, | ||
| postRequest, | ||
| startLoading, | ||
| stopLoading | ||
| stopLoading, | ||
| authErrorHandler, | ||
| escapeFilterValue | ||
| } from "openstack-uicore-foundation/lib/utils/actions"; | ||
| import T from "i18n-react/dist/i18n-react"; | ||
| import { getAccessTokenSafely } from "../utils/methods"; | ||
| import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions"; | ||
| import { DEFAULT_CURRENT_PAGE, DEFAULT_ORDER_DIR, DEFAULT_PER_PAGE } from "../utils/constants"; | ||
|
|
||
| export const GLOBAL_PAGE_CLONED = "GLOBAL_PAGE_CLONED"; | ||
|
|
||
| export const REQUEST_SPONSOR_MANAGED_PAGES = "REQUEST_SPONSOR_MANAGED_PAGES"; | ||
| export const RECEIVE_SPONSOR_MANAGED_PAGES = "RECEIVE_SPONSOR_MANAGED_PAGES"; | ||
|
|
||
| export const REQUEST_SPONSOR_CUSTOMIZED_PAGES = | ||
| "REQUEST_SPONSOR_CUSTOMIZED_PAGES"; | ||
| export const RECEIVE_SPONSOR_CUSTOMIZED_PAGES = | ||
| "RECEIVE_SPONSOR_CUSTOMIZED_PAGES"; | ||
|
|
||
| export const cloneGlobalPage = | ||
| (pagesIds, sponsorIds, allSponsors) => async (dispatch, getState) => { | ||
| const { currentSummitState } = getState(); | ||
|
|
@@ -62,3 +74,123 @@ export const cloneGlobalPage = | |
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| }; | ||
|
|
||
| /* ************************************************************************ */ | ||
| /* MANAGED PAGES */ | ||
| /* ************************************************************************ */ | ||
|
|
||
| export const getSponsorManagedPages = | ||
| ( | ||
| term = "", | ||
| page = DEFAULT_CURRENT_PAGE, | ||
| perPage = DEFAULT_PER_PAGE, | ||
| order = "id", | ||
| orderDir = DEFAULT_ORDER_DIR, | ||
| hideArchived = false | ||
| ) => | ||
| async (dispatch, getState) => { | ||
| const { currentSummitState, currentSponsorState } = getState(); | ||
| const { currentSummit } = currentSummitState; | ||
| const { | ||
| entity: { id: sponsorId } | ||
| } = currentSponsorState; | ||
| const accessToken = await getAccessTokenSafely(); | ||
| const summitTZ = currentSummit.time_zone.name; | ||
| const filter = []; | ||
|
|
||
| dispatch(startLoading()); | ||
|
|
||
| if (term) { | ||
| const escapedTerm = escapeFilterValue(term); | ||
| filter.push(`name=@${escapedTerm},code=@${escapedTerm}`); | ||
| } | ||
|
|
||
| const params = { | ||
| page, | ||
| fields: "id,code,name,kind,modules_count,allowed_add_ons", | ||
| per_page: perPage, | ||
| access_token: accessToken | ||
| }; | ||
|
|
||
| if (hideArchived) filter.push("is_archived==0"); | ||
|
|
||
| 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_MANAGED_PAGES), | ||
| createAction(RECEIVE_SPONSOR_MANAGED_PAGES), | ||
| `${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-pages`, | ||
| authErrorHandler, | ||
| { order, orderDir, page, perPage, term, hideArchived, summitTZ } | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
|
Comment on lines
+127
to
+135
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. Ensure loading state clears on failures.
🛠️ Suggested fix- return getRequest(
+ return getRequest(
createAction(REQUEST_SPONSOR_MANAGED_PAGES),
createAction(RECEIVE_SPONSOR_MANAGED_PAGES),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-pages`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
- )(params)(dispatch).then(() => {
- dispatch(stopLoading());
- });
+ )(params)(dispatch)
+ .finally(() => dispatch(stopLoading()));Apply to both managed and customized requests. Also applies to: 187-195 🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| /* ************************************************************************ */ | ||
| /* CUSTOMIZED PAGES */ | ||
| /* ************************************************************************ */ | ||
|
|
||
| export const getSponsorCustomizedPages = | ||
| ( | ||
| term = "", | ||
| page = DEFAULT_CURRENT_PAGE, | ||
| perPage = DEFAULT_PER_PAGE, | ||
| order = "id", | ||
| orderDir = DEFAULT_ORDER_DIR, | ||
| hideArchived = false | ||
| ) => | ||
| async (dispatch, getState) => { | ||
| const { currentSummitState, currentSponsorState } = getState(); | ||
| const { currentSummit } = currentSummitState; | ||
| const { | ||
| entity: { id: sponsorId } | ||
| } = currentSponsorState; | ||
| const accessToken = await getAccessTokenSafely(); | ||
| const summitTZ = currentSummit.time_zone.name; | ||
| const filter = []; | ||
|
|
||
| dispatch(startLoading()); | ||
|
|
||
| if (term) { | ||
| const escapedTerm = escapeFilterValue(term); | ||
| filter.push(`name=@${escapedTerm},code=@${escapedTerm}`); | ||
| } | ||
|
|
||
| const params = { | ||
| page, | ||
| fields: "id,code,name,kind,modules_count,allowed_add_ons", | ||
| per_page: perPage, | ||
| access_token: accessToken | ||
| }; | ||
|
|
||
| if (hideArchived) filter.push("is_archived==0"); | ||
|
|
||
| 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_CUSTOMIZED_PAGES), | ||
| createAction(RECEIVE_SPONSOR_CUSTOMIZED_PAGES), | ||
| `${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/sponsor-pages`, | ||
| authErrorHandler, | ||
| { order, orderDir, page, perPage, term, hideArchived, summitTZ } | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2461,6 +2461,23 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "pages_tab": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "alert_info": "To add a Sponsor Specific Page for this show's sponsor, click Add Page button. Note: this Page will be visible only to this sponsor for this show. The General Pages can only be managed on the Show's Pages section.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "hide_archived": "Hide archived Pages", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "using_template": "Using Template", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "new_page": "New Page", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "pages": "pages", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "managed_pages": "Managed Pages", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sponsor_customized_pages": "Customized Sponsor Pages", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "code": "Code", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "name": "Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "add_ons": "Add-ons", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "info_mod": "Info Mod", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "upload_mod": "Upload Mod", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "download_mod": "Download Mod", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "archive": "Archive", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "unarchive": "Unarchive" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
2464
to
2480
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. Add a managed-pages label to match the new table header. The UI renders a managed pages header, but there’s no dedicated label here. Add a key (and update the component to use it) to avoid falling back to the raw i18n key. 📝 Suggested addition "pages_tab": {
"alert_info": "To add a Sponsor Specific Page for this show's sponsor, click Add Page button. Note: this Page will be visible only to this sponsor for this show. The General Pages can only be managed on the Show's Pages section.",
"hide_archived": "Hide archived Pages",
"using_template": "Using Template",
"new_page": "New Page",
"pages": "pages",
+ "managed_pages": "Managed Pages",
"sponsor_customized_pages": "Customized Sponsor Pages",
"code": "Code",
"name": "Name",
"add_ons": "Add-ons",
"info_mod": "Info Mod",
"upload_mod": "Upload Mod",
"download_mod": "Download Mod",
"archive": "Archive",
"unarchive": "Unarchive"
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cart_tab": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "new_form": "New Form", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "forms": "forms", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.