-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Commit Authors & Refactored Code
- Loading branch information
1 parent
425238b
commit 71bb057
Showing
25 changed files
with
241 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { HttpCommunication } from '@services/communication/http/httpCommunication'; | ||
import { Commit } from '@notespace/shared/src/document/types/commits'; | ||
|
||
function commitsService(http: HttpCommunication, wid: string, id: string) { | ||
async function commit() { | ||
return await http.post(`/workspaces/${wid}/${id}/commit`); | ||
} | ||
|
||
async function getCommits(): Promise<Commit[]> { | ||
return await http.get(`/workspaces/${wid}/${id}/commits`); | ||
} | ||
|
||
async function rollback(commitId: string) { | ||
return await http.post(`/workspaces/${wid}/${id}/rollback`, { commitId }); | ||
} | ||
|
||
async function fork(commitId: string) { | ||
return await http.post(`/workspaces/${wid}/${id}/fork`, { commitId }); | ||
} | ||
|
||
return { | ||
commit, | ||
getCommits, | ||
rollback, | ||
fork, | ||
}; | ||
} | ||
|
||
export default commitsService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useMemo } from 'react'; | ||
import { useCommunication } from '@/contexts/communication/useCommunication'; | ||
import { useParams } from 'react-router-dom'; | ||
import commitsService from '@services/commits/commitsService'; | ||
|
||
function useCommitsService() { | ||
const { http } = useCommunication(); | ||
const { wid, id } = useParams(); | ||
if (!wid || !id) throw new Error('Cannot use commits service outside of a document'); | ||
return useMemo(() => commitsService(http, wid, id), [http, wid, id]); | ||
} | ||
|
||
export default useCommitsService; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
code/client/src/ui/pages/document/components/floating-buttons/FloatingButtons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import './FloatingButtons.scss'; | ||
import CommitDialog from '@ui/pages/document/components/floating-buttons/CommitDialog'; | ||
import useCommitsService from '@services/commits/useCommitsService'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { MdHistory } from 'react-icons/md'; | ||
|
||
function FloatingButtons() { | ||
const { wid, id } = useParams(); | ||
const { commit } = useCommitsService(); | ||
const navigate = useNavigate(); | ||
return ( | ||
<div className="floating-buttons"> | ||
<CommitDialog onCommit={commit} /> | ||
<button onClick={() => navigate(`/workspaces/${wid}/${id}/commits`)}> | ||
<MdHistory /> | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default FloatingButtons; |
21 changes: 0 additions & 21 deletions
21
code/client/src/ui/pages/document/components/version/Version.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { setup } from '@tests/test-utils'; | ||
import { mockCommunication } from '../../mocks/mockCommunication'; | ||
import SlateEditor from '@ui/pages/document/components/editor/Editor'; | ||
import { Fugue } from '@domain/editor/fugue/Fugue'; | ||
|
||
/** | ||
* Sets up the editor for testing | ||
* @returns user and the slate editor | ||
*/ | ||
const setupEditor = async () => { | ||
const fugue = new Fugue(); | ||
const { user, render } = setup(<SlateEditor fugue={fugue} communication={mockCommunication()} />); | ||
const { findByTestId } = render; | ||
const editorElement = await findByTestId('editor'); // calls 'act' under the hood, but is more readable | ||
editorElement.focus(); | ||
return { user, editorElement }; | ||
}; | ||
|
||
/** | ||
* Cleans up the editor after testing | ||
*/ | ||
const cleanupEditor = async () => { | ||
const editor = document.querySelector('[data-testid="editable"]'); | ||
if (editor) editor.innerHTML = ''; | ||
}; | ||
|
||
export { setupEditor, cleanupEditor }; | ||
// import { setup } from '@tests/test-utils'; | ||
// import { mockCommunication } from '../../mocks/mockCommunication'; | ||
// import Editor from '@ui/pages/document/components/editor/Editor'; | ||
// import { Fugue } from '@domain/editor/fugue/Fugue'; | ||
// | ||
// /** | ||
// * Sets up the editor for testing | ||
// * @returns user and the slate editor | ||
// */ | ||
// const setupEditor = async () => { | ||
// const fugue = new Fugue(); | ||
// const { user, render } = setup(<Editor fugue={fugue} communication={mockCommunication()} />); | ||
// const { findByTestId } = render; | ||
// const editorElement = await findByTestId('editor'); // calls 'act' under the hood, but is more readable | ||
// editorElement.focus(); | ||
// return { user, editorElement }; | ||
// }; | ||
// | ||
// /** | ||
// * Cleans up the editor after testing | ||
// */ | ||
// const cleanupEditor = async () => { | ||
// const editor = document.querySelector('[data-testid="editable"]'); | ||
// if (editor) editor.innerHTML = ''; | ||
// }; | ||
// | ||
// export { setupEditor, cleanupEditor }; |
Oops, something went wrong.