Skip to content

Commit

Permalink
move commanders components under feature folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Sep 6, 2024
1 parent a68bd81 commit b405a03
Show file tree
Hide file tree
Showing 24 changed files with 9 additions and 101 deletions.
2 changes: 1 addition & 1 deletion ui2/src/components/SinglePanel/SinglePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
selectSearchResults
} from "@/slices/dualPanel/dualPanel"
import {useSelector} from "react-redux"
import Commander from "@/components/Commander"
import Commander from "@/features/nodes/components/Commander"
import Viewer from "@/components/Viewer"
import SearchResults from "@/components/SearchResults"
import PanelContext from "@/contexts/PanelContext"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {Group, Stack, Box} from "@mantine/core"
import {useAppSelector, useAppDispatch} from "@/app/hooks"
import {useNavigate} from "react-router-dom"

import FolderNodeActions from "@/components/Commander/FolderNodeActions"
import Node from "@/components/Node"
import FolderNodeActions from "@/features/nodes/components/FolderNodeActions"
import Node from "@/features/nodes/components/Node"
import {
setCurrentNode,
selectLastPageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {updateActionPanel} from "@/slices/sizes"
import type {RootState} from "@/app/types"
import type {PanelMode} from "@/types"
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel"
import DeleteButton from "@/components/Commander/DeleteButton"
import NewFolderButton from "@/components/Commander/NewFolderButton"
import UploadButton from "@/components/Commander/UploadButton"
import DeleteButton from "@/features/nodes/components/DeleteButton"
import NewFolderButton from "@/features/nodes/components/NewFolderButton"
import UploadButton from "@/features/nodes/components/UploadButton"

import PanelContext from "@/contexts/PanelContext"
import EditNodeTagsButton from "@/components/SinglePanel/EditNodeTagsButton"
import EditNodeTitleButton from "@/components/SinglePanel/EditNodeTitleButton"
import QuickFilter from "@/components/Commander/QuickFilter"
import QuickFilter from "@/features/nodes/components/QuickFilter"

export default function FolderNodeActions() {
const {height, width} = useViewportSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
selectionRemoveNode
} from "@/slices/dualPanel/dualPanel"

import Tags from "@/components/Node/Tags"
import Tags from "@/features/nodes/components/Node/Tags"
import type {NodeType, PanelMode} from "@/types"
import classes from "./Document.module.scss"
import {RootState} from "@/app/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
selectionRemoveNode
} from "@/slices/dualPanel/dualPanel"

import Tags from "@/components/Node/Tags"
import Tags from "@/features/nodes/components/Node/Tags"
import classes from "./Folder.module.scss"
import {RootState} from "@/app/types"
import type {NodeType, PanelMode} from "@/types"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions ui2/src/slices/currentUser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {createSlice, createAsyncThunk, PayloadAction} from "@reduxjs/toolkit"
import axios from "@/httpClient"
import type {SliceState, SliceStateStatus, User, UserDetails} from "@/types"
import {store} from "@/app/store"
import {storeHomeNode, storeInboxNode} from "./dualPanel/dualPanel"

const initialState: SliceState<User> = {
data: null,
Expand All @@ -15,19 +13,6 @@ export const fetchCurrentUser = createAsyncThunk(
async () => {
const response = await axios.get("/api/users/me")
const userDetails = response.data as UserDetails
store.dispatch(
storeHomeNode({
folder_id: userDetails.home_folder_id,
user_id: userDetails.id
})
)
store.dispatch(
storeInboxNode({
folder_id: userDetails.home_folder_id,
user_id: userDetails.id
})
)

return userDetails
}
)
Expand Down
59 changes: 0 additions & 59 deletions ui2/src/slices/dualPanel/dualPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
commanderInitialState,
setCurrentNodeHelper,
nodeAddedHelper,
nodeUpdatedHelper,
dropThumbnailPageHelper,
resetPageChangesHelper,
getLatestVersionPages
Expand Down Expand Up @@ -55,7 +54,6 @@ import {
DualPanelState,
SetCurrentNodeArgs,
FolderAddedArgs,
NodeUpdatedArgs,
NodeWithSpinner,
SelectionNodePayload,
SelectionPagePayload
Expand Down Expand Up @@ -229,10 +227,6 @@ export const deleteNodes = createAsyncThunk<string[], string[]>(
return nodeIds
}
)
type StoreNodeInput = {
folder_id: string
user_id: string
}

type SetCurrentPageArg = {
mode: PanelMode
Expand Down Expand Up @@ -381,42 +375,6 @@ const dualPanelSlice = createSlice({
}
}
},
storeHomeNode(state, action: PayloadAction<StoreNodeInput>) {
const node: NodeType = {
id: action.payload.folder_id,
ctype: "folder",
title: ".home",
breadcrumb: [],
tags: [],
user_id: action.payload.user_id,
update_at: "",
ocr_status: "UNKNOWN",
ocr: false,
parent_id: null,
thumbnail_url: null,
accept_dropped_nodes: false,
is_currently_dragged: false
}
state.nodes.push(node)
},
storeInboxNode(state, action: PayloadAction<StoreNodeInput>) {
const node: NodeType = {
id: action.payload.folder_id,
ctype: "folder",
title: ".inbox",
breadcrumb: [],
tags: [],
user_id: action.payload.user_id,
update_at: "",
ocr_status: "UNKNOWN",
ocr: false,
parent_id: null,
thumbnail_url: null,
accept_dropped_nodes: false,
is_currently_dragged: false
}
state.nodes.push(node)
},
nodeAdded(state, action: PayloadAction<FolderAddedArgs>) {
nodeAddedHelper({
state,
Expand All @@ -431,19 +389,6 @@ const dualPanelSlice = createSlice({
mode: action.payload.panel
})
},
folderAdded(state, action: PayloadAction<FolderAddedArgs>) {
nodeAddedHelper({
state,
node: action.payload.node,
mode: action.payload.mode
})
},
nodeUpdated(state, action: PayloadAction<NodeUpdatedArgs>) {
nodeUpdatedHelper({
state,
node: action.payload.node
})
},
openSecondaryPanel(state, action: PayloadAction<CurrentNodeType>) {
state.secondaryPanel = {
commander: commanderInitialState(action.payload),
Expand Down Expand Up @@ -692,8 +637,6 @@ export const {
fitZoomFactor,
toggleThumbnailsPanel,
setCurrentNode,
folderAdded,
nodeUpdated,
openSecondaryPanel,
closeSecondaryPanel,
selectionAddNode,
Expand All @@ -702,8 +645,6 @@ export const {
selectionRemovePage,
clearNodesSelection,
updateSearchResultItemTarget,
storeHomeNode,
storeInboxNode,
nodeAdded,
setCurrentPage,
dropThumbnailPage,
Expand Down
16 changes: 0 additions & 16 deletions ui2/src/slices/dualPanel/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,6 @@ export function setCurrentNodeHelper({
}
}
}
export function nodeUpdatedHelper({
state,
node
}: {
state: DualPanelState
node: NodeType
}) {
const newNodes = state.nodes.map(n => {
if (n.id != node.id) {
return n
}
return node
})

state.nodes = newNodes
}

export function nodeAddedHelper({
state,
Expand Down
2 changes: 0 additions & 2 deletions ui2/src/slices/dualPanel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export type FolderAddedArgs = {
mode: PanelMode
}

export type NodeUpdatedArgs = FolderAddedArgs

export type SelectionNodePayload = {
selectionId: string
mode: PanelMode
Expand Down

0 comments on commit b405a03

Please sign in to comment.