Skip to content

Commit

Permalink
Merge pull request #1049 from Tarunmeena0901/BB-758
Browse files Browse the repository at this point in the history
fix BB-758 : Link from edit page to entity page
  • Loading branch information
MonkeyDo authored Feb 1, 2024
2 parents e2cb1e0 + 30fc6ae commit ec7ea51
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/client/entity-editor/entity-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import NameSection from './name-section/name-section';
import RelationshipSection from './relationship-editor/relationship-section';
import SubmissionSection from './submission-section/submission-section';
import _ from 'lodash';
import {getEntityUrl} from '../helpers/entity';
import {submit} from './submission-section/actions';


type OwnProps = {
children: React.ReactElement<any>,
heading: string,
intitialState:Record<string, any>,
entity: any
};

type StateProps = {
Expand Down Expand Up @@ -67,9 +69,11 @@ const EntityEditor = (props: Props) => {
children,
heading,
identifierEditorVisible,
onSubmit
onSubmit,
entity
} = props;
const currentState = (useSelector((state) => state) as any).toJS();
let entityURL;
// eslint-disable-next-line consistent-return
const handleUrlChange = React.useCallback(() => {
if (!_.isEqual(currentState, props.intitialState) && !currentState.submissionSection.submitted) {
Expand All @@ -80,11 +84,17 @@ const EntityEditor = (props: Props) => {
window.onbeforeunload = handleUrlChange;
}, [handleUrlChange]);

if(entity){
entityURL = getEntityUrl(entity);
}

return (
<form onSubmit={onSubmit}>
<Card>
<Card.Header as="h4">
{heading}
<div>
{entityURL ? <a href={entityURL}>{heading}</a> : heading}
</div>
</Card.Header>
<Card.Body>
<AliasEditor show={aliasEditorVisible} {...props}/>
Expand Down

0 comments on commit ec7ea51

Please sign in to comment.