Skip to content

Commit 8a99034

Browse files
authored
fix(share): multipath selector is not joined base path (#235)
1 parent d99753c commit 8a99034

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/components/MultiPathInput.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { createSignal } from "solid-js"
1717
import { TbPlus, TbFolder } from "solid-icons/tb"
1818
import { useT } from "~/hooks"
19+
import { pathJoin } from "~/utils"
1920
import { EnhancedFolderTree } from "~/components/EnhancedFolderTree"
2021

2122
export interface MultiPathInputProps {
@@ -25,6 +26,7 @@ export interface MultiPathInputProps {
2526
readOnly?: boolean
2627
id?: string
2728
placeholder?: string
29+
basePath?: string
2830
}
2931

3032
export const MultiPathInput = (props: MultiPathInputProps) => {
@@ -34,7 +36,11 @@ export const MultiPathInput = (props: MultiPathInputProps) => {
3436

3537
const addPath = () => {
3638
const currentPaths = props.value ? props.value.split("\n") : []
37-
const newPaths = [...currentPaths, selectedPath()].filter(Boolean)
39+
let sp = selectedPath()
40+
if (props.basePath) {
41+
sp = pathJoin(props.basePath, sp)
42+
}
43+
const newPaths = [...currentPaths, sp].filter(Boolean)
3844
const uniquePaths = [...new Set(newPaths)]
3945
props.onChange(uniquePaths.join("\n"))
4046
onClose()

src/pages/manage/shares/AddOrEdit.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { MaybeLoading } from "~/components"
77
import { ResponsiveGrid } from "../common/ResponsiveGrid"
88
import { batch, createSignal, Show } from "solid-js"
99
import { Item } from "./Item"
10+
import { me } from "~/store"
1011

1112
const AddOrEdit = () => {
1213
const t = useT()
@@ -52,6 +53,7 @@ const AddOrEdit = () => {
5253
type={Type.MultiPath}
5354
value={files()}
5455
valid={filesValid()}
56+
basePath={me().base_path}
5557
required
5658
onChange={(f) => {
5759
setFiles(f)

src/pages/manage/shares/Item.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type ItemProps = {
5050
type: Type.MultiPath
5151
onChange?: (value: string) => void
5252
value: string
53+
basePath?: string
5354
}
5455
| {
5556
type: Type.Select
@@ -164,6 +165,7 @@ const Item = (props: ItemProps) => {
164165
value={props.value as string}
165166
valid={props.valid}
166167
readOnly={props.readonly}
168+
basePath={props.basePath}
167169
onChange={(value) => {
168170
if (props.type === Type.MultiPath) {
169171
props.onChange?.(value)

src/pages/manage/shares/Share.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { PEmptyResp, ShareInfo, UserMethods } from "~/types"
22
import { useFetch, useRouter, useT, useUtil } from "~/hooks"
33
import { Badge, Button, HStack, Td, Tr } from "@hope-ui/solid"
44
import {
5-
base_path,
65
handleResp,
76
handleRespWithNotifySuccess,
87
makeTemplateData,
@@ -29,9 +28,7 @@ function ShareOp(props: ShareProps) {
2928
const [enableOrDisableLoading, enableOrDisable] = useFetch(
3029
(): PEmptyResp =>
3130
r.post(
32-
`/share/${props.share.disabled ? "enable" : "disable"}?id=${
33-
props.share.id
34-
}`,
31+
`/share/${props.share.disabled ? "enable" : "disable"}?id=${props.share.id}`,
3532
),
3633
)
3734
return (

0 commit comments

Comments
 (0)