@griddo/ax 10.3.2 → 10.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/api/files.tsx +20 -4
- package/src/api/utils.tsx +4 -2
- package/src/components/Fields/FileField/index.tsx +1 -1
- package/src/components/FileGallery/index.tsx +101 -70
- package/src/components/FileGallery/style.tsx +19 -3
- package/src/components/Icon/components/Download.js +7 -0
- package/src/components/Icon/svgs/Download.svg +3 -0
- package/src/components/SearchField/index.tsx +17 -1
- package/src/components/SearchField/style.tsx +4 -1
- package/src/components/Tag/index.tsx +12 -2
- package/src/components/Tag/style.tsx +19 -9
- package/src/containers/FileDrive/actions.tsx +26 -0
- package/src/containers/Sites/actions.tsx +26 -13
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/resize.ts +57 -0
- package/src/modules/Content/PageItem/index.tsx +1 -0
- package/src/modules/Content/index.tsx +23 -6
- package/src/modules/FileDrive/BulkListHeader/TableHeader/index.tsx +3 -1
- package/src/modules/FileDrive/BulkListHeader/TableHeader/style.tsx +16 -2
- package/src/modules/FileDrive/BulkListHeader/index.tsx +9 -2
- package/src/modules/FileDrive/FileDragAndDrop/index.tsx +4 -2
- package/src/modules/FileDrive/FileFilters/SortBy/index.tsx +60 -0
- package/src/modules/FileDrive/FileFilters/SortBy/style.tsx +31 -0
- package/src/modules/FileDrive/FileFilters/Type/index.tsx +77 -0
- package/src/modules/FileDrive/FileFilters/Type/style.tsx +39 -0
- package/src/modules/FileDrive/FileFilters/Usage/index.tsx +66 -0
- package/src/modules/FileDrive/FileFilters/Usage/style.tsx +30 -0
- package/src/modules/FileDrive/FileModal/DetailPanel/index.tsx +26 -7
- package/src/modules/FileDrive/FileModal/index.tsx +81 -15
- package/src/modules/FileDrive/GridItem/index.tsx +24 -5
- package/src/modules/FileDrive/GridItem/style.tsx +9 -4
- package/src/modules/FileDrive/ListItem/index.tsx +22 -4
- package/src/modules/FileDrive/ListItem/style.tsx +7 -1
- package/src/modules/FileDrive/atoms.tsx +27 -4
- package/src/modules/FileDrive/helpers.tsx +17 -17
- package/src/modules/FileDrive/hooks.tsx +77 -0
- package/src/modules/FileDrive/index.tsx +145 -23
- package/src/modules/FileDrive/style.tsx +40 -6
- package/src/modules/FileDrive/utils.tsx +19 -0
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
- package/src/types/index.tsx +2 -3
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { IFile } from "@ax/types";
|
|
3
3
|
import { Button, FloatingMenu, IconAction, Toast, Tooltip } from "@ax/components";
|
|
4
|
-
import { useToast } from "@ax/hooks";
|
|
4
|
+
import { useModal, useToast } from "@ax/hooks";
|
|
5
5
|
import FileDragAndDrop from "../FileDragAndDrop";
|
|
6
6
|
import { getFileIcon } from "../helpers";
|
|
7
|
+
import { NotSavedModal } from "../atoms";
|
|
7
8
|
import DetailPanel from "./DetailPanel";
|
|
9
|
+
import { IFileFormState } from "..";
|
|
8
10
|
|
|
9
11
|
import * as S from "./style";
|
|
10
12
|
|
|
11
13
|
const FileModal = (props: IProps) => {
|
|
12
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
file,
|
|
16
|
+
items,
|
|
17
|
+
activeDelete,
|
|
18
|
+
isAllowedToEdit,
|
|
19
|
+
setFile,
|
|
20
|
+
toggleModal,
|
|
21
|
+
onDelete,
|
|
22
|
+
setFileSelected,
|
|
23
|
+
handleDownload,
|
|
24
|
+
form,
|
|
25
|
+
setForm,
|
|
26
|
+
isDirty,
|
|
27
|
+
resetDirty,
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
13
30
|
const { fileType, fileName, id, site } = file;
|
|
14
31
|
|
|
15
32
|
const [replaceType, setReplaceType] = useState<"full" | "partial" | null>(null);
|
|
16
33
|
const [isDNDVisible, setDNDVisible] = useState(false);
|
|
34
|
+
const [isArrowPrev, setIsArrowPrev] = useState(false);
|
|
17
35
|
const { isVisible, toggleToast, setIsVisible } = useToast();
|
|
36
|
+
const { isOpen: isSaveOpen, toggleModal: toggleSaveModal } = useModal();
|
|
18
37
|
|
|
19
38
|
const iconUrl = `/img/icons/${getFileIcon(fileType)}`;
|
|
20
39
|
const index = items.indexOf(file.id);
|
|
@@ -22,6 +41,16 @@ const FileModal = (props: IProps) => {
|
|
|
22
41
|
const validFormats = ["pdf", "doc", "docx", "xls", "xlsx", "zip"];
|
|
23
42
|
|
|
24
43
|
const handleArrowClick = (isPrev: boolean) => () => {
|
|
44
|
+
if (isDirty) {
|
|
45
|
+
setIsArrowPrev(isPrev);
|
|
46
|
+
toggleSaveModal();
|
|
47
|
+
} else {
|
|
48
|
+
resetDirty();
|
|
49
|
+
changeFile(isPrev);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const changeFile = (isPrev: boolean) => {
|
|
25
54
|
isPrev ? setFile(items[index - 1]) : setFile(items[index + 1]);
|
|
26
55
|
setDNDVisible(false);
|
|
27
56
|
setReplaceType(null);
|
|
@@ -54,11 +83,26 @@ const FileModal = (props: IProps) => {
|
|
|
54
83
|
toggleToast();
|
|
55
84
|
};
|
|
56
85
|
|
|
86
|
+
const handleFileDownload = () => handleDownload(id, fileName);
|
|
87
|
+
|
|
57
88
|
const toastProps = {
|
|
58
89
|
setIsVisible,
|
|
59
90
|
message: "1 file replaced",
|
|
60
91
|
};
|
|
61
92
|
|
|
93
|
+
const handleMainAction = () => {
|
|
94
|
+
toggleSaveModal();
|
|
95
|
+
resetDirty();
|
|
96
|
+
changeFile(isArrowPrev);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const mainModalAction = {
|
|
100
|
+
title: "Yes, discard changes",
|
|
101
|
+
onClick: () => handleMainAction(),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleSaveModal };
|
|
105
|
+
|
|
62
106
|
return (
|
|
63
107
|
<>
|
|
64
108
|
<S.Wrapper>
|
|
@@ -67,21 +111,23 @@ const FileModal = (props: IProps) => {
|
|
|
67
111
|
<S.FilePreview>
|
|
68
112
|
<S.ImageWrapper>
|
|
69
113
|
<S.IconWrapper>
|
|
70
|
-
<div
|
|
114
|
+
<div>
|
|
115
|
+
<img src={iconUrl} alt={`${fileType} Icon`} />
|
|
116
|
+
</div>
|
|
71
117
|
{isDNDVisible && (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
118
|
+
<S.DragAndDropWrapper>
|
|
119
|
+
<FileDragAndDrop
|
|
120
|
+
validFormats={validFormats}
|
|
121
|
+
handleUpload={handleUpload}
|
|
122
|
+
inverse={true}
|
|
123
|
+
replaceData={{ fileID: id, keepURL: replaceType === "full" ? false : true }}
|
|
124
|
+
siteID={site || "global"}
|
|
125
|
+
/>
|
|
126
|
+
</S.DragAndDropWrapper>
|
|
127
|
+
)}
|
|
82
128
|
</S.IconWrapper>
|
|
83
129
|
</S.ImageWrapper>
|
|
84
|
-
<S.FileName>{fileName}</S.FileName>
|
|
130
|
+
<S.FileName data-testid="file-name">{fileName}</S.FileName>
|
|
85
131
|
<S.FileActions>
|
|
86
132
|
{isAllowedToEdit ? (
|
|
87
133
|
<S.ReplaceWrapper>
|
|
@@ -98,6 +144,9 @@ const FileModal = (props: IProps) => {
|
|
|
98
144
|
) : (
|
|
99
145
|
<></>
|
|
100
146
|
)}
|
|
147
|
+
<Button type="button" buttonStyle="text" icon="download" onClick={handleFileDownload}>
|
|
148
|
+
Download
|
|
149
|
+
</Button>
|
|
101
150
|
</S.FileActions>
|
|
102
151
|
</S.FilePreview>
|
|
103
152
|
<IconAction icon="rightArrow" onClick={handleArrowClick(false)} disabled={index === items.length - 1} />
|
|
@@ -108,9 +157,21 @@ const FileModal = (props: IProps) => {
|
|
|
108
157
|
onDelete={onDelete}
|
|
109
158
|
activeDelete={activeDelete}
|
|
110
159
|
isAllowedToEdit={isAllowedToEdit}
|
|
160
|
+
form={form}
|
|
161
|
+
setForm={setForm}
|
|
162
|
+
isDirty={isDirty}
|
|
163
|
+
resetDirty={resetDirty}
|
|
111
164
|
/>
|
|
112
165
|
</S.Wrapper>
|
|
113
166
|
{isVisible && <Toast {...toastProps} />}
|
|
167
|
+
{isSaveOpen && (
|
|
168
|
+
<NotSavedModal
|
|
169
|
+
isOpen={isSaveOpen}
|
|
170
|
+
toggleModal={toggleSaveModal}
|
|
171
|
+
mainModalAction={mainModalAction}
|
|
172
|
+
secondaryModalAction={secondaryModalAction}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
114
175
|
</>
|
|
115
176
|
);
|
|
116
177
|
};
|
|
@@ -120,10 +181,15 @@ interface IProps {
|
|
|
120
181
|
toggleModal(): void;
|
|
121
182
|
onDelete(fileID: number): void;
|
|
122
183
|
items: number[];
|
|
123
|
-
setFile
|
|
184
|
+
setFile(id: number): void;
|
|
124
185
|
setFileSelected: (file: IFile) => void;
|
|
125
186
|
activeDelete: boolean;
|
|
126
187
|
isAllowedToEdit: boolean;
|
|
188
|
+
handleDownload(fileID: number, fileName: string): void;
|
|
189
|
+
form: IFileFormState;
|
|
190
|
+
setForm(form: IFileFormState): void;
|
|
191
|
+
isDirty: boolean;
|
|
192
|
+
resetDirty(): void;
|
|
127
193
|
}
|
|
128
194
|
|
|
129
195
|
export default FileModal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { CheckField, Tooltip } from "@ax/components";
|
|
2
|
+
import { CheckField, Tag, Tooltip } from "@ax/components";
|
|
3
3
|
import { IActionMenuOption, ICheck, IFile } from "@ax/types";
|
|
4
4
|
import { formatBytes, getFormattedDateWithTimezone, trimText } from "@ax/helpers";
|
|
5
5
|
import { useModal } from "@ax/hooks";
|
|
@@ -17,11 +17,13 @@ const GridItem = (props: IProps) => {
|
|
|
17
17
|
isAllowedToDelete,
|
|
18
18
|
isAllowedToEdit,
|
|
19
19
|
isAllowedToMove,
|
|
20
|
+
isSearching,
|
|
20
21
|
onChange,
|
|
21
22
|
onClick,
|
|
22
23
|
onDelete,
|
|
23
24
|
onMove,
|
|
24
25
|
} = props;
|
|
26
|
+
|
|
25
27
|
const { id, fileName, fileType, sizeBytes, uploadDate, folder } = file;
|
|
26
28
|
|
|
27
29
|
const [selectedFolder, setSelectedFolder] = useState<number>(currentFolderID || 0);
|
|
@@ -74,7 +76,7 @@ const GridItem = (props: IProps) => {
|
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
const handleMoveFile = () => {
|
|
77
|
-
if(folder !== selectedFolder) {
|
|
79
|
+
if (folder?.folderId !== selectedFolder) {
|
|
78
80
|
onMove(id, selectedFolder);
|
|
79
81
|
isMoveOpen && toggleMoveModal();
|
|
80
82
|
setSelectedFolder(0);
|
|
@@ -103,15 +105,26 @@ const GridItem = (props: IProps) => {
|
|
|
103
105
|
const FileTitle = () =>
|
|
104
106
|
fileName.length > 40 ? (
|
|
105
107
|
<Tooltip content={fileName}>
|
|
106
|
-
<S.Name>{trimText(fileName, 40)}</S.Name>
|
|
108
|
+
<S.Name data-testid="file-name">{trimText(fileName, 40)}</S.Name>
|
|
109
|
+
</Tooltip>
|
|
110
|
+
) : (
|
|
111
|
+
<S.Name data-testid="file-name">{fileName}</S.Name>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const FolderTag = () =>{
|
|
115
|
+
if(!folder) return <></>;
|
|
116
|
+
return folder.folderName.length > 20 ? (
|
|
117
|
+
<Tooltip content={folder.folderName}>
|
|
118
|
+
<Tag type="square" text={trimText(folder.folderName, 25)} icon="project" />
|
|
107
119
|
</Tooltip>
|
|
108
120
|
) : (
|
|
109
|
-
<
|
|
121
|
+
<Tag type="square" text={folder.folderName} icon="project" />
|
|
110
122
|
);
|
|
123
|
+
}
|
|
111
124
|
|
|
112
125
|
return (
|
|
113
126
|
<>
|
|
114
|
-
<S.Wrapper onClick={handleClick}>
|
|
127
|
+
<S.Wrapper onClick={handleClick} isTall={isSearching}>
|
|
115
128
|
<S.Header>
|
|
116
129
|
<S.CheckWrapper onClick={handleCheckClick}>
|
|
117
130
|
<CheckField name="check" value={id} checked={isSelected} onChange={handleChange} />
|
|
@@ -126,6 +139,11 @@ const GridItem = (props: IProps) => {
|
|
|
126
139
|
<S.Tag>{getFormattedDateWithTimezone(uploadDate, "d MMM Y")}</S.Tag>
|
|
127
140
|
<S.Tag>{formatBytes(sizeBytes)}</S.Tag>
|
|
128
141
|
</S.Info>
|
|
142
|
+
{isSearching && folder && (
|
|
143
|
+
<S.TagWrapper>
|
|
144
|
+
<FolderTag />
|
|
145
|
+
</S.TagWrapper>
|
|
146
|
+
)}
|
|
129
147
|
</S.Wrapper>
|
|
130
148
|
{isDeleteOpen && (
|
|
131
149
|
<DeleteFileModal
|
|
@@ -158,6 +176,7 @@ interface IProps {
|
|
|
158
176
|
isAllowedToEdit: boolean;
|
|
159
177
|
isAllowedToDelete: boolean;
|
|
160
178
|
isAllowedToMove: boolean;
|
|
179
|
+
isSearching: boolean;
|
|
161
180
|
onChange(e: ICheck): void;
|
|
162
181
|
onClick(file: IFile): void;
|
|
163
182
|
onDelete(fileID: number): void;
|
|
@@ -10,18 +10,18 @@ const StyledActionMenu = styled(ActionMenu)`
|
|
|
10
10
|
top: ${(p) => p.theme.spacing.xs};
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
-
const Wrapper = styled.div
|
|
13
|
+
const Wrapper = styled.div<{ isTall: boolean }>`
|
|
14
14
|
position: relative;
|
|
15
15
|
background-color: ${(p) => p.theme.color.uiBackground02};
|
|
16
16
|
border: ${(p) => `1px solid ${p.theme.color.uiLine}`};
|
|
17
|
-
border-radius: ${p => p.theme.radii.s};
|
|
17
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
padding: ${(p) => p.theme.spacing.s};
|
|
21
21
|
width: 100%;
|
|
22
22
|
min-width: 220px;
|
|
23
23
|
max-width: 280px;
|
|
24
|
-
height: 154px;
|
|
24
|
+
height: ${(p) => (p.isTall ? "180px" : "154px")};
|
|
25
25
|
margin-right: ${(p) => p.theme.spacing.s};
|
|
26
26
|
cursor: pointer;
|
|
27
27
|
&:hover {
|
|
@@ -73,4 +73,9 @@ const Tag = styled.div`
|
|
|
73
73
|
margin-right: ${(p) => p.theme.spacing.xxs};
|
|
74
74
|
`;
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const TagWrapper = styled.div`
|
|
77
|
+
display: flex;
|
|
78
|
+
margin-top: ${(p) => p.theme.spacing.xs};
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
export { Wrapper, Header, Name, Info, CheckWrapper, IconWrapper, StyledActionMenu, Tag, TagWrapper };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { CheckField, ElementsTooltip, Tooltip } from "@ax/components";
|
|
2
|
+
import { CheckField, ElementsTooltip, Tag, Tooltip } from "@ax/components";
|
|
3
3
|
import { IActionMenuOption, ICheck, IFile } from "@ax/types";
|
|
4
4
|
import { formatBytes, getFormattedDateWithTimezone, trimText } from "@ax/helpers";
|
|
5
|
-
import { useModal
|
|
5
|
+
import { useModal } from "@ax/hooks";
|
|
6
6
|
|
|
7
7
|
import { getFileIcon } from "../helpers";
|
|
8
8
|
import { DeleteFileModal, MoveItemModal } from "../atoms";
|
|
@@ -17,6 +17,7 @@ const ListItem = (props: IProps) => {
|
|
|
17
17
|
isAllowedToDelete,
|
|
18
18
|
isAllowedToEdit,
|
|
19
19
|
isAllowedToMove,
|
|
20
|
+
isSearching,
|
|
20
21
|
onChange,
|
|
21
22
|
onClick,
|
|
22
23
|
onDelete,
|
|
@@ -73,7 +74,7 @@ const ListItem = (props: IProps) => {
|
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
const handleMoveFile = () => {
|
|
76
|
-
if(folder !== selectedFolder) {
|
|
77
|
+
if (folder?.folderId !== selectedFolder) {
|
|
77
78
|
onMove(id, selectedFolder);
|
|
78
79
|
isMoveOpen && toggleMoveModal();
|
|
79
80
|
setSelectedFolder(0);
|
|
@@ -102,6 +103,17 @@ const ListItem = (props: IProps) => {
|
|
|
102
103
|
const FileTitle = () =>
|
|
103
104
|
fileName.length > 50 ? <Tooltip content={fileName}>{trimText(fileName, 50)}</Tooltip> : <>{fileName}</>;
|
|
104
105
|
|
|
106
|
+
const FolderTag = () => {
|
|
107
|
+
if (!folder) return <></>;
|
|
108
|
+
return folder.folderName.length > 20 ? (
|
|
109
|
+
<Tooltip content={folder.folderName}>
|
|
110
|
+
<Tag type="square" text={trimText(folder.folderName,20)} icon="project" />
|
|
111
|
+
</Tooltip>
|
|
112
|
+
) : (
|
|
113
|
+
<Tag type="square" text={folder.folderName} icon="project" />
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
105
117
|
return (
|
|
106
118
|
<>
|
|
107
119
|
<S.ItemRow role="rowgroup" selected={isSelected}>
|
|
@@ -111,7 +123,7 @@ const ListItem = (props: IProps) => {
|
|
|
111
123
|
<S.IconCell role="cell" onClick={handleClick}>
|
|
112
124
|
<img src={iconUrl} alt={`${fileType} Icon`} />
|
|
113
125
|
</S.IconCell>
|
|
114
|
-
<S.NameCell role="cell" onClick={handleClick}>
|
|
126
|
+
<S.NameCell role="cell" onClick={handleClick} data-testid="file-name-cell">
|
|
115
127
|
<FileTitle />
|
|
116
128
|
</S.NameCell>
|
|
117
129
|
<S.TypeCell role="cell" onClick={handleClick}>
|
|
@@ -136,6 +148,11 @@ const ListItem = (props: IProps) => {
|
|
|
136
148
|
/>
|
|
137
149
|
)}
|
|
138
150
|
</S.TagsCell>
|
|
151
|
+
{isSearching && (
|
|
152
|
+
<S.FolderCell role="cell">
|
|
153
|
+
<FolderTag />
|
|
154
|
+
</S.FolderCell>
|
|
155
|
+
)}
|
|
139
156
|
<S.ActionsCell role="cell">
|
|
140
157
|
<S.StyledActionMenu icon="more" options={menuOptions} tooltip="File actions" />
|
|
141
158
|
</S.ActionsCell>
|
|
@@ -171,6 +188,7 @@ interface IProps {
|
|
|
171
188
|
isAllowedToEdit: boolean;
|
|
172
189
|
isAllowedToDelete: boolean;
|
|
173
190
|
isAllowedToMove: boolean;
|
|
191
|
+
isSearching: boolean;
|
|
174
192
|
onChange(e: ICheck): void;
|
|
175
193
|
onClick(file: IFile): void;
|
|
176
194
|
onDelete(fileID: number): void;
|
|
@@ -53,7 +53,7 @@ const FileType = styled.div`
|
|
|
53
53
|
const SizeCell = styled(Cell)`
|
|
54
54
|
${(p) => p.theme.textStyle.uiXS};
|
|
55
55
|
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
56
|
-
flex: 0 0
|
|
56
|
+
flex: 0 0 85px;
|
|
57
57
|
align-items: center;
|
|
58
58
|
`;
|
|
59
59
|
|
|
@@ -68,6 +68,11 @@ const TagsCell = styled(Cell)`
|
|
|
68
68
|
flex: 0 0 300px;
|
|
69
69
|
`;
|
|
70
70
|
|
|
71
|
+
const FolderCell = styled(Cell)`
|
|
72
|
+
flex: 0 0 200px;
|
|
73
|
+
align-content: flex-start;
|
|
74
|
+
`;
|
|
75
|
+
|
|
71
76
|
const ActionsCell = styled(Cell)`
|
|
72
77
|
flex: 0 0 70px;
|
|
73
78
|
text-align: center;
|
|
@@ -85,4 +90,5 @@ export {
|
|
|
85
90
|
UpdatedCell,
|
|
86
91
|
TagsCell,
|
|
87
92
|
ActionsCell,
|
|
93
|
+
FolderCell,
|
|
88
94
|
};
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { IModal } from "@ax/types";
|
|
4
4
|
import { Modal, FieldsBehavior } from "@ax/components";
|
|
5
5
|
import FolderTree from "./FolderTree";
|
|
6
|
-
import {
|
|
6
|
+
import { IFolderFormState } from ".";
|
|
7
7
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
@@ -149,9 +149,32 @@ const MoveItemModal = (props: IMoveModalProps): JSX.Element => {
|
|
|
149
149
|
);
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
+
const NotSavedModal = (props: IModal): JSX.Element => {
|
|
153
|
+
const { isOpen, toggleModal, mainModalAction, secondaryModalAction } = props;
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<Modal
|
|
157
|
+
isOpen={isOpen}
|
|
158
|
+
hide={toggleModal}
|
|
159
|
+
size="S"
|
|
160
|
+
title="Unsaved changes"
|
|
161
|
+
mainAction={mainModalAction}
|
|
162
|
+
secondaryAction={secondaryModalAction}
|
|
163
|
+
isChild={true}
|
|
164
|
+
>
|
|
165
|
+
{
|
|
166
|
+
<S.ModalContent>
|
|
167
|
+
Some content is not saved on this file. If you exit without saving it, it will be lost. Do you want to discard
|
|
168
|
+
your changes?
|
|
169
|
+
</S.ModalContent>
|
|
170
|
+
}
|
|
171
|
+
</Modal>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
152
175
|
interface INewModalProps extends IModal {
|
|
153
|
-
form:
|
|
154
|
-
setForm(form:
|
|
176
|
+
form: IFolderFormState;
|
|
177
|
+
setForm(form: IFolderFormState): void;
|
|
155
178
|
}
|
|
156
179
|
|
|
157
180
|
interface IRenameModalProps extends IModal {
|
|
@@ -170,4 +193,4 @@ interface IMoveModalProps extends IModal {
|
|
|
170
193
|
hideRoot?: boolean;
|
|
171
194
|
}
|
|
172
195
|
|
|
173
|
-
export { NewFolderModal, DeleteFolderModal, DeleteFileModal, MoveItemModal, RenameFolderModal };
|
|
196
|
+
export { NewFolderModal, DeleteFolderModal, DeleteFileModal, MoveItemModal, RenameFolderModal, NotSavedModal };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const getFileIcon = (type: string) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
switch (type) {
|
|
3
|
+
case "pdf":
|
|
4
|
+
return "pdf.png";
|
|
5
|
+
case "doc":
|
|
6
|
+
case "docx":
|
|
7
|
+
return "word.png";
|
|
8
|
+
case "xls":
|
|
9
|
+
case "xlsx":
|
|
10
|
+
case "csv":
|
|
11
|
+
return "excel.png";
|
|
12
|
+
case "zip":
|
|
13
|
+
return "zip.png";
|
|
14
|
+
default:
|
|
15
|
+
return "zip.png";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export { getFileIcon };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useSortedListStatus = () => {
|
|
4
|
+
const sortedInitialState: {
|
|
5
|
+
isAscending: boolean;
|
|
6
|
+
sortedByName: boolean;
|
|
7
|
+
sortedByDate: boolean;
|
|
8
|
+
sortedBySize: boolean;
|
|
9
|
+
} = {
|
|
10
|
+
isAscending: false,
|
|
11
|
+
sortedByName: false,
|
|
12
|
+
sortedByDate: false,
|
|
13
|
+
sortedBySize: false,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const [sortedListStatus, setSortedListStatus] = useState(sortedInitialState);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
sortedListStatus,
|
|
20
|
+
setSortedListStatus,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const useFilterQuery = () => {
|
|
25
|
+
const initialQueryValues = {
|
|
26
|
+
order: "",
|
|
27
|
+
filterType: "all",
|
|
28
|
+
filterUsage: "",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const [query, setQuery] = useState(initialQueryValues);
|
|
32
|
+
|
|
33
|
+
const setFilterQuery = (filterValues: any) => {
|
|
34
|
+
const { order, filterType, filterUsage } = filterValues;
|
|
35
|
+
let filterQuery = "";
|
|
36
|
+
|
|
37
|
+
const currentQuery = (pointer: string, values: string) => {
|
|
38
|
+
return filterQuery ? filterQuery.concat(`&${pointer}=${values}`) : `${pointer}=${values}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (order) {
|
|
42
|
+
filterQuery = currentQuery("order", order);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (filterType) {
|
|
46
|
+
filterQuery = currentQuery("filterType", filterType);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (filterUsage) {
|
|
50
|
+
filterQuery = currentQuery("filterUsage", filterUsage);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return filterQuery;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const setFiltersSelection = (pointer: string, filter: string, isAscendent?: boolean) => {
|
|
57
|
+
const { order, filterType, filterUsage } = query;
|
|
58
|
+
const orderMethod = isAscendent ? "asc" : "desc";
|
|
59
|
+
const filterValues = {
|
|
60
|
+
order: pointer === "order" ? `${filter}-${orderMethod}` : order,
|
|
61
|
+
filterType: pointer === "filterType" ? filter : filterType,
|
|
62
|
+
filterUsage: pointer === "filterUsage" ? filter : filterUsage,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
setQuery(filterValues);
|
|
66
|
+
|
|
67
|
+
return filterValues;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
setFiltersSelection,
|
|
72
|
+
setFilterQuery,
|
|
73
|
+
filterValues: query,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { useSortedListStatus, useFilterQuery };
|