@griddo/ax 11.4.24 → 11.5.0
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/__tests__/components/Fields/ImageField/ImageField.test.tsx +52 -34
- package/src/api/folders.tsx +62 -0
- package/src/api/images.tsx +159 -1
- package/src/api/index.tsx +2 -0
- package/src/api/sites.tsx +1 -1
- package/src/components/Fields/ImageField/index.tsx +7 -6
- package/src/components/Fields/Wysiwyg/index.tsx +5 -3
- package/src/components/FileGallery/index.tsx +22 -16
- package/src/components/FileGallery/style.tsx +18 -4
- package/src/components/Gallery/FolderItem/index.tsx +39 -0
- package/src/components/Gallery/FolderItem/style.tsx +31 -0
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +112 -237
- package/src/components/Gallery/GalleryPanel/DetailPanel/style.tsx +77 -61
- package/src/components/Gallery/GalleryPanel/index.tsx +37 -32
- package/src/components/Gallery/GalleryPanel/style.tsx +1 -0
- package/src/components/Gallery/index.tsx +267 -163
- package/src/components/Gallery/style.tsx +200 -135
- package/src/components/Loading/index.tsx +7 -2
- package/src/components/Loading/style.tsx +2 -2
- package/src/components/TableFilters/StateFilter/index.tsx +1 -1
- package/src/containers/FileDrive/actions.tsx +1 -2
- package/src/containers/FileDrive/interfaces.tsx +3 -3
- package/src/containers/Gallery/actions.tsx +359 -13
- package/src/containers/Gallery/constants.tsx +12 -0
- package/src/containers/Gallery/interfaces.tsx +44 -1
- package/src/containers/Gallery/reducer.tsx +27 -3
- package/src/containers/Sites/actions.tsx +2 -2
- package/src/containers/Users/actions.tsx +9 -6
- package/src/helpers/files.tsx +37 -1
- package/src/helpers/index.tsx +3 -1
- package/src/modules/App/Routing/NavMenu/NavItem/NavSubItem/style.tsx +7 -2
- package/src/modules/App/Routing/NavMenu/index.tsx +2 -1
- package/src/modules/FileDrive/FileFilters/SortBy/style.tsx +3 -0
- package/src/modules/FileDrive/FileModal/DetailPanel/UsageContent/index.tsx +1 -1
- package/src/modules/FileDrive/FolderTree/MenuItem/index.tsx +14 -10
- package/src/modules/FileDrive/FolderTree/MenuItem/style.tsx +8 -1
- package/src/modules/FileDrive/FolderTree/MenuList/index.tsx +9 -2
- package/src/modules/FileDrive/index.tsx +45 -28
- package/src/modules/FileDrive/style.tsx +7 -6
- package/src/modules/GlobalEditor/index.tsx +1 -1
- package/src/modules/MediaGallery/Breadcrumb/index.tsx +42 -0
- package/src/modules/MediaGallery/Breadcrumb/style.tsx +18 -0
- package/src/modules/MediaGallery/BulkGridHeader/GridHeader/index.tsx +37 -0
- package/src/modules/MediaGallery/BulkGridHeader/GridHeader/style.tsx +19 -0
- package/src/modules/MediaGallery/BulkGridHeader/index.tsx +35 -0
- package/src/modules/MediaGallery/BulkGridHeader/style.tsx +17 -0
- package/src/modules/MediaGallery/BulkListHeader/TableHeader/index.tsx +46 -0
- package/src/modules/MediaGallery/BulkListHeader/TableHeader/style.tsx +53 -0
- package/src/modules/MediaGallery/BulkListHeader/index.tsx +42 -0
- package/src/modules/MediaGallery/BulkListHeader/style.tsx +17 -0
- package/src/modules/MediaGallery/FolderItem/index.tsx +191 -0
- package/src/modules/MediaGallery/FolderItem/style.tsx +39 -0
- package/src/modules/MediaGallery/FolderTree/MenuItem/index.tsx +87 -0
- package/src/modules/MediaGallery/FolderTree/MenuItem/style.tsx +76 -0
- package/src/modules/MediaGallery/FolderTree/MenuList/index.tsx +34 -0
- package/src/modules/MediaGallery/FolderTree/index.tsx +62 -0
- package/src/modules/MediaGallery/FolderTree/style.tsx +49 -0
- package/src/modules/MediaGallery/GridItem/index.tsx +149 -0
- package/src/modules/MediaGallery/GridItem/style.tsx +74 -0
- package/src/modules/MediaGallery/ImageDragAndDrop/index.tsx +299 -0
- package/src/{components/Gallery/GalleryPanel/GalleryDragAndDrop → modules/MediaGallery/ImageDragAndDrop}/style.tsx +114 -33
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Orientation/style.tsx +2 -1
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/SortBy/style.tsx +3 -0
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Type/style.tsx +1 -0
- package/src/modules/MediaGallery/ImageFilters/Usage/index.tsx +75 -0
- package/src/modules/MediaGallery/ImageFilters/Usage/style.tsx +30 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/Item/index.tsx +35 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/Item/style.tsx +43 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/ItemGroup/index.tsx +44 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/ItemGroup/style.tsx +34 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/index.tsx +233 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/style.tsx +21 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +209 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/style.tsx +81 -0
- package/src/modules/MediaGallery/ImageModal/index.tsx +168 -0
- package/src/modules/MediaGallery/ImageModal/style.tsx +106 -0
- package/src/modules/MediaGallery/ListItem/index.tsx +181 -0
- package/src/modules/MediaGallery/ListItem/style.tsx +100 -0
- package/src/modules/MediaGallery/UploadItem/index.tsx +32 -0
- package/src/modules/MediaGallery/UploadItem/style.tsx +42 -0
- package/src/modules/MediaGallery/atoms.tsx +196 -0
- package/src/{components/Gallery → modules/MediaGallery}/hooks.tsx +10 -4
- package/src/modules/MediaGallery/index.tsx +892 -0
- package/src/modules/MediaGallery/style.tsx +216 -0
- package/src/{components/Gallery → modules/MediaGallery}/utils.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +2 -2
- package/src/routes/multisite.tsx +24 -4
- package/src/routes/site.tsx +24 -4
- package/src/types/files.tsx +98 -0
- package/src/types/index.tsx +33 -91
- package/src/__tests__/components/Gallery/Gallery.test.tsx +0 -559
- package/src/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +0 -54
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +0 -118
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +0 -54
- package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +0 -869
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx +0 -249
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryPanel.test.tsx +0 -55
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +0 -239
- package/src/containers/FileDrive/utils.tsx +0 -37
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Orientation/index.tsx +0 -0
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/SortBy/index.tsx +0 -0
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Type/index.tsx +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { IGetFolderParams, IImage } from "@ax/types";
|
|
3
|
+
import { Button, ErrorToast, IconAction, Toast, Tooltip } from "@ax/components";
|
|
4
|
+
import { useModal, useToast } from "@ax/hooks";
|
|
5
|
+
import ImageDragAndDrop from "../ImageDragAndDrop";
|
|
6
|
+
import { NotSavedModal } from "../atoms";
|
|
7
|
+
import DetailPanel from "./DetailPanel";
|
|
8
|
+
import { IImageFormState } from "..";
|
|
9
|
+
|
|
10
|
+
import * as S from "./style";
|
|
11
|
+
|
|
12
|
+
const ImageModal = (props: IProps) => {
|
|
13
|
+
const {
|
|
14
|
+
image,
|
|
15
|
+
items,
|
|
16
|
+
activeDelete,
|
|
17
|
+
isAllowedToEdit,
|
|
18
|
+
setFile,
|
|
19
|
+
onDelete,
|
|
20
|
+
setFileSelected,
|
|
21
|
+
handleDownload,
|
|
22
|
+
form,
|
|
23
|
+
setForm,
|
|
24
|
+
isDirty,
|
|
25
|
+
resetDirty,
|
|
26
|
+
getParams,
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
const { name, id, site, alt, url } = image;
|
|
30
|
+
|
|
31
|
+
const [isDNDVisible, setDNDVisible] = useState(false);
|
|
32
|
+
const [isArrowPrev, setIsArrowPrev] = useState(false);
|
|
33
|
+
const { isVisible, toggleToast, setIsVisible } = useToast();
|
|
34
|
+
const { isOpen: isSaveOpen, toggleModal: toggleSaveModal } = useModal();
|
|
35
|
+
|
|
36
|
+
const index = items.indexOf(image.id);
|
|
37
|
+
|
|
38
|
+
const validFormats = ["jpeg", "jpg", "png", "svg", "gif"];
|
|
39
|
+
|
|
40
|
+
const handleArrowClick = (isPrev: boolean) => () => {
|
|
41
|
+
if (isDirty) {
|
|
42
|
+
setIsArrowPrev(isPrev);
|
|
43
|
+
toggleSaveModal();
|
|
44
|
+
} else {
|
|
45
|
+
resetDirty();
|
|
46
|
+
changeFile(isPrev);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const changeFile = (isPrev: boolean) => {
|
|
51
|
+
isPrev ? setFile(items[index - 1]) : setFile(items[index + 1]);
|
|
52
|
+
setDNDVisible(false);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleReplace = () => setDNDVisible((state) => !state);
|
|
56
|
+
|
|
57
|
+
const handleUpload = (file: IImage[]) => {
|
|
58
|
+
setFileSelected(file[0]);
|
|
59
|
+
setDNDVisible(false);
|
|
60
|
+
toggleToast();
|
|
61
|
+
resetDirty();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleFileDownload = () => handleDownload(id, name);
|
|
65
|
+
|
|
66
|
+
const toastProps = {
|
|
67
|
+
setIsVisible,
|
|
68
|
+
message: "1 image replaced",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleMainAction = () => {
|
|
72
|
+
toggleSaveModal();
|
|
73
|
+
resetDirty();
|
|
74
|
+
changeFile(isArrowPrev);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const mainModalAction = {
|
|
78
|
+
title: "Yes, discard changes",
|
|
79
|
+
onClick: () => handleMainAction(),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleSaveModal };
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<S.Wrapper>
|
|
87
|
+
<ErrorToast size="l" />
|
|
88
|
+
<S.LeftPanel>
|
|
89
|
+
<IconAction icon="leftArrow" onClick={handleArrowClick(true)} disabled={index === 0} />
|
|
90
|
+
<S.FilePreview>
|
|
91
|
+
<S.ImageWrapper>
|
|
92
|
+
<div>
|
|
93
|
+
<img src={url} alt={alt} />
|
|
94
|
+
</div>
|
|
95
|
+
{isDNDVisible && (
|
|
96
|
+
<S.DragAndDropWrapper>
|
|
97
|
+
<ImageDragAndDrop
|
|
98
|
+
validFormats={validFormats}
|
|
99
|
+
handleUpload={handleUpload}
|
|
100
|
+
inverse={true}
|
|
101
|
+
replaceData={{ fileID: id }}
|
|
102
|
+
siteID={site || "global"}
|
|
103
|
+
getParams={getParams}
|
|
104
|
+
/>
|
|
105
|
+
</S.DragAndDropWrapper>
|
|
106
|
+
)}
|
|
107
|
+
</S.ImageWrapper>
|
|
108
|
+
<S.FileActions>
|
|
109
|
+
{isAllowedToEdit ? (
|
|
110
|
+
<S.ReplaceWrapper>
|
|
111
|
+
<Tooltip content="Replacement image will appear on all linked pages.">
|
|
112
|
+
<Button type="button" buttonStyle="text" icon="image" onClick={handleReplace}>
|
|
113
|
+
Replace
|
|
114
|
+
</Button>
|
|
115
|
+
</Tooltip>
|
|
116
|
+
</S.ReplaceWrapper>
|
|
117
|
+
) : (
|
|
118
|
+
<></>
|
|
119
|
+
)}
|
|
120
|
+
<Button type="button" buttonStyle="text" icon="download" onClick={handleFileDownload}>
|
|
121
|
+
Download
|
|
122
|
+
</Button>
|
|
123
|
+
</S.FileActions>
|
|
124
|
+
</S.FilePreview>
|
|
125
|
+
<IconAction icon="rightArrow" onClick={handleArrowClick(false)} disabled={index === items.length - 1} />
|
|
126
|
+
</S.LeftPanel>
|
|
127
|
+
<DetailPanel
|
|
128
|
+
image={image}
|
|
129
|
+
onDelete={onDelete}
|
|
130
|
+
activeDelete={activeDelete}
|
|
131
|
+
isAllowedToEdit={isAllowedToEdit}
|
|
132
|
+
form={form}
|
|
133
|
+
setForm={setForm}
|
|
134
|
+
isDirty={isDirty}
|
|
135
|
+
resetDirty={resetDirty}
|
|
136
|
+
getParams={getParams}
|
|
137
|
+
/>
|
|
138
|
+
</S.Wrapper>
|
|
139
|
+
{isVisible && <Toast {...toastProps} />}
|
|
140
|
+
{isSaveOpen && (
|
|
141
|
+
<NotSavedModal
|
|
142
|
+
isOpen={isSaveOpen}
|
|
143
|
+
toggleModal={toggleSaveModal}
|
|
144
|
+
mainModalAction={mainModalAction}
|
|
145
|
+
secondaryModalAction={secondaryModalAction}
|
|
146
|
+
/>
|
|
147
|
+
)}
|
|
148
|
+
</>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
interface IProps {
|
|
153
|
+
image: IImage;
|
|
154
|
+
onDelete(fileID: number): Promise<void>;
|
|
155
|
+
items: number[];
|
|
156
|
+
setFile(id: number): void;
|
|
157
|
+
setFileSelected: (file: IImage) => void;
|
|
158
|
+
activeDelete: boolean;
|
|
159
|
+
isAllowedToEdit: boolean;
|
|
160
|
+
handleDownload(fileID: number, fileName: string): void;
|
|
161
|
+
form: IImageFormState;
|
|
162
|
+
setForm(form: IImageFormState): void;
|
|
163
|
+
isDirty: boolean;
|
|
164
|
+
resetDirty(): void;
|
|
165
|
+
getParams(): IGetFolderParams;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default ImageModal;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
const Wrapper = styled.div`
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
const LeftPanel = styled.div`
|
|
10
|
+
position: relative;
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
padding-left: ${(p) => p.theme.spacing.m};
|
|
15
|
+
padding-right: ${(p) => p.theme.spacing.m};
|
|
16
|
+
align-items: center;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const FilePreview = styled.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
align-content: center;
|
|
25
|
+
flex-flow: column wrap;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const ImageWrapper = styled.div`
|
|
29
|
+
position: relative;
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 358px;
|
|
34
|
+
align-items: center;
|
|
35
|
+
img {
|
|
36
|
+
max-height: 358px;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const FileName = styled.div`
|
|
41
|
+
${(p) => p.theme.textStyle.uiL};
|
|
42
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
43
|
+
margin-top: ${(p) => p.theme.spacing.s};
|
|
44
|
+
text-align: center;
|
|
45
|
+
word-break: break-word;
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const FileActions = styled.div`
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
margin-top: ${(p) => p.theme.spacing.m};
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const ReplaceWrapper = styled.div`
|
|
55
|
+
position: relative;
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const ActionMenu = styled.ul`
|
|
59
|
+
padding: 0;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const ActionItem = styled.li`
|
|
64
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
65
|
+
color: ${(p) => p.theme.color.textHighEmphasis};
|
|
66
|
+
padding: ${(p) => p.theme.spacing.xxs} ${(p) => p.theme.spacing.xs};
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
|
|
69
|
+
&:focus {
|
|
70
|
+
background: ${(p) => p.theme.color.overlayFocusPrimary};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background: ${(p) => p.theme.color.overlayHoverPrimary};
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
const TextType = styled.div`
|
|
79
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
80
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
81
|
+
padding-left: ${(p) => p.theme.spacing.xs};
|
|
82
|
+
padding-top: ${(p) => p.theme.spacing.xxs};
|
|
83
|
+
width: 140px;
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
const DragAndDropWrapper = styled.div`
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 0;
|
|
89
|
+
left: 0;
|
|
90
|
+
height: 100%;
|
|
91
|
+
width: 100%;
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
Wrapper,
|
|
96
|
+
FilePreview,
|
|
97
|
+
ImageWrapper,
|
|
98
|
+
FileName,
|
|
99
|
+
LeftPanel,
|
|
100
|
+
FileActions,
|
|
101
|
+
ReplaceWrapper,
|
|
102
|
+
ActionMenu,
|
|
103
|
+
ActionItem,
|
|
104
|
+
TextType,
|
|
105
|
+
DragAndDropWrapper,
|
|
106
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { CheckField, ElementsTooltip, Tooltip } from "@ax/components";
|
|
3
|
+
import { IActionMenuOption, ICheck, IImage } from "@ax/types";
|
|
4
|
+
import { formatBytes, getFileExtension, trimText } from "@ax/helpers";
|
|
5
|
+
import { useModal } from "@ax/hooks";
|
|
6
|
+
|
|
7
|
+
import { DeleteFileModal, MoveItemModal } from "../atoms";
|
|
8
|
+
|
|
9
|
+
import * as S from "./style";
|
|
10
|
+
|
|
11
|
+
const ListItem = (props: IProps) => {
|
|
12
|
+
const {
|
|
13
|
+
image,
|
|
14
|
+
isSelected,
|
|
15
|
+
currentFolderID,
|
|
16
|
+
isAllowedToDelete,
|
|
17
|
+
isAllowedToEdit,
|
|
18
|
+
isAllowedToMove,
|
|
19
|
+
hoverCheck,
|
|
20
|
+
onChange,
|
|
21
|
+
onClick,
|
|
22
|
+
onDelete,
|
|
23
|
+
onMove,
|
|
24
|
+
} = props;
|
|
25
|
+
const { id, tags, name, size, width, height, folderId } = image;
|
|
26
|
+
const imageType = getFileExtension(image.name);
|
|
27
|
+
|
|
28
|
+
const [selectedFolder, setSelectedFolder] = useState<number | null>(currentFolderID || null);
|
|
29
|
+
const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
|
|
30
|
+
const { isOpen: isMoveOpen, toggleModal: toggleMoveModal } = useModal();
|
|
31
|
+
|
|
32
|
+
const handleChange = (value: ICheck) => onChange(value);
|
|
33
|
+
const handleClick = () => onClick(image);
|
|
34
|
+
|
|
35
|
+
let menuOptions: IActionMenuOption[] = [];
|
|
36
|
+
|
|
37
|
+
if (isAllowedToEdit) {
|
|
38
|
+
menuOptions = [
|
|
39
|
+
{
|
|
40
|
+
label: "Edit",
|
|
41
|
+
icon: "edit",
|
|
42
|
+
action: () => onClick(image),
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
if (isAllowedToMove) {
|
|
47
|
+
menuOptions = [
|
|
48
|
+
...menuOptions,
|
|
49
|
+
{
|
|
50
|
+
label: "Move to...",
|
|
51
|
+
icon: "change",
|
|
52
|
+
action: () => toggleMoveModal(),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (isAllowedToDelete) {
|
|
59
|
+
menuOptions = [
|
|
60
|
+
...menuOptions,
|
|
61
|
+
{
|
|
62
|
+
label: "Delete",
|
|
63
|
+
icon: "delete",
|
|
64
|
+
action: () => toggleDeleteModal(),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const handleDeleteFile = () => {
|
|
70
|
+
onDelete(id);
|
|
71
|
+
isDeleteOpen && toggleDeleteModal();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleMoveFile = () => {
|
|
75
|
+
if (folderId !== selectedFolder) {
|
|
76
|
+
onMove(id, selectedFolder || "root");
|
|
77
|
+
isMoveOpen && toggleMoveModal();
|
|
78
|
+
setSelectedFolder(0);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleModalClose = () => {
|
|
83
|
+
setSelectedFolder(0);
|
|
84
|
+
isMoveOpen && toggleMoveModal();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const mainDeleteModalAction = {
|
|
88
|
+
title: "Delete image",
|
|
89
|
+
onClick: () => handleDeleteFile(),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
93
|
+
|
|
94
|
+
const mainMoveModalAction = {
|
|
95
|
+
title: "Move",
|
|
96
|
+
onClick: () => handleMoveFile(),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const secondaryMoveModalAction = { title: "Cancel", onClick: handleModalClose };
|
|
100
|
+
|
|
101
|
+
const FileTitle = () => (name.length > 50 ? <Tooltip content={name}>{trimText(name, 50)}</Tooltip> : <>{name}</>);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
<S.ItemRow role="rowgroup" selected={isSelected}>
|
|
106
|
+
<S.CheckCell role="cell">
|
|
107
|
+
<CheckField name="check" value={id} checked={isSelected || hoverCheck} onChange={handleChange} />
|
|
108
|
+
</S.CheckCell>
|
|
109
|
+
<S.ThumbCell role="cell" onClick={handleClick}>
|
|
110
|
+
<S.ThumbWrapper>
|
|
111
|
+
<img src={image.thumb} alt={image.alt} />
|
|
112
|
+
</S.ThumbWrapper>
|
|
113
|
+
</S.ThumbCell>
|
|
114
|
+
<S.NameCell role="cell" onClick={handleClick} data-testid="file-name-cell">
|
|
115
|
+
<FileTitle />
|
|
116
|
+
</S.NameCell>
|
|
117
|
+
<S.TypeCell role="cell" onClick={handleClick}>
|
|
118
|
+
<S.FileType>{imageType}</S.FileType>
|
|
119
|
+
</S.TypeCell>
|
|
120
|
+
<S.SizeCell role="cell" onClick={handleClick}>
|
|
121
|
+
{formatBytes(size)}
|
|
122
|
+
</S.SizeCell>
|
|
123
|
+
<S.UpdatedCell role="cell" onClick={handleClick}>
|
|
124
|
+
{`${width}x${height}`}
|
|
125
|
+
</S.UpdatedCell>
|
|
126
|
+
<S.TagsCell role="cell" onClick={handleClick}>
|
|
127
|
+
{tags.length > 0 && (
|
|
128
|
+
<ElementsTooltip
|
|
129
|
+
elements={tags}
|
|
130
|
+
elementsPerRow={3}
|
|
131
|
+
defaultElements={3}
|
|
132
|
+
rounded={true}
|
|
133
|
+
defaultColor="#FFBB37"
|
|
134
|
+
prefix="#"
|
|
135
|
+
size="M"
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</S.TagsCell>
|
|
139
|
+
<S.ActionsCell role="cell">
|
|
140
|
+
<S.StyledActionMenu icon="more" options={menuOptions} tooltip="File actions" />
|
|
141
|
+
</S.ActionsCell>
|
|
142
|
+
</S.ItemRow>
|
|
143
|
+
{isDeleteOpen && (
|
|
144
|
+
<DeleteFileModal
|
|
145
|
+
isOpen={isDeleteOpen}
|
|
146
|
+
toggleModal={toggleDeleteModal}
|
|
147
|
+
mainModalAction={mainDeleteModalAction}
|
|
148
|
+
secondaryModalAction={secondaryDeleteModalAction}
|
|
149
|
+
title={name}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
{isMoveOpen && (
|
|
153
|
+
<MoveItemModal
|
|
154
|
+
isOpen={isMoveOpen}
|
|
155
|
+
toggleModal={handleModalClose}
|
|
156
|
+
mainModalAction={mainMoveModalAction}
|
|
157
|
+
secondaryModalAction={secondaryMoveModalAction}
|
|
158
|
+
folder={selectedFolder}
|
|
159
|
+
setFolder={setSelectedFolder}
|
|
160
|
+
hideRoot={!folderId}
|
|
161
|
+
/>
|
|
162
|
+
)}
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
interface IProps {
|
|
168
|
+
image: IImage;
|
|
169
|
+
isSelected: boolean;
|
|
170
|
+
currentFolderID: number | null;
|
|
171
|
+
isAllowedToEdit: boolean;
|
|
172
|
+
isAllowedToDelete: boolean;
|
|
173
|
+
isAllowedToMove: boolean;
|
|
174
|
+
onChange(e: ICheck): void;
|
|
175
|
+
onClick(file: IImage): void;
|
|
176
|
+
onDelete(fileID: number): void;
|
|
177
|
+
onMove(fileID: number, folderID: number | "root"): void;
|
|
178
|
+
hoverCheck: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default ListItem;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { ActionMenu } from "@ax/components";
|
|
3
|
+
import { Cell, Row } from "@ax/components/TableList/TableItem/style";
|
|
4
|
+
|
|
5
|
+
const StyledActionMenu = styled(ActionMenu)`
|
|
6
|
+
opacity: 0;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
const ItemRow = styled(Row)<{ global?: boolean }>`
|
|
10
|
+
&:hover {
|
|
11
|
+
${StyledActionMenu} {
|
|
12
|
+
opacity: 1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const CheckCell = styled(Cell)`
|
|
18
|
+
label {
|
|
19
|
+
margin-bottom: ${(p) => p.theme.spacing.s};
|
|
20
|
+
}
|
|
21
|
+
> div {
|
|
22
|
+
width: ${(p) => p.theme.spacing.s};
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const ThumbCell = styled(Cell)`
|
|
27
|
+
padding: 8px 0;
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const ThumbWrapper = styled.div`
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
border: ${(p) => `1px solid ${p.theme.color.uiLine}`};
|
|
35
|
+
padding: ${(p) => p.theme.spacing.xxs};
|
|
36
|
+
width: ${(p) => p.theme.spacing.l};
|
|
37
|
+
height: ${(p) => p.theme.spacing.l};
|
|
38
|
+
img {
|
|
39
|
+
max-height: 40px;
|
|
40
|
+
width: auto;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const NameCell = styled(Cell)`
|
|
45
|
+
${(p) => p.theme.textStyle.uiL};
|
|
46
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
47
|
+
flex-grow: 1;
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const TypeCell = styled(Cell)`
|
|
51
|
+
flex: 0 0 80px;
|
|
52
|
+
align-items: center;
|
|
53
|
+
text-transform: uppercase;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const FileType = styled.div`
|
|
57
|
+
${(p) => p.theme.textStyle.uiS};
|
|
58
|
+
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
59
|
+
border: ${(p) => `1px solid ${p.theme.color.textMediumEmphasis}`};
|
|
60
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
61
|
+
padding: ${(p) => `0 ${p.theme.spacing.xxs}`};
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const SizeCell = styled(Cell)`
|
|
65
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
66
|
+
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
67
|
+
flex: 0 0 85px;
|
|
68
|
+
align-items: center;
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
const UpdatedCell = styled(Cell)`
|
|
72
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
73
|
+
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
74
|
+
flex: 0 0 120px;
|
|
75
|
+
align-items: center;
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
const TagsCell = styled(Cell)`
|
|
79
|
+
flex: 0 0 300px;
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
const ActionsCell = styled(Cell)`
|
|
83
|
+
flex: 0 0 70px;
|
|
84
|
+
text-align: center;
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
ItemRow,
|
|
89
|
+
StyledActionMenu,
|
|
90
|
+
CheckCell,
|
|
91
|
+
ThumbCell,
|
|
92
|
+
ThumbWrapper,
|
|
93
|
+
NameCell,
|
|
94
|
+
TypeCell,
|
|
95
|
+
FileType,
|
|
96
|
+
SizeCell,
|
|
97
|
+
UpdatedCell,
|
|
98
|
+
TagsCell,
|
|
99
|
+
ActionsCell,
|
|
100
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CheckField, Icon, ProgressBar } from "@ax/components";
|
|
3
|
+
|
|
4
|
+
import * as S from "./style";
|
|
5
|
+
|
|
6
|
+
const UploadItem = (props: IProps) => {
|
|
7
|
+
const { uploadPercentage, grid } = props;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<S.Wrapper grid={grid}>
|
|
11
|
+
{!grid && (
|
|
12
|
+
<S.CheckWrapper role="cell">
|
|
13
|
+
<CheckField name="check" value={0} checked={false} />
|
|
14
|
+
</S.CheckWrapper>
|
|
15
|
+
)}
|
|
16
|
+
<S.IconWrapper>
|
|
17
|
+
<Icon name="page" size="32" />
|
|
18
|
+
</S.IconWrapper>
|
|
19
|
+
<S.BarWrapper>
|
|
20
|
+
<ProgressBar percentage={uploadPercentage} />
|
|
21
|
+
</S.BarWrapper>
|
|
22
|
+
<S.Text>Uploading...</S.Text>
|
|
23
|
+
</S.Wrapper>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface IProps {
|
|
28
|
+
uploadPercentage: number;
|
|
29
|
+
grid: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default UploadItem;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { Cell } from "@ax/components/TableList/TableItem/style";
|
|
3
|
+
|
|
4
|
+
const BarWrapper = styled.div``;
|
|
5
|
+
|
|
6
|
+
const Wrapper = styled.div<{ grid: boolean }>`
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: ${(p) => (p.grid ? "column" : "row")};
|
|
9
|
+
border: ${(p) => `1px dashed ${p.theme.color.interactive01}`};
|
|
10
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
11
|
+
align-items: center;
|
|
12
|
+
padding: ${(p) =>
|
|
13
|
+
p.grid ? p.theme.spacing.m : `${p.theme.spacing.xs} ${p.theme.spacing.xs} ${p.theme.spacing.xs} 0`};
|
|
14
|
+
margin-bottom: ${(p) => (p.grid ? "0" : p.theme.spacing.xs)};
|
|
15
|
+
justify-content: center;
|
|
16
|
+
|
|
17
|
+
${BarWrapper} {
|
|
18
|
+
width: ${(p) => (p.grid ? "150px" : "250px")};
|
|
19
|
+
margin: ${(p) => (p.grid ? `${p.theme.spacing.s} 0` : `0 ${p.theme.spacing.m}`)};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const IconWrapper = styled.div`
|
|
24
|
+
width: 32px;
|
|
25
|
+
height: 32px;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const Text = styled.div`
|
|
29
|
+
${(p) => p.theme.textStyle.fieldLabel};
|
|
30
|
+
color: ${(p) => p.theme.colors.interactive01};
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const CheckWrapper = styled(Cell)`
|
|
34
|
+
label {
|
|
35
|
+
margin-bottom: ${(p) => p.theme.spacing.s};
|
|
36
|
+
}
|
|
37
|
+
> div {
|
|
38
|
+
width: ${(p) => p.theme.spacing.s};
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export { Wrapper, IconWrapper, BarWrapper, Text, CheckWrapper };
|