mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 19:44:35 +00:00
fix(web): show original name as default name in rename file/folder modal
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
|
|
||||||
import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
|
import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ type NameInputModalProps = {
|
|||||||
isFolder: boolean
|
isFolder: boolean
|
||||||
actionLabel: string
|
actionLabel: string
|
||||||
action: (name: string) => void
|
action: (name: string) => void
|
||||||
|
defaultName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const NameInputModal = ({
|
const NameInputModal = ({
|
||||||
@@ -20,12 +21,17 @@ const NameInputModal = ({
|
|||||||
title,
|
title,
|
||||||
isFolder,
|
isFolder,
|
||||||
actionLabel,
|
actionLabel,
|
||||||
action
|
action,
|
||||||
|
defaultName
|
||||||
}: NameInputModalProps) => {
|
}: NameInputModalProps) => {
|
||||||
const [name, setName] = useState('')
|
const [name, setName] = useState('')
|
||||||
const [hasError, setHasError] = useState(false)
|
const [hasError, setHasError] = useState(false)
|
||||||
const [errorText, setErrorText] = useState('')
|
const [errorText, setErrorText] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (defaultName) setName(defaultName)
|
||||||
|
}, [defaultName])
|
||||||
|
|
||||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = event.target.value
|
const value = event.target.value
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ const TreeViewNode = ({
|
|||||||
action={
|
action={
|
||||||
nameInputModalActionLabel === 'Add' ? addFileFolder : renameFileFolder
|
nameInputModalActionLabel === 'Add' ? addFileFolder : renameFileFolder
|
||||||
}
|
}
|
||||||
|
defaultName={node.relativePath.split('/').pop()}
|
||||||
/>
|
/>
|
||||||
<Menu
|
<Menu
|
||||||
open={contextMenu !== null}
|
open={contextMenu !== null}
|
||||||
|
|||||||
Reference in New Issue
Block a user