Skip to content
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

Refactoring uploader 1 #452

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui2/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
selectCurrentUserStatus,
selectCurrentUser
} from "@/slices/currentUser"
import {updateOutlet} from "@/slices/sizes"
import {updateOutlet} from "@/features/ui/uiSlice"

import "./App.css"
import {selectNavBarWidth} from "@/slices/navBar"
import {selectNavBarWidth} from "@/features/ui/uiSlice"
import Uploader from "@/components/Uploader"

function App() {
Expand Down
6 changes: 2 additions & 4 deletions ui2/src/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@ import {apiSlice} from "@/features/api/slice"
import authSliceReducer from "@/features/auth/slice"
import currentUserReducer from "@/slices/currentUser"
import dualPanelReducer from "@/slices/dualPanel/dualPanel"
import navBarReducer from "@/slices/navBar"
import tagsReducer from "@/features/tags/tagsSlice"
import groupsReducer from "@/features/groups/groupsSlice"
import usersReducer from "@/features/users/usersSlice"
import nodesReducer from "@/features/nodes/nodesSlice"
import uiReducer from "@/features/ui/uiSlice"
import {uploaderReducer} from "@/slices/uploader"
import sizesSliceReducer from "@/slices/sizes"
import dragndropReducer from "@/slices/dragndrop"

export const store = configureStore({
reducer: {
auth: authSliceReducer,
currentUser: currentUserReducer,
dualPanel: dualPanelReducer,
navBar: navBarReducer,
tags: tagsReducer,
groups: groupsReducer,
users: usersReducer,
uploader: uploaderReducer,
sizes: sizesSliceReducer,
dragndrop: dragndropReducer,
nodes: nodesReducer,
ui: uiReducer,
[apiSlice.reducerPath]: apiSlice.reducer
},
middleware: getDefaultMiddleware =>
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
selectPanelNodesStatus,
selectCurrentFolderID
} from "@/slices/dualPanel/dualPanel"
import {updateBreadcrumb} from "@/slices/sizes"
import {updateBreadcrumb} from "@/features/ui/uiSlice"

import type {PanelMode, NType, UserDetails} from "@/types"

Expand Down
19 changes: 2 additions & 17 deletions ui2/src/components/DualPanel/ToggleSecondaryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import {
openSecondaryPanel,
closeSecondaryPanel,
selectMainPanel,
selectSecondaryPanel,
selectLastPageSize
selectSecondaryPanel
} from "@/slices/dualPanel/dualPanel"
import {fetchPaginatedNodes, setCurrentNode} from "@/slices/dualPanel/dualPanel"
import {setCurrentNode} from "@/slices/dualPanel/dualPanel"
import {selectCurrentUser} from "@/slices/currentUser"

import type {PanelMode, User} from "@/types"
import {INITIAL_PAGE_SIZE} from "@/cconstants"
import {RootState} from "@/app/types"

import PanelContext from "@/contexts/PanelContext"

Expand All @@ -24,9 +21,6 @@ export default function ToggleSecondaryPanel() {
const secondaryPanel = useSelector(selectSecondaryPanel)
const user: User = useSelector(selectCurrentUser)
const dispatch = useDispatch()
const lastPageSize = useSelector((state: RootState) =>
selectLastPageSize(state, mode)
)

if (mainPanel) {
// mainPanel is always there
Expand All @@ -41,15 +35,6 @@ export default function ToggleSecondaryPanel() {
breadcrumb: null
})
)
dispatch(
fetchPaginatedNodes({
nodeId: folderId,
panel: "secondary",
urlParams: new URLSearchParams(
`page_number=1&page_size=${lastPageSize || INITIAL_PAGE_SIZE}`
)
})
)
dispatch(
setCurrentNode({
node: {
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/Header/SidebarToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useDispatch} from "react-redux"
import {IconMenu2} from "@tabler/icons-react"
import {UnstyledButton} from "@mantine/core"

import {toggleNavBar} from "@/slices/navBar"
import {toggleNavBar} from "@/features/ui/uiSlice"

export default function SidebarToggle() {
const dispatch = useDispatch()
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
selectCurrentUserStatus,
selectCurrentUserError
} from "@/slices/currentUser.ts"
import {selectNavBarCollapsed} from "@/slices/navBar"
import {selectNavBarCollapsed} from "@/features/ui/uiSlice"

import type {User} from "@/types.ts"

Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/SearchResults/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Group} from "@mantine/core"
import {useViewportSize} from "@mantine/hooks"
import {useDispatch} from "react-redux"
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel"
import {updateSearchActionPanel} from "@/slices/sizes"
import {updateSearchActionPanel} from "@/features/ui/uiSlice"

import GoBackButton from "./GoBackButton"
import OpenInOtherPanelCheckbox from "./OpenInOtherPanelCheckbox"
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/SearchResults/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "@/slices/dualPanel/dualPanel"
import ActionButtons from "./ActionButtons"
import SearchResultItems from "./SearchResultItems"
import {selectSearchContentHeight} from "@/slices/sizes"
import {selectSearchContentHeight} from "@/features/ui/uiSlice"
import {NType, PanelMode} from "@/types"
import classes from "./SearchResults.module.css"

Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/Uploader/uploader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Dialog, List, Container} from "@mantine/core"
import {useSelector, useDispatch} from "react-redux"
import {selectOpened, selectFiles, closeUploader} from "@/slices/uploader"
import {selectOpened, selectFiles, closeUploader} from "@/features/ui/uiSlice"
import UploaderItem from "./uploaderItem"

export default function Uploader() {
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/Viewer/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Group} from "@mantine/core"
import {useViewportSize} from "@mantine/hooks"
import {useDispatch, useSelector} from "react-redux"
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel"
import {updateActionPanel} from "@/slices/sizes"
import {updateActionPanel} from "@/features/ui/uiSlice"
import PanelContext from "@/contexts/PanelContext"
import EditTitleButton from "./EditTitleButton"

Expand Down
2 changes: 1 addition & 1 deletion ui2/src/components/Viewer/Viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {RootState} from "@/app/types"
import type {PanelMode, NType} from "@/types"
import Breadcrumbs from "@/components/Breadcrumbs"
import PanelContext from "@/contexts/PanelContext"
import {selectContentHeight} from "@/slices/sizes"
import {selectContentHeight} from "@/features/ui/uiSlice"
import ActionButtons from "./ActionButtons"
import ThumbnailsToggle from "./ThumbnailsToggle"
import Pages from "./Pages"
Expand Down
2 changes: 1 addition & 1 deletion ui2/src/features/nodes/components/Commander.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Breadcrumbs from "@/components/Breadcrumbs"
import Pagination from "@/components/Pagination"
import PanelContext from "@/contexts/PanelContext"
import drop_files from "@/components/modals/DropFiles"
import {selectContentHeight} from "@/slices/sizes"
import {selectContentHeight} from "@/features/ui/uiSlice"
import classes from "./Commander.module.scss"
import {useGetPaginatedNodesQuery} from "@/features/nodes/apiSlice"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Group} from "@mantine/core"
import {useViewportSize} from "@mantine/hooks"
import {useSelector, useDispatch} from "react-redux"
import {selectSelectedNodeIds} from "@/slices/dualPanel/dualPanel"
import {updateActionPanel} from "@/slices/sizes"
import {updateActionPanel} from "@/features/ui/uiSlice"

import type {RootState} from "@/app/types"
import type {PanelMode} from "@/types"
Expand Down
15 changes: 6 additions & 9 deletions ui2/src/features/nodes/components/UploadButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {useSelector} from "react-redux"
import {useAppSelector} from "@/app/hooks"
import {FileButton, ActionIcon, Tooltip} from "@mantine/core"
import {IconUpload} from "@tabler/icons-react"
import drop_files from "@/components/modals/DropFiles"
import {useContext} from "react"
import PanelContext from "@/contexts/PanelContext"
import {FolderType, PanelMode} from "@/types"
import {RootState} from "@/app/types"
import {selectCurrentFolder} from "@/slices/dualPanel/dualPanel"
import {PanelMode} from "@/types"
import {selectCurrentFolderID} from "@/slices/dualPanel/dualPanel"
import {useGetFolderQuery} from "../apiSlice"

const MIME_TYPES = [
"image/png",
Expand All @@ -17,10 +17,8 @@ const MIME_TYPES = [

export default function UploadButton() {
const mode: PanelMode = useContext(PanelContext)
const target = useSelector(
(state: RootState) =>
selectCurrentFolder(state, mode) as FolderType | undefined
)
const folderID = useAppSelector(s => selectCurrentFolderID(s, mode))
const {data: target} = useGetFolderQuery(folderID!)

const onUpload = (files: File[]) => {
if (!files) {
Expand All @@ -31,7 +29,6 @@ export default function UploadButton() {
console.error("Current folder is undefined")
return
}

drop_files({source_files: files, target}).then(() => {})
}

Expand Down
Loading