Skip to content

Commit

Permalink
refactor: history modal (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Jun 20, 2022
1 parent 71463a9 commit affe724
Show file tree
Hide file tree
Showing 28 changed files with 771 additions and 637 deletions.
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "3.23.0-alpha.0",
"license": "AGPL-3.0-or-later",
"main": "dist/app.js",
"author": "Standard Notes",
"author": "Standard Notes.",
"private": true,
"files": [
"dist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ChallengeModal from '@/Components/ChallengeModal/ChallengeModal'
import NotesContextMenu from '@/Components/NotesContextMenu/NotesContextMenu'
import PurchaseFlowWrapper from '@/Components/PurchaseFlow/PurchaseFlowWrapper'
import { FunctionComponent, useCallback, useEffect, useMemo, useState } from 'react'
import RevisionHistoryModalWrapper from '@/Components/RevisionHistoryModal/RevisionHistoryModalWrapper'
import RevisionHistoryModal from '@/Components/RevisionHistoryModal/RevisionHistoryModal'
import PremiumModalProvider from '@/Hooks/usePremiumModal'
import ConfirmSignoutContainer from '@/Components/ConfirmSignoutModal/ConfirmSignoutModal'
import TagsContextMenuWrapper from '@/Components/Tags/TagContextMenu'
Expand Down Expand Up @@ -196,7 +196,13 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
<Footer application={application} applicationGroup={mainApplicationGroup} />
<SessionsModal application={application} viewControllerManager={viewControllerManager} />
<PreferencesViewWrapper viewControllerManager={viewControllerManager} application={application} />
<RevisionHistoryModalWrapper application={application} viewControllerManager={viewControllerManager} />
<RevisionHistoryModal
application={application}
historyModalController={viewControllerManager.historyModalController}
notesController={viewControllerManager.notesController}
selectionController={viewControllerManager.selectionController}
subscriptionController={viewControllerManager.subscriptionController}
/>
</>

{renderChallenges()}
Expand All @@ -207,6 +213,7 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
navigationController={viewControllerManager.navigationController}
notesController={viewControllerManager.notesController}
noteTagsController={viewControllerManager.noteTagsController}
historyModalController={viewControllerManager.historyModalController}
/>
<TagsContextMenuWrapper viewControllerManager={viewControllerManager} />
<FileContextMenuWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import UrlMissing from '@/Components/ComponentView/UrlMissing'
import IsDeprecated from '@/Components/ComponentView/IsDeprecated'
import IsExpired from '@/Components/ComponentView/IsExpired'
import IssueOnLoading from '@/Components/ComponentView/IssueOnLoading'
import { ViewControllerManager } from '@/Services/ViewControllerManager'
import { openSubscriptionDashboard } from '@/Utils/ManageSubscription'

interface IProps {
application: WebApplication
viewControllerManager: ViewControllerManager
componentViewer: ComponentViewer
requestReload?: (viewer: ComponentViewer, force?: boolean) => void
onLoad?: (component: SNComponent) => void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { NavigationController } from '@/Controllers/Navigation/NavigationControl
import { NotesController } from '@/Controllers/NotesController'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import { NoteTagsController } from '@/Controllers/NoteTagsController'
import { HistoryModalController } from '@/Controllers/NoteHistory/HistoryModalController'

type Props = {
application: WebApplication
Expand All @@ -23,6 +24,7 @@ type Props = {
notesController: NotesController
noteTagsController: NoteTagsController
selectionController: SelectedItemsController
historyModalController: HistoryModalController
}

const MultipleSelectedNotes = ({
Expand All @@ -34,6 +36,7 @@ const MultipleSelectedNotes = ({
notesController,
noteTagsController,
selectionController,
historyModalController,
}: Props) => {
const count = notesController.selectedNotesCount

Expand Down Expand Up @@ -65,6 +68,7 @@ const MultipleSelectedNotes = ({
navigationController={navigationController}
notesController={notesController}
noteTagsController={noteTagsController}
historyModalController={historyModalController}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class NoteGroupView extends PureComponent<Props, State> {
navigationController={this.viewControllerManager.navigationController}
notesController={this.viewControllerManager.notesController}
noteTagsController={this.viewControllerManager.noteTagsController}
historyModalController={this.viewControllerManager.historyModalController}
/>
)}

Expand Down
9 changes: 2 additions & 7 deletions packages/web/src/javascripts/Components/NoteView/NoteView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ class NoteView extends PureComponent<NoteViewProps, State> {
navigationController={this.viewControllerManager.navigationController}
notesController={this.viewControllerManager.notesController}
noteTagsController={this.viewControllerManager.noteTagsController}
historyModalController={this.viewControllerManager.historyModalController}
onClickPreprocessing={this.ensureNoteIsInsertedBeforeUIAction}
/>
</div>
Expand Down Expand Up @@ -1002,7 +1003,6 @@ class NoteView extends PureComponent<NoteViewProps, State> {
onLoad={this.onEditorComponentLoad}
requestReload={this.editorComponentViewerRequestsReload}
application={this.application}
viewControllerManager={this.viewControllerManager}
/>
</div>
)}
Expand Down Expand Up @@ -1073,12 +1073,7 @@ class NoteView extends PureComponent<NoteViewProps, State> {
{this.state.stackComponentViewers.map((viewer) => {
return (
<div className="component-view component-stack-item" key={viewer.identifier}>
<ComponentView
key={viewer.identifier}
componentViewer={viewer}
application={this.application}
viewControllerManager={this.viewControllerManager}
/>
<ComponentView key={viewer.identifier} componentViewer={viewer} application={this.application} />
</div>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ import { WebApplication } from '@/Application/Application'
import { NotesController } from '@/Controllers/NotesController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { NoteTagsController } from '@/Controllers/NoteTagsController'
import { HistoryModalController } from '@/Controllers/NoteHistory/HistoryModalController'

type Props = {
application: WebApplication
navigationController: NavigationController
notesController: NotesController
noteTagsController: NoteTagsController
historyModalController: HistoryModalController
}

const NotesContextMenu = ({ application, navigationController, notesController, noteTagsController }: Props) => {
const NotesContextMenu = ({
application,
navigationController,
notesController,
noteTagsController,
historyModalController,
}: Props) => {
const { contextMenuOpen, contextMenuPosition, contextMenuMaxHeight } = notesController

const contextMenuRef = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -49,6 +57,7 @@ const NotesContextMenu = ({ application, navigationController, notesController,
navigationController={navigationController}
notesController={notesController}
noteTagsController={noteTagsController}
historyModalController={historyModalController}
/>
</div>
) : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const NotesOptions = ({
navigationController,
notesController,
noteTagsController,
historyModalController,
closeOnBlur,
}: NotesOptionsProps) => {
const [altKeyDown, setAltKeyDown] = useState(false)
Expand Down Expand Up @@ -259,8 +260,8 @@ const NotesOptions = ({
}, [application, notes])

const openRevisionHistoryModal = useCallback(() => {
notesController.setShowRevisionHistoryModal(true)
}, [notesController])
historyModalController.openModal(notesController.firstSelectedNote)
}, [historyModalController, notesController.firstSelectedNote])

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { FOCUSABLE_BUT_NOT_TABBABLE } from '@/Constants/Constants'
import { NotesController } from '@/Controllers/NotesController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { NoteTagsController } from '@/Controllers/NoteTagsController'
import { HistoryModalController } from '@/Controllers/NoteHistory/HistoryModalController'

type Props = {
application: WebApplication
navigationController: NavigationController
notesController: NotesController
noteTagsController: NoteTagsController
historyModalController: HistoryModalController
onClickPreprocessing?: () => Promise<void>
}

Expand All @@ -24,6 +26,7 @@ const NotesOptionsPanel = ({
navigationController,
notesController,
noteTagsController,
historyModalController,
onClickPreprocessing,
}: Props) => {
const [open, setOpen] = useState(false)
Expand Down Expand Up @@ -95,6 +98,7 @@ const NotesOptionsPanel = ({
navigationController={navigationController}
notesController={notesController}
noteTagsController={noteTagsController}
historyModalController={historyModalController}
closeOnBlur={closeOnBlur}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WebApplication } from '@/Application/Application'
import { HistoryModalController } from '@/Controllers/NoteHistory/HistoryModalController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { NotesController } from '@/Controllers/NotesController'
import { NoteTagsController } from '@/Controllers/NoteTagsController'
Expand All @@ -8,5 +9,6 @@ export type NotesOptionsProps = {
navigationController: NavigationController
notesController: NotesController
noteTagsController: NoteTagsController
historyModalController: HistoryModalController
closeOnBlur: (event: { relatedTarget: EventTarget | null }) => void
}

0 comments on commit affe724

Please sign in to comment.