Skip to content
Open
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
1 change: 1 addition & 0 deletions dashboard/src/components/CreateDropdown/CreateDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const CreateDropdown = () => {
<EntityForm
open={entityModal}
onClose={() => setEntityModal(false)}
isAdd={true}
/>
)}
{classificationModal && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jest.mock('react-router-dom', () => ({

jest.mock('@views/Entity/EntityForm', () => ({
__esModule: true,
default: ({ open, onClose }: { open: boolean; onClose: () => void }) =>
default: ({ open, onClose, isAdd }: { open: boolean; onClose: () => void; isAdd?: boolean }) =>
open ? (
<div data-testid="entity-form">
<div data-testid="entity-form" data-isadd={isAdd ? 'true' : 'false'}>
<button type="button" onClick={onClose}>
Close entity
</button>
Expand Down Expand Up @@ -84,6 +84,7 @@ describe('CreateDropdown (header Create menu)', () => {

fireEvent.click(screen.getByText('Entity'))
expect(await screen.findByTestId('entity-form')).toBeInTheDocument()
expect(screen.getByTestId('entity-form')).toHaveAttribute('data-isadd', 'true')

fireEvent.click(screen.getByText('Close entity'))
await waitFor(() => {
Expand Down
7 changes: 5 additions & 2 deletions dashboard/src/views/Entity/EntityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ export function reducer(state: State, action: Action): State {

const EntityForm = ({
open,
onClose
onClose,
isAdd = false
}: {
open: boolean;
onClose: () => void;
isAdd?: boolean;
}) => {
const key = "atlas.ui.editable.entity.types";
const dispatchApi = useAppDispatch();
const navigate = useNavigate();
const { guid }: any = useParams();
const { guid: urlGuid }: any = useParams();
const guid = isAdd ? undefined : urlGuid;
const [_searchParams, setSearchParams] = useSearchParams();

const { entityData = {} }: any = useAppSelector((state: any) => state.entity);
Expand Down