Skip to content
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

access request: update guest request payload #343

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
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export class InvenioRequestsApp extends Component {
}

render() {
const { overriddenCmps, userAvatar } = this.props;
const { overriddenCmps, userAvatar, permissions } = this.props;

return (
<OverridableContext.Provider value={overriddenCmps}>
<Provider store={this.store}>
<Request userAvatar={userAvatar} />
<Request userAvatar={userAvatar} permissions={permissions}/>
</Provider>
</OverridableContext.Provider>
);
Expand All @@ -57,6 +57,7 @@ InvenioRequestsApp.propTypes = {
request: PropTypes.object.isRequired,
userAvatar: PropTypes.string.isRequired,
defaultQueryParams: PropTypes.object,
permissions: PropTypes.object.isRequired,
};

InvenioRequestsApp.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Request extends Component {
}

render() {
const { request, updateRequestAfterAction, userAvatar } = this.props;
const { request, updateRequestAfterAction, userAvatar, permissions } = this.props;

return (
<Overridable id="InvenioRequest.Request.layout">
Expand All @@ -28,7 +28,7 @@ export class Request extends Component {
request={request}
actionSuccessCallback={updateRequestAfterAction}
/>
<RequestDetails request={request} userAvatar={userAvatar} />
<RequestDetails request={request} userAvatar={userAvatar} permissions={permissions}/>
</Loader>
</Overridable>
);
Expand All @@ -40,6 +40,7 @@ Request.propTypes = {
initRequest: PropTypes.func.isRequired,
updateRequestAfterAction: PropTypes.func.isRequired,
userAvatar: PropTypes.string,
permissions: PropTypes.object.isRequired,
};

Request.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { Timeline } from "../timeline";

class RequestDetails extends Component {
render() {
const { request, userAvatar } = this.props;
const { request, userAvatar, permissions } = this.props;
return (
<Overridable id="InvenioRequests.RequestDetails.layout" {...this.props}>
<>
<Grid stackable reversed="mobile">
<Grid.Column mobile={16} tablet={12} computer={13}>
<Timeline userAvatar={userAvatar} />
<Timeline userAvatar={userAvatar} request={request} permissions={permissions}/>
</Grid.Column>
<Grid.Column mobile={16} tablet={4} computer={3}>
<RequestMetadata request={request} />
Expand All @@ -34,6 +34,7 @@ class RequestDetails extends Component {
RequestDetails.propTypes = {
request: PropTypes.object.isRequired,
userAvatar: PropTypes.string,
permissions: PropTypes.object.isRequired,
};

RequestDetails.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ import {
import { i18next } from "@translations/invenio_requests/i18next";
import React from "react";
import ReactDOM from "react-dom";
import { overrideStore } from "react-overridable";
import { InvenioRequestsApp } from "./InvenioRequestsApp";
import {
RequestAcceptButton,
RequestCancelButton,
RequestDeclineButton,
} from "./components/Buttons";
import { InvenioRequestsApp } from "./InvenioRequestsApp";
import {
LabelTypeCommunityInclusion,
LabelTypeCommunityInvitation,
LabelTypeCommunitySubmission,
LabelTypeGuestAccess,
LabelTypeUserAccess,
} from "./contrib";
import {
AcceptStatus,
CancelStatus,
Expand All @@ -34,20 +42,14 @@ import {
TimelineExpireEvent,
TimelineUnknownEvent,
} from "./timelineEvents";
import {
LabelTypeCommunityInclusion,
LabelTypeCommunityInvitation,
LabelTypeCommunitySubmission,
LabelTypeGuestAccess,
LabelTypeUserAccess,
} from "./contrib";

const requestDetailsDiv = document.getElementById("request-detail");
const request = JSON.parse(requestDetailsDiv.dataset.record);
const defaultQueryParams = JSON.parse(requestDetailsDiv.dataset.defaultQueryConfig);
const userAvatar = JSON.parse(requestDetailsDiv.dataset.userAvatar);
const permissions = JSON.parse(requestDetailsDiv.dataset.permissions);

const overriddenComponents = {
const defaultComponents = {
"TimelineEvent.layout.unknown": TimelineUnknownEvent,
"TimelineEvent.layout.declined": TimelineDeclineEvent,
"TimelineEvent.layout.accepted": TimelineAcceptEvent,
Expand Down Expand Up @@ -76,12 +78,15 @@ const overriddenComponents = {
"RequestActionModal.title.decline": () => i18next.t("Decline request"),
};

const overriddenComponents = overrideStore.getAll();

ReactDOM.render(
<InvenioRequestsApp
request={request}
defaultQueryParams={defaultQueryParams}
overriddenCmps={overriddenComponents}
overriddenCmps={{ ...defaultComponents, ...overriddenComponents }}
userAvatar={userAvatar}
permissions={permissions}
/>,
requestDetailsDiv
);
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class TimelineFeed extends Component {
};

render() {
const { timeline, loading, error, setPage, size, page, userAvatar } = this.props;
const { timeline, loading, error, setPage, size, page, userAvatar, request, permissions } = this.props;
const { modalOpen, modalAction } = this.state;

return (
<Loader isLoading={loading}>
<Error error={error}>
<Overridable id="TimelineFeed.layout" {...this.props}>
<Container id="requests-timeline" className="ml-0-mobile mr-0-mobile">
<Overridable id="TimelineFeed.header" request={request} permissions={permissions}/>
<RequestsFeed>
{timeline.hits?.hits.map((event) => (
<TimelineCommentEventControlled
Expand Down Expand Up @@ -92,6 +93,8 @@ TimelineFeed.propTypes = {
page: PropTypes.number,
size: PropTypes.number,
userAvatar: PropTypes.string,
request: PropTypes.object.isRequired,
permissions: PropTypes.object.isRequired,
};

TimelineFeed.defaultProps = {
Expand Down
2 changes: 2 additions & 0 deletions invenio_requests/services/requests/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def update(self, identity, data=None, record=None, **kwargs):
if record.status == "created":
keys = ("title", "description", "payload", "receiver", "topic")
else:
# TODO: add possibility to update payload (https://github.com/inveniosoftware/invenio-rdm-records/issues/1402)
# keys = ("title", "description", "payload")
keys = ("title", "description")

for k in keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h2 class="ui header">
data-record='{{ invenio_request | tojson }}'
data-default-query-config='{{ dict(size=config["REQUESTS_TIMELINE_PAGE_SIZE"]) | tojson }}'
data-user-avatar='{{ user_avatar | tojson }}'
data-permissions='{{ permissions | tojson }}'
>{# react app root #}
<div class="ui grid">
<div class="stretched row">
Expand Down
Loading