Skip to content

Commit 9a214fe

Browse files
Merge pull request #227 from PaperMold/feature/add-custom-date-formatter
Add support for custom date formatting in FileItem component
2 parents 510e1e4 + dc70777 commit 9a214fe

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

frontend/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ type File = {
110110
| `fileUploadConfig` | { url: string; method?: "POST" \| "PUT"; headers?: { [key: string]: string } } | Configuration object for file uploads. It includes the upload URL (`url`), an optional HTTP method (`method`, default is `"POST"`), and an optional `headers` object for setting custom HTTP headers in the upload request. The `method` property allows only `"POST"` or `"PUT"` values. The `headers` object can accept any standard or custom headers required by the server. Example: `{ url: "https://example.com/fileupload", method: "PUT", headers: { Authorization: "Bearer " + TOKEN, "X-Custom-Header": "value" } }` |
111111
| `files` | Array<[File](#-file-structure)> | An array of file and folder objects representing the current directory structure. Each object includes `name`, `isDirectory`, and `path` properties. |
112112
| `fontFamily` | string | The font family to be used throughout the component. Accepts any valid CSS font family (e.g., `'Arial, sans-serif'`, `'Roboto'`). You can customize the font styling to match your application's theme. `default: 'Nunito Sans, sans-serif'`. |
113+
| `formatDate` | (date: string \| Date) => string | (Optional) A custom function used to format file and folder modification dates. If omitted, the component falls back to its built-in formatter from `utils/formatDate`. Useful for adapting the date display to different locales or formats.
113114
| `height` | string \| number | The height of the component `default: 600px`. Can be a string (e.g., `'100%'`, `'10rem'`) or a number (in pixels). |
114115
| `initialPath` | string | The path of the directory to be loaded initially e.g. `/Documents`. This should be the path of a folder which is included in `files` array. Default value is `""` |
115116
| `isLoading` | boolean | A boolean state indicating whether the application is currently performing an operation, such as creating, renaming, or deleting a file/folder. Displays a loading state if set `true`. |

frontend/src/FileManager/FileList/FileItem.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useFileIcons } from "../../hooks/useFileIcons";
44
import CreateFolderAction from "../Actions/CreateFolder/CreateFolder.action";
55
import RenameAction from "../Actions/Rename/Rename.action";
66
import { getDataSize } from "../../utils/getDataSize";
7-
import { formatDate } from "../../utils/formatDate";
87
import { useFileNavigation } from "../../contexts/FileNavigationContext";
98
import { useSelection } from "../../contexts/SelectionContext";
109
import { useClipBoard } from "../../contexts/ClipboardContext";
@@ -26,6 +25,7 @@ const FileItem = ({
2625
handleContextMenu,
2726
setLastSelectedFile,
2827
draggable,
28+
formatDate,
2929
}) => {
3030
const [fileSelected, setFileSelected] = useState(false);
3131
const [lastClickTime, setLastClickTime] = useState(0);

frontend/src/FileManager/FileList/FileList.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const FileList = ({
1717
enableFilePreview,
1818
triggerAction,
1919
permissions,
20+
formatDate,
2021
}) => {
2122
const { currentPathFiles, sortConfig, setSortConfig } = useFileNavigation();
2223
const filesViewRef = useRef(null);
@@ -75,6 +76,7 @@ const FileList = ({
7576
setVisible={setVisible}
7677
setLastSelectedFile={setLastSelectedFile}
7778
draggable={permissions.move}
79+
formatDate={formatDate}
7880
/>
7981
))}
8082
</>

frontend/src/FileManager/FileManager.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { dateStringValidator, urlValidator } from "../validators/propValidators"
1616
import { TranslationProvider } from "../contexts/TranslationProvider";
1717
import { useMemo, useState } from "react";
1818
import { defaultPermissions } from "../constants";
19+
import { formatDate as defaultFormatDate } from "../utils/formatDate";
1920
import "./FileManager.scss";
2021

2122
const FileManager = ({
@@ -55,6 +56,7 @@ const FileManager = ({
5556
defaultNavExpanded = true,
5657
className = "",
5758
style = {},
59+
formatDate = defaultFormatDate,
5860
}) => {
5961
const [isNavigationPaneOpen, setNavigationPaneOpen] = useState(defaultNavExpanded);
6062
const triggerAction = useTriggerAction();
@@ -131,6 +133,7 @@ const FileManager = ({
131133
enableFilePreview={enableFilePreview}
132134
triggerAction={triggerAction}
133135
permissions={permissions}
136+
formatDate={formatDate}
134137
/>
135138
</div>
136139
</section>
@@ -217,6 +220,7 @@ FileManager.propTypes = {
217220
defaultNavExpanded: PropTypes.bool,
218221
className: PropTypes.string,
219222
style: PropTypes.object,
223+
formatDate: PropTypes.func,
220224
};
221225

222226
export default FileManager;

0 commit comments

Comments
 (0)