This repository was archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/ff 429 create new folder #170
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0807001
FF-430 add create new Folder api function
qvalentin 2387661
FF-433 add Modal for create new folder
qvalentin 7640b8c
update snapshots
qvalentin 6c55c81
change be url
qvalentin c6297c6
add prevent default to event handler
qvalentin 19c3b12
Merge branch 'master' into feature/FF-429-createNewFolder
qvalentin 41b3cc5
update snapshots
qvalentin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
interface constantsdef { | ||
url: { API_URL: string | ||
FH_URL: string}; | ||
url: { API_URL: string; FH_URL: string }; | ||
} | ||
|
||
const prod: constantsdef = { | ||
url: { | ||
API_URL: window.location.origin + "/api", | ||
FH_URL: window.location.origin + "/data" | ||
} | ||
url: { | ||
API_URL: window.location.origin + "/api", | ||
FH_URL: window.location.origin + "/data" | ||
} | ||
}; | ||
|
||
const dev: constantsdef = { | ||
url: { | ||
API_URL: "https://demo.filefighter.de/api", | ||
// API_URL: "http://localhost:8080", | ||
//API_URL: "http://localhost/api", | ||
//FH_URL: "http://localhost:5000/data" | ||
//FH_URL: "http://localhost/data" | ||
FH_URL: "https://demo.filefighter.de/data" | ||
|
||
} | ||
url: { | ||
API_URL: "https://demo.filefighter.de/api", | ||
// API_URL: "http://localhost:8080", | ||
//API_URL: "http://localhost/api", | ||
//FH_URL: "http://localhost:5000/data" | ||
//FH_URL: "http://localhost/data" | ||
FH_URL: "https://demo.filefighter.de/data" | ||
} | ||
}; | ||
export const constants = process.env.NODE_ENV === "development" ? dev : prod; | ||
|
||
|
||
export const MIN_PASSWORD_LENGTH = 8; | ||
export const MAX_PASSWORD_LENGTH = 20; | ||
export const DEFAULT_ALERT_DURATION = 3500; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useSelector } from "react-redux"; | ||
import React, { ReactElement, useState } from "react"; | ||
import { RootState } from "../../../../background/redux/store"; | ||
import { Button } from "react-bootstrap"; | ||
import { Modal } from "react-bootstrap"; | ||
import { NewFolderModalContent } from "./NewFolderModalContent"; | ||
|
||
function NewFolder(): ReactElement { | ||
const currentFsItemId = useSelector( | ||
(state: RootState) => state.filesystem.currentFsItemId | ||
); | ||
const [showModal, setShowModal] = useState(false); | ||
const handleClose = () => setShowModal(false); | ||
const handleShow = () => setShowModal(true); | ||
|
||
if (currentFsItemId === "-1") { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<> | ||
<Button onClick={handleShow}>New Folder</Button> | ||
<Modal | ||
show={showModal} | ||
onHide={handleClose} | ||
contentClassName={"bg-body"} | ||
> | ||
<NewFolderModalContent | ||
handleClose={handleClose} | ||
currentFsItemId={currentFsItemId} | ||
/> | ||
</Modal> | ||
</> | ||
); | ||
} | ||
|
||
export { NewFolder }; |
71 changes: 71 additions & 0 deletions
71
src/components/pages/filesytem/upload/NewFolderModalContent.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Button, Form, Modal, Row } from "react-bootstrap"; | ||
import React, { FormEvent, useState } from "react"; | ||
import { createNewFolder } from "../../../../background/api/filesystem"; | ||
import { isFileNameValid } from "../../../../background/methods/filesystem"; | ||
import { useDispatch } from "react-redux"; | ||
import { addToContents } from "../../../../background/redux/actions/filesystem"; | ||
|
||
interface Props { | ||
handleClose: () => void; | ||
currentFsItemId: string; | ||
} | ||
|
||
function NewFolderModalContent({ handleClose, currentFsItemId }: Props) { | ||
const dispatch = useDispatch(); | ||
const [folderName, setFolderName] = useState(""); | ||
const [error, setError] = useState(""); | ||
|
||
function handleApply(event: FormEvent) { | ||
event.preventDefault(); | ||
console.log("[NEW FOLDER ]", folderName); | ||
if (!isFileNameValid(folderName)) { | ||
setError("The name is not a valid foldername."); | ||
return; | ||
} | ||
|
||
createNewFolder(folderName, currentFsItemId) | ||
.then((response) => { | ||
dispatch(addToContents(response.data)); | ||
setError(""); | ||
handleClose(); | ||
}) | ||
.catch((error) => | ||
setError( | ||
error.response?.data.message ?? "Something went wrong :(" | ||
) | ||
); | ||
} | ||
|
||
return ( | ||
<Form onSubmit={handleApply}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Create new Directory</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form.Group controlId="formFolderName"> | ||
<Form.Label>Folder name</Form.Label> | ||
<Form.Control | ||
type="text" | ||
placeholder="e.g. My Cat Pictures" | ||
value={folderName} | ||
onChange={(event) => setFolderName(event.target.value)} | ||
/> | ||
</Form.Group> | ||
{error && <p className="text-danger">{error}</p>} | ||
</Modal.Body> | ||
|
||
<Modal.Footer> | ||
<Row className="w-100 justify-content-between"> | ||
<Button variant="secondary" onClick={handleClose}> | ||
Abort | ||
</Button> | ||
<Button variant="primary" onClick={handleApply}> | ||
Creat Folder | ||
</Button> | ||
</Row> | ||
</Modal.Footer> | ||
</Form> | ||
); | ||
} | ||
|
||
export { NewFolderModalContent }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3