Skip to content
Snippets Groups Projects
Unverified Commit 55c483e1 authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Fix permission error when opening revision history (#20421)

parent 9f8f810c
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ const EntityLink = ({ ...@@ -8,6 +8,8 @@ const EntityLink = ({
entityId, entityId,
name = "name", name = "name",
LinkComponent = Link, LinkComponent = Link,
dispatchApiErrorEvent = true,
fallback = null,
...linkProps ...linkProps
}) => ( }) => (
<EntityObjectLoader <EntityObjectLoader
...@@ -15,6 +17,7 @@ const EntityLink = ({ ...@@ -15,6 +17,7 @@ const EntityLink = ({
entityId={entityId} entityId={entityId}
properties={[name]} properties={[name]}
loadingAndErrorWrapper={false} loadingAndErrorWrapper={false}
dispatchApiErrorEvent={dispatchApiErrorEvent}
wrapped wrapped
> >
{({ object }) => {({ object }) =>
...@@ -22,7 +25,9 @@ const EntityLink = ({ ...@@ -22,7 +25,9 @@ const EntityLink = ({
<LinkComponent {...linkProps} to={object.getUrl()}> <LinkComponent {...linkProps} to={object.getUrl()}>
<span>{object.getName()}</span> <span>{object.getName()}</span>
</LinkComponent> </LinkComponent>
) : null ) : (
fallback
)
} }
</EntityObjectLoader> </EntityObjectLoader>
); );
......
...@@ -42,6 +42,7 @@ export default class EntityObjectLoader extends React.Component { ...@@ -42,6 +42,7 @@ export default class EntityObjectLoader extends React.Component {
loadingAndErrorWrapper: true, loadingAndErrorWrapper: true,
reload: false, reload: false,
wrapped: false, wrapped: false,
dispatchApiErrorEvent: true,
}; };
_getWrappedObject; _getWrappedObject;
...@@ -61,11 +62,15 @@ export default class EntityObjectLoader extends React.Component { ...@@ -61,11 +62,15 @@ export default class EntityObjectLoader extends React.Component {
} }
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
const { entityId, fetch } = this.props; const { entityId, fetch, dispatchApiErrorEvent } = this.props;
if (entityId != null) { if (entityId != null) {
fetch( fetch(
{ id: entityId }, { id: entityId },
{ reload: this.props.reload, properties: this.props.properties }, {
reload: this.props.reload,
properties: this.props.properties,
noEvent: !dispatchApiErrorEvent,
},
); );
} }
} }
...@@ -121,7 +126,11 @@ export default class EntityObjectLoader extends React.Component { ...@@ -121,7 +126,11 @@ export default class EntityObjectLoader extends React.Component {
reload = () => { reload = () => {
return this.props.fetch( return this.props.fetch(
{ id: this.props.entityId }, { id: this.props.entityId },
{ reload: true, properties: this.props.properties }, {
reload: true,
properties: this.props.properties,
noEvent: !this.props.dispatchApiErrorEvent,
},
); );
}; };
......
...@@ -16,6 +16,10 @@ export const EntityLink = styled(RawEntityLink)` ...@@ -16,6 +16,10 @@ export const EntityLink = styled(RawEntityLink)`
} }
`; `;
EntityLink.defaultProps = {
dispatchApiErrorEvent: false,
};
const revisionTitlePropTypes = { const revisionTitlePropTypes = {
username: PropTypes.string.isRequired, username: PropTypes.string.isRequired,
message: PropTypes.node.isRequired, message: PropTypes.node.isRequired,
......
...@@ -71,6 +71,7 @@ export function getCollectionChangeDescription(prevCollectionId, collectionId) { ...@@ -71,6 +71,7 @@ export function getCollectionChangeDescription(prevCollectionId, collectionId) {
key={key} key={key}
entityId={collectionId || "root"} entityId={collectionId || "root"}
entityType="collections" entityType="collections"
fallback={t`Unknown`}
/> />
)}`, )}`,
]; ];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment