diff --git a/public/components/notebooks/components/__tests__/__snapshots__/note_table.test.tsx.snap b/public/components/notebooks/components/__tests__/__snapshots__/note_table.test.tsx.snap
index e4bd2c8fa..4d3fbeeb0 100644
--- a/public/components/notebooks/components/__tests__/__snapshots__/note_table.test.tsx.snap
+++ b/public/components/notebooks/components/__tests__/__snapshots__/note_table.test.tsx.snap
@@ -132,9 +132,10 @@ exports[` spec renders the component 1`] = `
-
+
@@ -1022,9 +1023,10 @@ exports[` spec renders the empty component 1`] = `
-
+
@@ -1080,10 +1082,11 @@ exports[` spec renders the empty component 1`] = `
-
+
({
+ useLocation: jest.fn().mockReturnValue({
+ pathname: '/notebooks',
+ search: '',
+ hash: '',
+ state: null,
+ key: '',
+ }),
+ useHistory: jest.fn()
+}));
+
describe(' spec', () => {
configure({ adapter: new Adapter() });
@@ -81,4 +92,40 @@ describe(' spec', () => {
utils.getByText('Actions').click();
utils.getByText('Rename').click();
});
-});
+
+ it('create notebook', async () => {
+ const fetchNotebooks = jest.fn();
+ const addSampleNotebooks = jest.fn();
+ const createNotebook = jest.fn();
+ const renameNotebook = jest.fn();
+ const cloneNotebook = jest.fn();
+ const deleteNotebook = jest.fn();
+ const setBreadcrumbs = jest.fn();
+ const setToast = jest.fn();
+ const notebooks = Array.from({ length: 5 }, (v, k) => ({
+ path: `path-${k}`,
+ id: `id-${k}`,
+ dateCreated: 'date-created',
+ dateModified: 'date-modified',
+ }));
+ const utils = render(
+
+ );
+ utils.getByText('Create notebook').click();
+ await waitFor(() => {
+ expect(global.window.location.href).toContain('/create')
+ });
+ });
+});
\ No newline at end of file
diff --git a/public/components/notebooks/components/main.tsx b/public/components/notebooks/components/main.tsx
index 9ba18c8e7..36d81a96b 100644
--- a/public/components/notebooks/components/main.tsx
+++ b/public/components/notebooks/components/main.tsx
@@ -308,26 +308,8 @@ export class Main extends React.Component {
/>
(
-
- )}
- />
- (
{
)}
/>
+ (
+
+ )}
+ />
>
diff --git a/public/components/notebooks/components/note_table.tsx b/public/components/notebooks/components/note_table.tsx
index d7ba77625..3c5da6df8 100644
--- a/public/components/notebooks/components/note_table.tsx
+++ b/public/components/notebooks/components/note_table.tsx
@@ -43,6 +43,7 @@ import {
} from './helpers/modal_containers';
import { NotebookType } from './main';
import { pageStyles } from '../../../../common/constants/shared';
+import { useHistory, useLocation } from 'react-router-dom';
interface NoteTableProps {
loading: boolean;
@@ -64,6 +65,8 @@ export function NoteTable(props: NoteTableProps) {
const [isActionsPopoverOpen, setIsActionsPopoverOpen] = useState(false);
const [selectedNotebooks, setSelectedNotebooks] = useState([]);
const [searchQuery, setSearchQuery] = useState('');
+ const location = useLocation();
+ const history = useHistory();
const { notebooks, createNotebook, renameNotebook, cloneNotebook, deleteNotebook } = props;
useEffect(() => {
@@ -77,6 +80,13 @@ export function NoteTable(props: NoteTableProps) {
props.fetchNotebooks();
}, []);
+ useEffect(() => {
+ const url = window.location.hash.split('/')
+ if (url[url.length-1] === 'create') {
+ createNote();
+ }
+ }, [location]);
+
const closeModal = () => {
setIsModalVisible(false);
};
@@ -114,7 +124,10 @@ export function NoteTable(props: NoteTableProps) {
setModalLayout(
getCustomModal(
onCreate,
- closeModal,
+ () => {
+ closeModal()
+ history.goBack();
+ },
'Name',
'Create notebook',
'Cancel',
@@ -306,7 +319,7 @@ export function NoteTable(props: NoteTableProps) {
- createNote()}>
+
Create notebook
@@ -367,10 +380,9 @@ export function NoteTable(props: NoteTableProps) {
- createNote()}
>
Create notebook