Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/actions/show-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ export const getShowPages =
page,
per_page: perPage,
access_token: accessToken,
fields:
"code,name,id,modules_count,sponsorship_types,is_archived,apply_to_all_types",
expand: "sponsorship_types"
fields: "code,name,id,modules_count,is_archived,apply_to_all_types",
expand: "sponsorship_types,modules"
};

if (hideArchived) filter.push("is_archived==0");
Expand Down Expand Up @@ -114,7 +113,7 @@ export const getShowPage = (pageId) => async (dispatch, getState) => {

const params = {
access_token: accessToken,
expand: "modules"
expand: "modules,sponsorship_types"
};

return getRequest(
Expand Down
186 changes: 93 additions & 93 deletions src/actions/sponsor-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,53 +111,53 @@ export const getSponsorManagedPages =
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,assigned_type",
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`,
snackbarErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
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,assigned_type",
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`,
snackbarErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
};

export const saveSponsorManagedPage =
(entity) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
Expand Down Expand Up @@ -256,55 +256,55 @@ export const getSponsorCustomizedPages =
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,allowed_add_ons,is_archived,modules,allowed_add_ons.type,allowed_add_ons.name,allowed_add_ons.id",
expand: "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`,
snackbarErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
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,allowed_add_ons,is_archived,modules,allowed_add_ons.type,allowed_add_ons.name,allowed_add_ons.id",
expand: "allowed_add_ons,modules",
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`,
snackbarErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
};

export const getSponsorCustomizedPage =
(pageId) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
Expand All @@ -319,7 +319,7 @@ export const getSponsorCustomizedPage =
const params = {
fields:
"id,code,name,allowed_add_ons,is_archived,modules,allowed_add_ons.name,allowed_add_ons.id",
expand: "allowed_add_ons",
expand: "allowed_add_ons,modules",
access_token: accessToken
};

Expand Down
4 changes: 2 additions & 2 deletions src/reducers/sponsors/show-pages-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const showPagesListReducer = (state = DEFAULT_STATE, action) => {

const sponsorshipTypeIds = pageData.apply_to_all_types
? ["all"]
: [...pageData.sponsorship_types];
: pageData.sponsorship_types.map((st) => st.id);

const currentShowPage = {
...pageData,
Expand All @@ -148,7 +148,7 @@ const showPagesListReducer = (state = DEFAULT_STATE, action) => {
sponsorship_types: sponsorshipTypeIds
};

return { ...state, currentShowPage };
return { ...state, currentShowPage };
}
case SHOW_PAGE_DELETED: {
const { pageId } = payload;
Expand Down
39 changes: 37 additions & 2 deletions src/reducers/sponsors/sponsor-page-pages-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* */

import { LOGOUT_USER } from "openstack-uicore-foundation/lib/security/actions";
import { epochToMomentTimeZone } from "openstack-uicore-foundation/lib/utils/methods";
import {
REQUEST_SPONSOR_MANAGED_PAGES,
RECEIVE_SPONSOR_MANAGED_PAGES,
Expand All @@ -24,7 +25,10 @@ import {
} from "../../actions/sponsor-pages-actions";
import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";
import { RECEIVE_GLOBAL_SPONSORSHIPS } from "../../actions/sponsor-forms-actions";
import { PAGES_MODULE_KINDS } from "../../utils/constants";
import {
PAGE_MODULES_DOWNLOAD,
PAGES_MODULE_KINDS
} from "../../utils/constants";

const DEFAULT_PAGE = {
code: "",
Expand Down Expand Up @@ -174,7 +178,38 @@ const sponsorPagePagesListReducer = (state = DEFAULT_STATE, action) => {
}
case RECEIVE_SPONSOR_CUSTOMIZED_PAGE: {
const customizedPage = payload.response;
return { ...state, currentEditPage: customizedPage };

const modules = customizedPage.modules.map((module) => {
const tmpModule = {
...module,
...(module.upload_deadline
? {
upload_deadline: epochToMomentTimeZone(
module.upload_deadline,
state.summitTZ || "UTC"
)
}
: {})
};

if (module.kind === PAGES_MODULE_KINDS.DOCUMENT) {
if (module.file) {
tmpModule.file = [
{
...module.file,
file_path: module.file.storage_key,
public_url: module.file.file_url
}
];
tmpModule.type = PAGE_MODULES_DOWNLOAD.FILE;
} else {
tmpModule.type = PAGE_MODULES_DOWNLOAD.URL;
}
}
return tmpModule;
});

return { ...state, currentEditPage: { ...customizedPage, modules } };
}
case SPONSOR_CUSTOMIZED_PAGE_ARCHIVED: {
const { pageId } = payload;
Expand Down
Loading