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 = ({
entityId,
name = "name",
LinkComponent = Link,
dispatchApiErrorEvent = true,
fallback = null,
...linkProps
}) => (
<EntityObjectLoader
......@@ -15,6 +17,7 @@ const EntityLink = ({
entityId={entityId}
properties={[name]}
loadingAndErrorWrapper={false}
dispatchApiErrorEvent={dispatchApiErrorEvent}
wrapped
>
{({ object }) =>
......@@ -22,7 +25,9 @@ const EntityLink = ({
<LinkComponent {...linkProps} to={object.getUrl()}>
<span>{object.getName()}</span>
</LinkComponent>
) : null
) : (
fallback
)
}
</EntityObjectLoader>
);
......
......@@ -42,6 +42,7 @@ export default class EntityObjectLoader extends React.Component {
loadingAndErrorWrapper: true,
reload: false,
wrapped: false,
dispatchApiErrorEvent: true,
};
_getWrappedObject;
......@@ -61,11 +62,15 @@ export default class EntityObjectLoader extends React.Component {
}
UNSAFE_componentWillMount() {
const { entityId, fetch } = this.props;
const { entityId, fetch, dispatchApiErrorEvent } = this.props;
if (entityId != null) {
fetch(
{ 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 {
reload = () => {
return this.props.fetch(
{ 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)`
}
`;
EntityLink.defaultProps = {
dispatchApiErrorEvent: false,
};
const revisionTitlePropTypes = {
username: PropTypes.string.isRequired,
message: PropTypes.node.isRequired,
......
......@@ -71,6 +71,7 @@ export function getCollectionChangeDescription(prevCollectionId, collectionId) {
key={key}
entityId={collectionId || "root"}
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