-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new page/route for notebooks create and rename #152
Changes from 20 commits
015d929
8a7b4d1
5b388fc
ad615c3
6152d33
7682fc9
613496a
c9e610a
6dd53cd
28bc0bc
c4ceca5
6355fbe
fe62059
05f5a80
b47634b
7f89652
d45370a
70b6253
d6e8f87
da2769e
cc0763c
e9eabb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<NotebookType[]>([]); | ||
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.push('/notebooks') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch - I missed this as I was mainly testing it from the notebooks page itself, not the connection from other pages. Fixed with |
||
}, | ||
'Name', | ||
'Create notebook', | ||
'Cancel', | ||
|
@@ -306,7 +319,7 @@ export function NoteTable(props: NoteTableProps) { | |
</EuiPopover> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiButton fill onClick={() => createNote()}> | ||
<EuiButton fill href="#/notebooks/create"> | ||
Create notebook | ||
</EuiButton> | ||
</EuiFlexItem> | ||
|
@@ -367,10 +380,9 @@ export function NoteTable(props: NoteTableProps) { | |
<EuiSpacer size="m" /> | ||
<EuiFlexGroup justifyContent="center"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
<EuiButton fill href="#/notebooks/create" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's revert this fill as it was previously. Usually, a page should only have 1 primary fill button to implicitly tell the user that this is the main button to click on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see... Fixed in cc0763c |
||
data-test-subj="note-table-empty-state-create-notebook-button" | ||
fullWidth={false} | ||
onClick={() => createNote()} | ||
> | ||
Create notebook | ||
</EuiButton> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derek-ho FYI future code changes (don't address for this PR)
Array.at(-1) vs arr[arr.length - 1]
The usual practice is to access length and calculate the index from that — for example, array[array.length - 1]. The at() method allows relative indexing, so this can be shortened to array.at(-1).