@webiny/app-file-manager 0.0.0-unstable.e622468070 → 0.0.0-unstable.e6f0dc8ca7
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/app.js +12 -1
- package/app.js.map +1 -1
- package/components/BottomInfoBar/BottomInfoBar.js +0 -10
- package/components/BottomInfoBar/BottomInfoBar.js.map +1 -1
- package/components/BottomInfoBar/SupportedFileTypes.js +5 -2
- package/components/BottomInfoBar/SupportedFileTypes.js.map +1 -1
- package/components/BulkActions/ActionEdit/ActionEditPresenter.test.js +3 -3
- package/components/BulkActions/ActionEdit/ActionEditPresenter.test.js.map +1 -1
- package/components/BulkActions/ActionEdit/domain/Batch.d.ts +3 -24
- package/components/BulkActions/ActionEdit/domain/Field.js +1 -1
- package/components/BulkActions/ActionEdit/domain/Field.js.map +1 -1
- package/components/FileDetails/FileDetails.js +1 -2
- package/components/FileDetails/FileDetails.js.map +1 -1
- package/components/FileDetails/components/ActionButton.d.ts +1 -1
- package/components/FileDetails/components/ActionButton.js.map +1 -1
- package/components/Grid/ActionButton.d.ts +1 -1
- package/components/Grid/ActionButton.js.map +1 -1
- package/components/Grid/File.d.ts +1 -1
- package/components/Grid/File.js.map +1 -1
- package/components/fields/Description.d.ts +2 -0
- package/components/fields/Description.js +25 -0
- package/components/fields/Description.js.map +1 -0
- package/components/fields/index.d.ts +1 -0
- package/components/fields/index.js +1 -0
- package/components/fields/index.js.map +1 -1
- package/domain/permissionsSchema.d.ts +18 -0
- package/domain/permissionsSchema.js +21 -0
- package/domain/permissionsSchema.js.map +1 -0
- package/features/getFile/GetFileGateway.d.ts +12 -0
- package/features/getFile/GetFileGateway.js +24 -0
- package/features/getFile/GetFileGateway.js.map +1 -0
- package/features/getFile/GetFileRepository.d.ts +11 -0
- package/features/getFile/GetFileRepository.js +15 -0
- package/features/getFile/GetFileRepository.js.map +1 -0
- package/features/getFile/GetFileUseCase.d.ts +10 -0
- package/features/getFile/GetFileUseCase.js +32 -0
- package/features/getFile/GetFileUseCase.js.map +1 -0
- package/features/getFile/abstractions.d.ts +38 -0
- package/features/getFile/abstractions.js +15 -0
- package/features/getFile/abstractions.js.map +1 -0
- package/features/getFile/feature.d.ts +3 -0
- package/features/getFile/feature.js +20 -0
- package/features/getFile/feature.js.map +1 -0
- package/features/getFile/index.d.ts +3 -0
- package/features/getFile/index.js +4 -0
- package/features/getFile/index.js.map +1 -0
- package/features/permissions/abstractions.d.ts +17 -0
- package/features/permissions/abstractions.js +5 -0
- package/features/permissions/abstractions.js.map +1 -0
- package/features/permissions/feature.d.ts +14 -0
- package/features/permissions/feature.js +6 -0
- package/features/permissions/feature.js.map +1 -0
- package/features/shared/FILE_FIELDS.d.ts +1 -0
- package/features/shared/FILE_FIELDS.js +3 -0
- package/features/shared/FILE_FIELDS.js.map +1 -0
- package/features/shared/types.d.ts +16 -0
- package/features/shared/types.js.map +1 -0
- package/hooks/useDeleteFile.js +2 -4
- package/hooks/useDeleteFile.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/FileManagerView.js +1 -2
- package/modules/FileManagerRenderer/FileManagerView/FileManagerView.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/LeftSidebar.js +6 -7
- package/modules/FileManagerRenderer/FileManagerView/LeftSidebar.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Grid/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Grid/Thumbnail.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Table/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Table/Thumbnail.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/FileDetails/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/FileDetails/Thumbnail.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/getThumbnailRenderer.js +1 -1
- package/modules/FileManagerRenderer/FileManagerView/getThumbnailRenderer.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/index.js.map +1 -1
- package/modules/FileManagerRenderer/index.js +6 -2
- package/modules/FileManagerRenderer/index.js.map +1 -1
- package/modules/HeadlessCms/fileField.js +2 -2
- package/modules/HeadlessCms/fileField.js.map +1 -1
- package/modules/HeadlessCms/fileRenderer/fileField.js +15 -6
- package/modules/HeadlessCms/fileRenderer/fileField.js.map +1 -1
- package/modules/HeadlessCms/fileRenderer/fileFields.js +11 -5
- package/modules/HeadlessCms/fileRenderer/fileFields.js.map +1 -1
- package/modules/SecurityPermissions.d.ts +2 -0
- package/modules/SecurityPermissions.js +18 -0
- package/modules/SecurityPermissions.js.map +1 -0
- package/modules/Settings/index.js +2 -11
- package/modules/Settings/index.js.map +1 -1
- package/package.json +39 -39
- package/presentation/resolveImageTool/ResolveImageTool.d.ts +40 -0
- package/presentation/resolveImageTool/ResolveImageTool.js +48 -0
- package/presentation/resolveImageTool/ResolveImageTool.js.map +1 -0
- package/presentation/resolveImageTool/feature.d.ts +1 -0
- package/presentation/resolveImageTool/feature.js +10 -0
- package/presentation/resolveImageTool/feature.js.map +1 -0
- package/components/ImageEditor/ImageEditor.d.ts +0 -45
- package/components/ImageEditor/ImageEditor.js +0 -218
- package/components/ImageEditor/ImageEditor.js.map +0 -1
- package/components/ImageEditor/ImageEditorDialog.d.ts +0 -16
- package/components/ImageEditor/ImageEditorDialog.js +0 -53
- package/components/ImageEditor/ImageEditorDialog.js.map +0 -1
- package/components/ImageEditor/index.d.ts +0 -1
- package/components/ImageEditor/index.js +0 -3
- package/components/ImageEditor/index.js.map +0 -1
- package/components/ImageEditor/toolbar/crop.d.ts +0 -4
- package/components/ImageEditor/toolbar/crop.js +0 -67
- package/components/ImageEditor/toolbar/crop.js.map +0 -1
- package/components/ImageEditor/toolbar/filter.d.ts +0 -3
- package/components/ImageEditor/toolbar/filter.js +0 -167
- package/components/ImageEditor/toolbar/filter.js.map +0 -1
- package/components/ImageEditor/toolbar/flip.d.ts +0 -4
- package/components/ImageEditor/toolbar/flip.js +0 -94
- package/components/ImageEditor/toolbar/flip.js.map +0 -1
- package/components/ImageEditor/toolbar/index.d.ts +0 -4
- package/components/ImageEditor/toolbar/index.js +0 -6
- package/components/ImageEditor/toolbar/index.js.map +0 -1
- package/components/ImageEditor/toolbar/rotate.d.ts +0 -4
- package/components/ImageEditor/toolbar/rotate.js +0 -93
- package/components/ImageEditor/toolbar/rotate.js.map +0 -1
- package/components/ImageEditor/toolbar/types.d.ts +0 -32
- package/components/ImageEditor/toolbar/types.js.map +0 -1
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.d.ts +0 -2
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.js +0 -111
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.js.map +0 -1
- package/modules/Settings/plugins/permissionRenderer/FileManagerPermissions.d.ts +0 -14
- package/modules/Settings/plugins/permissionRenderer/FileManagerPermissions.js +0 -205
- package/modules/Settings/plugins/permissionRenderer/FileManagerPermissions.js.map +0 -1
- package/modules/Settings/plugins/permissionRenderer/index.d.ts +0 -3
- package/modules/Settings/plugins/permissionRenderer/index.js +0 -23
- package/modules/Settings/plugins/permissionRenderer/index.js.map +0 -1
- /package/{components/ImageEditor/toolbar → features/shared}/types.js +0 -0
package/app.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { RegisterFeature } from "@webiny/app-admin";
|
|
2
3
|
import { SettingsModule } from "./modules/Settings/index.js";
|
|
3
4
|
import { FileManagerApiProviderModule } from "./modules/FileManagerApiProvider/index.js";
|
|
4
5
|
import { FileManagerRendererModule } from "./modules/FileManagerRenderer/index.js";
|
|
5
6
|
import { HeadlessCmsModule } from "./modules/HeadlessCms/index.js";
|
|
6
7
|
import { EnterpriseModule } from "./modules/Enterprise/index.js";
|
|
8
|
+
import { SecurityPermissions } from "./modules/SecurityPermissions.js";
|
|
9
|
+
import { FmPermissionsFeature } from "./features/permissions/feature.js";
|
|
10
|
+
import { GetFileFeature } from "./features/getFile/feature.js";
|
|
11
|
+
import { ResolveImageToolFeature } from "./presentation/resolveImageTool/feature.js";
|
|
7
12
|
export const FileManager = () => {
|
|
8
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RegisterFeature, {
|
|
14
|
+
feature: FmPermissionsFeature
|
|
15
|
+
}), /*#__PURE__*/React.createElement(RegisterFeature, {
|
|
16
|
+
feature: GetFileFeature
|
|
17
|
+
}), /*#__PURE__*/React.createElement(RegisterFeature, {
|
|
18
|
+
feature: ResolveImageToolFeature
|
|
19
|
+
}), /*#__PURE__*/React.createElement(SettingsModule, null), /*#__PURE__*/React.createElement(FileManagerApiProviderModule, null), /*#__PURE__*/React.createElement(FileManagerRendererModule, null), /*#__PURE__*/React.createElement(HeadlessCmsModule, null), /*#__PURE__*/React.createElement(EnterpriseModule, null), /*#__PURE__*/React.createElement(SecurityPermissions, null));
|
|
9
20
|
};
|
|
10
21
|
|
|
11
22
|
//# sourceMappingURL=app.js.map
|
package/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SettingsModule","FileManagerApiProviderModule","FileManagerRendererModule","HeadlessCmsModule","EnterpriseModule","FileManager","createElement","Fragment"],"sources":["app.tsx"],"sourcesContent":["import React from \"react\";\nimport { SettingsModule } from \"~/modules/Settings/index.js\";\nimport { FileManagerApiProviderModule } from \"~/modules/FileManagerApiProvider/index.js\";\nimport { FileManagerRendererModule } from \"~/modules/FileManagerRenderer/index.js\";\nimport { HeadlessCmsModule } from \"~/modules/HeadlessCms/index.js\";\nimport { EnterpriseModule } from \"~/modules/Enterprise/index.js\";\n\nexport const FileManager = () => {\n return (\n <>\n <SettingsModule />\n <FileManagerApiProviderModule />\n <FileManagerRendererModule />\n <HeadlessCmsModule />\n <EnterpriseModule />\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc;AACvB,SAASC,4BAA4B;AACrC,SAASC,yBAAyB;AAClC,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;
|
|
1
|
+
{"version":3,"names":["React","RegisterFeature","SettingsModule","FileManagerApiProviderModule","FileManagerRendererModule","HeadlessCmsModule","EnterpriseModule","SecurityPermissions","FmPermissionsFeature","GetFileFeature","ResolveImageToolFeature","FileManager","createElement","Fragment","feature"],"sources":["app.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { SettingsModule } from \"~/modules/Settings/index.js\";\nimport { FileManagerApiProviderModule } from \"~/modules/FileManagerApiProvider/index.js\";\nimport { FileManagerRendererModule } from \"~/modules/FileManagerRenderer/index.js\";\nimport { HeadlessCmsModule } from \"~/modules/HeadlessCms/index.js\";\nimport { EnterpriseModule } from \"~/modules/Enterprise/index.js\";\nimport { SecurityPermissions } from \"./modules/SecurityPermissions.js\";\nimport { FmPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { GetFileFeature } from \"~/features/getFile/feature.js\";\nimport { ResolveImageToolFeature } from \"~/presentation/resolveImageTool/feature.js\";\n\nexport const FileManager = () => {\n return (\n <>\n <RegisterFeature feature={FmPermissionsFeature} />\n <RegisterFeature feature={GetFileFeature} />\n <RegisterFeature feature={ResolveImageToolFeature} />\n <SettingsModule />\n <FileManagerApiProviderModule />\n <FileManagerRendererModule />\n <HeadlessCmsModule />\n <EnterpriseModule />\n <SecurityPermissions />\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,cAAc;AACvB,SAASC,4BAA4B;AACrC,SAASC,yBAAyB;AAClC,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAC5B,SAASC,oBAAoB;AAC7B,SAASC,cAAc;AACvB,SAASC,uBAAuB;AAEhC,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,oBACIX,KAAA,CAAAY,aAAA,CAAAZ,KAAA,CAAAa,QAAA,qBACIb,KAAA,CAAAY,aAAA,CAACX,eAAe;IAACa,OAAO,EAAEN;EAAqB,CAAE,CAAC,eAClDR,KAAA,CAAAY,aAAA,CAACX,eAAe;IAACa,OAAO,EAAEL;EAAe,CAAE,CAAC,eAC5CT,KAAA,CAAAY,aAAA,CAACX,eAAe;IAACa,OAAO,EAAEJ;EAAwB,CAAE,CAAC,eACrDV,KAAA,CAAAY,aAAA,CAACV,cAAc,MAAE,CAAC,eAClBF,KAAA,CAAAY,aAAA,CAACT,4BAA4B,MAAE,CAAC,eAChCH,KAAA,CAAAY,aAAA,CAACR,yBAAyB,MAAE,CAAC,eAC7BJ,KAAA,CAAAY,aAAA,CAACP,iBAAiB,MAAE,CAAC,eACrBL,KAAA,CAAAY,aAAA,CAACN,gBAAgB,MAAE,CAAC,eACpBN,KAAA,CAAAY,aAAA,CAACL,mBAAmB,MAAE,CACxB,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import mime from "mime/lite.js";
|
|
3
2
|
import { Separator } from "@webiny/admin-ui";
|
|
4
3
|
import { SupportedFileTypes } from "./SupportedFileTypes.js";
|
|
5
4
|
import ListStatus from "./ListStatus.js";
|
|
6
|
-
mime.define({
|
|
7
|
-
"image/x-icon": ["ico"]
|
|
8
|
-
}, true);
|
|
9
|
-
mime.define({
|
|
10
|
-
"image/jpg": ["jpg"]
|
|
11
|
-
}, true);
|
|
12
|
-
mime.define({
|
|
13
|
-
"image/vnd.microsoft.icon": ["ico"]
|
|
14
|
-
}, true);
|
|
15
5
|
export const BottomInfoBar = props => {
|
|
16
6
|
return /*#__PURE__*/React.createElement("div", {
|
|
17
7
|
className: "bg-neutral-base w-full overflow-hidden z-5"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","Separator","SupportedFileTypes","ListStatus","BottomInfoBar","props","createElement","className"],"sources":["BottomInfoBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { Separator } from \"@webiny/admin-ui\";\n\nimport type { SupportedFileTypesProps } from \"./SupportedFileTypes.js\";\nimport { SupportedFileTypes } from \"./SupportedFileTypes.js\";\nimport type { ListStatusProps } from \"./ListStatus.js\";\nimport ListStatus from \"./ListStatus.js\";\n\ntype BottomInfoBarProps = SupportedFileTypesProps & ListStatusProps;\n\nexport const BottomInfoBar = (props: BottomInfoBarProps) => {\n return (\n <div className=\"bg-neutral-base w-full overflow-hidden z-5\">\n <Separator />\n <div className={\"h-xl px-md py-sm flex items-center justify-between\"}>\n <SupportedFileTypes {...props} />\n <ListStatus {...props} />\n </div>\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,kBAAkB;AAG5C,SAASC,kBAAkB;AAE3B,OAAOC,UAAU;AAIjB,OAAO,MAAMC,aAAa,GAAIC,KAAyB,IAAK;EACxD,oBACIL,KAAA,CAAAM,aAAA;IAAKC,SAAS,EAAC;EAA4C,gBACvDP,KAAA,CAAAM,aAAA,CAACL,SAAS,MAAE,CAAC,eACbD,KAAA,CAAAM,aAAA;IAAKC,SAAS,EAAE;EAAqD,gBACjEP,KAAA,CAAAM,aAAA,CAACJ,kBAAkB,EAAKG,KAAQ,CAAC,eACjCL,KAAA,CAAAM,aAAA,CAACH,UAAU,EAAKE,KAAQ,CACvB,CACJ,CAAC;AAEd,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { Text } from "@webiny/admin-ui";
|
|
3
3
|
import { i18n } from "@webiny/app/i18n/index.js";
|
|
4
|
-
import
|
|
4
|
+
import { Mime } from "mime";
|
|
5
|
+
import vendorTypes from "mime/types/other.js";
|
|
6
|
+
import standardTypes from "mime/types/standard.js";
|
|
7
|
+
const mime = new Mime(standardTypes, vendorTypes);
|
|
5
8
|
mime.define({
|
|
6
9
|
"image/x-icon": ["ico"]
|
|
7
10
|
}, true);
|
|
@@ -9,7 +12,7 @@ mime.define({
|
|
|
9
12
|
"image/jpg": ["jpg"]
|
|
10
13
|
}, true);
|
|
11
14
|
mime.define({
|
|
12
|
-
"
|
|
15
|
+
"application/vnd.microsoft.icon": ["ico"]
|
|
13
16
|
}, true);
|
|
14
17
|
const t = i18n.ns("app-admin/file-manager/components/bottom-info-bar/supported-files");
|
|
15
18
|
const getUniqueFilePlugins = accept => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","Text","i18n","mime","define","t","ns","getUniqueFilePlugins","accept","exts","forEach","item","ext","getExtension","Object","keys","SupportedFileTypes","loading","totalCount","currentCount","getLabel","count","length","createElement","size","as","className","currentCountLabel","String","totalCountLabel","files","join"],"sources":["SupportedFileTypes.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport mime from \"mime/
|
|
1
|
+
{"version":3,"names":["React","useCallback","Text","i18n","Mime","vendorTypes","standardTypes","mime","define","t","ns","getUniqueFilePlugins","accept","exts","forEach","item","ext","getExtension","Object","keys","SupportedFileTypes","loading","totalCount","currentCount","getLabel","count","length","createElement","size","as","className","currentCountLabel","String","totalCountLabel","files","join"],"sources":["SupportedFileTypes.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { Mime } from \"mime\";\nimport vendorTypes from \"mime/types/other.js\";\nimport standardTypes from \"mime/types/standard.js\";\n\nconst mime = new Mime(standardTypes, vendorTypes);\nmime.define({ \"image/x-icon\": [\"ico\"] }, true);\nmime.define({ \"image/jpg\": [\"jpg\"] }, true);\nmime.define({ \"application/vnd.microsoft.icon\": [\"ico\"] }, true);\n\nconst t = i18n.ns(\"app-admin/file-manager/components/bottom-info-bar/supported-files\");\n\nconst getUniqueFilePlugins = (accept: string[]): string[] => {\n const exts: Record<string, boolean> = {};\n accept.forEach(item => {\n const ext = mime.getExtension(item);\n if (!ext) {\n return;\n }\n exts[ext] = true;\n });\n\n return Object.keys(exts);\n};\n\nexport interface SupportedFileTypesProps {\n accept: string[];\n loading: boolean;\n totalCount: number;\n currentCount: number;\n}\n\nexport const SupportedFileTypes = ({\n accept,\n loading,\n totalCount,\n currentCount\n}: SupportedFileTypesProps) => {\n const getLabel = useCallback((count = 0): string => {\n return `${count} ${count === 1 ? \"file\" : \"files\"}`;\n }, []);\n\n if (!accept || loading) {\n return null;\n }\n\n if (accept.length === 0) {\n return (\n <Text size={\"sm\"} as={\"div\"} className={\"text-neutral-strong\"}>\n {t`Showing {currentCountLabel} out of {totalCountLabel} from all file extensions.`({\n currentCountLabel: String(currentCount),\n totalCountLabel: getLabel(totalCount)\n })}\n </Text>\n );\n }\n\n return (\n <Text size={\"sm\"} as={\"div\"} className={\"text-neutral-strong\"}>\n {t`Showing {currentCountLabel} out of {totalCountLabel} from the following file extensions: {files}.`(\n {\n currentCountLabel: String(currentCount),\n totalCountLabel: getLabel(totalCount),\n files: getUniqueFilePlugins(accept).join(\", \")\n }\n )}\n </Text>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,IAAI,QAAQ,2BAA2B;AAChD,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,WAAW,MAAM,qBAAqB;AAC7C,OAAOC,aAAa,MAAM,wBAAwB;AAElD,MAAMC,IAAI,GAAG,IAAIH,IAAI,CAACE,aAAa,EAAED,WAAW,CAAC;AACjDE,IAAI,CAACC,MAAM,CAAC;EAAE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,EAAEC,MAAM,CAACT,YAAY,CAAC;MACvCU,eAAe,EAAET,QAAQ,CAACF,UAAU;IACxC,CAAC,CACC,CAAC;EAEf;EAEA,oBACItB,KAAA,CAAA2B,aAAA,CAACzB,IAAI;IAAC0B,IAAI,EAAE,IAAK;IAACC,EAAE,EAAE,KAAM;IAACC,SAAS,EAAE;EAAsB,GACzDrB,CAAC,mGAAmG,CACjG;IACIsB,iBAAiB,EAAEC,MAAM,CAACT,YAAY,CAAC;IACvCU,eAAe,EAAET,QAAQ,CAACF,UAAU,CAAC;IACrCY,KAAK,EAAEvB,oBAAoB,CAACC,MAAM,CAAC,CAACuB,IAAI,CAAC,IAAI;EACjD,CACJ,CACE,CAAC;AAEf,CAAC","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ describe("ActionEditPresenter", () => {
|
|
|
19
19
|
renderer: {
|
|
20
20
|
name: "ref-inputs"
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
list: true,
|
|
23
23
|
settings: {
|
|
24
24
|
models: [{
|
|
25
25
|
modelId: "any-model"
|
|
@@ -51,7 +51,7 @@ describe("ActionEditPresenter", () => {
|
|
|
51
51
|
name: "required",
|
|
52
52
|
message: "Value is required."
|
|
53
53
|
}],
|
|
54
|
-
|
|
54
|
+
list: false,
|
|
55
55
|
predefinedValues: {
|
|
56
56
|
values: [],
|
|
57
57
|
enabled: false
|
|
@@ -71,7 +71,7 @@ describe("ActionEditPresenter", () => {
|
|
|
71
71
|
},
|
|
72
72
|
listValidation: [],
|
|
73
73
|
validation: [],
|
|
74
|
-
|
|
74
|
+
list: false,
|
|
75
75
|
predefinedValues: {
|
|
76
76
|
values: [],
|
|
77
77
|
enabled: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","it","expect","beforeEach","vi","ActionEditPresenter","extensionFields","id","fieldId","label","type","renderer","name","tags","storageId","
|
|
1
|
+
{"version":3,"names":["describe","it","expect","beforeEach","vi","ActionEditPresenter","extensionFields","id","fieldId","label","type","renderer","name","tags","storageId","list","settings","models","modelId","createFields","listValidation","validation","message","predefinedValues","values","enabled","layout","map","field","fields","presenter","clearAllMocks","load","vm","show","toEqual","currentBatch","operations","operator","value","undefined","operators","raw","editorVm","isOpen","toBe","openEditor","closeEditor"],"sources":["ActionEditPresenter.test.ts"],"sourcesContent":["import { describe, it, expect, beforeEach, vi } from \"vitest\";\nimport { ActionEditPresenter } from \"./ActionEditPresenter.js\";\nimport { type FieldRaw } from \"~/components/BulkActions/ActionEdit/domain/index.js\";\n\ndescribe(\"ActionEditPresenter\", () => {\n const extensionFields = [\n {\n id: \"field1\",\n fieldId: \"field1\",\n label: \"Field 1\",\n type: \"text\",\n renderer: {\n name: \"text-input\"\n },\n tags: [\"$bulk-edit\"],\n storageId: \"text@field1\"\n },\n {\n id: \"field2\",\n fieldId: \"field2\",\n label: \"Field 2\",\n type: \"ref\",\n renderer: {\n name: \"ref-inputs\"\n },\n list: true,\n settings: {\n models: [\n {\n modelId: \"any-model\"\n }\n ]\n },\n tags: [\"$bulk-edit\"],\n storageId: \"ref@field2\"\n },\n {\n id: \"field3\",\n fieldId: \"field3\",\n label: \"Field 3\",\n type: \"number\",\n renderer: {\n name: \"number-input\"\n },\n tags: [],\n storageId: \"number@field3\"\n }\n ];\n\n const createFields = (extensionFields: FieldRaw[]) => {\n return [\n {\n id: \"name\",\n storageId: \"text@name\",\n fieldId: \"name\",\n label: \"Name\",\n type: \"text\",\n settings: {},\n listValidation: [],\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ],\n list: false,\n predefinedValues: {\n values: [],\n enabled: false\n },\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: \"extensions\",\n storageId: \"object@extensions\",\n fieldId: \"extensions\",\n label: \"Extensions\",\n type: \"object\",\n settings: {\n layout: extensionFields.map(field => [field.id]),\n fields: extensionFields\n },\n listValidation: [],\n validation: [],\n list: false,\n predefinedValues: {\n values: [],\n enabled: false\n },\n renderer: {\n name: \"any\"\n }\n }\n ];\n };\n\n let presenter: ActionEditPresenter;\n\n beforeEach(() => {\n vi.clearAllMocks();\n presenter = new ActionEditPresenter();\n });\n\n it(\"should create a presenter and load extensions fields\", () => {\n presenter.load(createFields(extensionFields));\n\n // I should see the bulk edit action\n expect(presenter.vm.show).toEqual(true);\n\n // I should receive a `currentBatch`\n expect(presenter.vm.currentBatch).toEqual({\n operations: [\n {\n field: \"\",\n operator: \"\",\n value: undefined\n }\n ]\n });\n\n // I should receive the `fields` available for bulk edit\n expect(presenter.vm.fields).toEqual([\n {\n label: \"Field 1\",\n value: \"extensions.field1\",\n operators: [\n {\n label: \"Override existing values\",\n value: \"OVERRIDE\"\n },\n {\n label: \"Clear all existing values\",\n value: \"REMOVE\"\n }\n ],\n raw: extensionFields[0]\n },\n {\n label: \"Field 2\",\n value: \"extensions.field2\",\n operators: [\n {\n label: \"Override existing values\",\n value: \"OVERRIDE\"\n },\n {\n label: \"Clear all existing values\",\n value: \"REMOVE\"\n },\n {\n label: \"Append to existing values\",\n value: \"APPEND\"\n }\n ],\n raw: extensionFields[1]\n }\n ]);\n\n // I should receive the editor.vm\n expect(presenter.vm.editorVm).toEqual({\n isOpen: false\n });\n });\n\n it(\"should not show the bulk action if no `extensions` fields are defined\", () => {\n presenter.load(createFields([]));\n\n // The editor action should not be rendered\n expect(presenter.vm.show).toBe(false);\n });\n\n it(\"should open / close the editor\", () => {\n presenter.load(createFields(extensionFields));\n\n // The editor should be closed by default\n expect(presenter.vm.editorVm.isOpen).toBe(false);\n\n // Let's open the editor\n presenter.openEditor();\n expect(presenter.vm.editorVm.isOpen).toBe(true);\n\n // Let's open the editor\n presenter.closeEditor();\n expect(presenter.vm.editorVm.isOpen).toBe(false);\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,UAAU,EAAEC,EAAE,QAAQ,QAAQ;AAC7D,SAASC,mBAAmB;AAG5BL,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EA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C,IAAI,CAAC,IAAI,CAAC;;IAE/C;IACAf,SAAS,CAACiB,WAAW,CAAC,CAAC;IACvB7C,MAAM,CAAC4B,SAAS,CAACG,EAAE,CAACU,QAAQ,CAACC,MAAM,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;EACpD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,33 +6,12 @@ export declare const batchValidationSchema: zod.ZodObject<{
|
|
|
6
6
|
operations: zod.ZodArray<zod.ZodObject<{
|
|
7
7
|
field: zod.ZodString;
|
|
8
8
|
operator: zod.ZodString;
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
operator: string;
|
|
12
|
-
}, {
|
|
13
|
-
field: string;
|
|
14
|
-
operator: string;
|
|
15
|
-
}>, "many">;
|
|
16
|
-
}, "strip", zod.ZodTypeAny, {
|
|
17
|
-
operations: {
|
|
18
|
-
field: string;
|
|
19
|
-
operator: string;
|
|
20
|
-
}[];
|
|
21
|
-
}, {
|
|
22
|
-
operations: {
|
|
23
|
-
field: string;
|
|
24
|
-
operator: string;
|
|
25
|
-
}[];
|
|
26
|
-
}>;
|
|
9
|
+
}, zod.core.$strip>>;
|
|
10
|
+
}, zod.core.$strip>;
|
|
27
11
|
export declare class Batch {
|
|
28
12
|
operations: Operation[];
|
|
29
13
|
static createEmpty(): Batch;
|
|
30
|
-
static validate(data: BatchDTO): zod.
|
|
31
|
-
operations: {
|
|
32
|
-
field: string;
|
|
33
|
-
operator: string;
|
|
34
|
-
}[];
|
|
35
|
-
}, {
|
|
14
|
+
static validate(data: BatchDTO): zod.ZodSafeParseResult<{
|
|
36
15
|
operations: {
|
|
37
16
|
field: string;
|
|
38
17
|
operator: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OperatorType","Field","createFromRaw","field","label","value","fieldId","operators","Operator","createFromField","constructor","renderer","raw","createFrom","rawData","OVERRIDE","REMOVE","
|
|
1
|
+
{"version":3,"names":["OperatorType","Field","createFromRaw","field","label","value","fieldId","operators","Operator","createFromField","constructor","renderer","raw","createFrom","rawData","OVERRIDE","REMOVE","list","push","APPEND","map","operator"],"sources":["Field.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/app-headless-cms-common/types/model.js\";\n\nexport type FieldRaw = CmsModelField;\n\nexport enum OperatorType {\n OVERRIDE = \"OVERRIDE\",\n APPEND = \"APPEND\",\n REMOVE = \"REMOVE\"\n}\n\nexport interface FieldDTO {\n label: string;\n value: string;\n operators: OperatorDTO[];\n raw: FieldRaw;\n}\n\nexport class Field {\n public readonly label: string;\n public readonly value: string;\n public readonly operators: Operator[];\n public readonly raw: FieldRaw;\n\n static createFromRaw(field: FieldRaw) {\n const label = field.label;\n const value = field.fieldId;\n const operators = Operator.createFromField(field);\n return new Field(label, value, operators, field);\n }\n\n private constructor(label: string, value: string, operators: Operator[], renderer: FieldRaw) {\n this.label = label;\n this.value = value;\n this.operators = operators;\n this.raw = renderer;\n }\n}\n\nexport interface OperatorDTO {\n label: string;\n value: string;\n}\n\nexport class Operator {\n public readonly label: string;\n public readonly value: string;\n\n static createFrom(rawData: OperatorDTO) {\n return new Operator(rawData.label, rawData.value);\n }\n\n static createFromField(field: CmsModelField) {\n const operators = [\n {\n label: \"Override existing values\",\n value: OperatorType.OVERRIDE\n },\n {\n label: \"Clear all existing values\",\n value: OperatorType.REMOVE\n }\n ];\n\n if (field.list) {\n operators.push({\n label: \"Append to existing values\",\n value: OperatorType.APPEND\n });\n }\n\n return operators.map(operator => this.createFrom(operator));\n }\n\n private constructor(label: string, value: string) {\n this.label = label;\n this.value = value;\n }\n}\n"],"mappings":"AAIA,WAAYA,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AAaxB,OAAO,MAAMC,KAAK,CAAC;EAMf,OAAOC,aAAaA,CAACC,KAAe,EAAE;IAClC,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK;IACzB,MAAMC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
|
|
|
1
1
|
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import noop from "lodash/noop.js";
|
|
3
|
-
|
|
4
|
-
import { useHotkeys } from "react-hotkeyz";
|
|
3
|
+
import { useHotkeys } from "@webiny/app-admin";
|
|
5
4
|
import { Drawer, Grid, OverlayLoader, Tabs } from "@webiny/admin-ui";
|
|
6
5
|
import { Form } from "@webiny/form";
|
|
7
6
|
import { prepareFormData } from "@webiny/app-headless-cms-common";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useMemo","useRef","noop","useHotkeys","Drawer","Grid","OverlayLoader","Tabs","Form","prepareFormData","FileDetailsProvider","Preview","Actions","Content","Extensions","Description","useFileModel","useFileManagerViewConfig","FileProvider","FileDetailsInner","file","onForm","props","formRef","createRef","current","fileModel","fileDetails","leftPanel","rightPanel","width","split","extensionFields","fields","find","field","fieldId","settings","onSubmit","data","fileData","basicFieldsElement","createElement","map","Column","span","key","name","element","extensionFieldsElement","length","model","ref","Panel","flex","parseFloat","className","groupFields","size","spacing","separator","tabs","Tab","value","trigger","content","FileDetails","open","onClose","onSave","loading","onSetFile","zIndex","disabled","keys","esc","drawerWidth","title","description","modal","bodyPadding","headerSeparator","footerSeparator","actions","Fragment","CancelButton","text","ConfirmButton","onClick","submit","hideFileDetails","form"],"sources":["FileDetails.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport noop from \"lodash/noop.js\";\n// @ts-expect-error This package has no types.\nimport { useHotkeys } from \"react-hotkeyz\";\nimport { Drawer, Grid, OverlayLoader, Tabs } from \"@webiny/admin-ui\";\nimport type { FileItem } from \"~/types.js\";\nimport type { FormAPI, FormOnSubmit } from \"@webiny/form\";\nimport { Form } from \"@webiny/form\";\nimport { prepareFormData } from \"@webiny/app-headless-cms-common\";\nimport { FileDetailsProvider } from \"~/components/FileDetails/FileDetailsProvider.js\";\nimport { Preview } from \"./components/Preview.js\";\nimport { Actions } from \"./components/Actions.js\";\nimport { Content } from \"./components/Content.js\";\nimport { Extensions } from \"./components/Extensions.js\";\nimport { Description } from \"./components/Description.js\";\nimport { useFileModel } from \"~/hooks/useFileModel.js\";\nimport { useFileManagerViewConfig } from \"~/index.js\";\nimport { FileProvider } from \"~/contexts/FileProvider.js\";\n\ninterface FileDetailsInnerProps {\n file: FileItem;\n onForm: (form: FormAPI) => void;\n onClose: () => void;\n onSubmit: (fileData: FileItem) => void;\n}\n\nconst FileDetailsInner = ({ file, onForm, ...props }: FileDetailsInnerProps) => {\n const formRef = React.createRef<FormAPI>();\n\n useEffect(() => {\n if (formRef.current) {\n onForm(formRef.current);\n }\n }, []);\n\n const fileModel = useFileModel();\n const { fileDetails } = useFileManagerViewConfig();\n\n const [, leftPanel = \"1\", rightPanel = \"1\"] = fileDetails.width.split(\",\");\n\n const extensionFields = useMemo(() => {\n const fields = fileModel.fields.find(field => field.fieldId === \"extensions\");\n if (!fields?.settings?.fields) {\n return [];\n }\n return fields?.settings?.fields || [];\n }, [fileModel]);\n\n const onSubmit: FormOnSubmit<FileItem> = async data => {\n const fileData = prepareFormData(data, fileModel.fields);\n props.onSubmit({ ...file, ...fileData });\n };\n\n const basicFieldsElement = (\n <Grid>\n {fileDetails.fields.map(field => (\n <Grid.Column span={12} key={field.name}>\n {field.element}\n </Grid.Column>\n ))}\n </Grid>\n );\n\n const extensionFieldsElement =\n extensionFields.length > 0 ? <Extensions model={fileModel} /> : null;\n\n return (\n <Form data={file} onSubmit={onSubmit} ref={formRef}>\n {() => (\n <Content>\n <Content.Panel flex={parseFloat(leftPanel)}>\n <div className={\"flex flex-col justify-between gap-md h-full px-lg py-md\"}>\n <Actions />\n <Preview />\n </div>\n </Content.Panel>\n <Content.Panel flex={parseFloat(rightPanel)}>\n {fileDetails.groupFields ? (\n <Tabs\n size={\"md\"}\n spacing={\"lg\"}\n separator={true}\n tabs={[\n <Tabs.Tab\n key={\"basic-details\"}\n value={\"basic-details\"}\n trigger={\"Basic details\"}\n content={basicFieldsElement}\n />,\n <Tabs.Tab\n key={\"advanced-details\"}\n value={\"advanced-details\"}\n trigger={\"Advanced details\"}\n content={extensionFieldsElement}\n />\n ]}\n />\n ) : (\n <div className={\"p-lg\"}>\n {basicFieldsElement}\n <div className={\"mt-lg\"}>{extensionFieldsElement}</div>\n </div>\n )}\n </Content.Panel>\n </Content>\n )}\n </Form>\n );\n};\n\nexport interface FileDetailsProps {\n file?: FileItem;\n open: boolean;\n loading: string | null;\n onClose: () => void;\n onSave: (file: FileItem) => void;\n onSetFile?: (file: FileItem) => void;\n}\n\nexport const FileDetails = ({\n open,\n onClose,\n onSave,\n loading,\n file,\n onSetFile = noop\n}: FileDetailsProps) => {\n useHotkeys({\n zIndex: 50,\n disabled: !open,\n keys: {\n esc: onClose\n }\n });\n\n const { fileDetails } = useFileManagerViewConfig();\n\n const drawerWidth = fileDetails.width.split(\",\")[0];\n\n const formRef = useRef<FormAPI | null>(null);\n\n if (!file) {\n return null;\n }\n\n return (\n <FileProvider file={file}>\n <Drawer\n title={file.name}\n description={<Description />}\n width={drawerWidth}\n open={open}\n modal={true}\n bodyPadding={false}\n headerSeparator={true}\n footerSeparator={true}\n onClose={onClose}\n data-testid={\"fm.file-details.drawer\"}\n actions={\n <>\n <Drawer.CancelButton text={\"Cancel\"} />\n <Drawer.ConfirmButton\n text={\"Update\"}\n onClick={() => formRef.current?.submit()}\n />\n </>\n }\n >\n {loading && <OverlayLoader text={loading} />}\n <FileDetailsProvider hideFileDetails={onClose} onSetFile={onSetFile}>\n <FileDetailsInner\n onForm={form => {\n formRef.current = form;\n }}\n file={file}\n onClose={onClose}\n onSubmit={onSave}\n />\n </FileDetailsProvider>\n </Drawer>\n </FileProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACzD,OAAOC,IAAI,MAAM,gBAAgB;AACjC;AACA,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,MAAM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keys","Drawer","Grid","OverlayLoader","Tabs","Form","prepareFormData","FileDetailsProvider","Preview","Actions","Content","Extensions","Description","useFileModel","useFileManagerViewConfig","FileProvider","FileDetailsInner","file","onForm","props","formRef","createRef","current","fileModel","fileDetails","leftPanel","rightPanel","width","split","extensionFields","fields","find","field","fieldId","settings","onSubmit","data","fileData","basicFieldsElement","createElement","map","Column","span","key","name","element","extensionFieldsElement","length","model","ref","Panel","flex","parseFloat","className","groupFields","size","spacing","separator","tabs","Tab","value","trigger","content","FileDetails","open","onClose","onSave","loading","onSetFile","zIndex","disabled","keys","esc","drawerWidth","title","description","modal","bodyPadding","headerSeparator","footerSeparator","actions","Fragment","CancelButton","text","ConfirmButton","onClick","submit","hideFileDetails","form"],"sources":["FileDetails.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport noop from \"lodash/noop.js\";\nimport { useHotkeys } from \"@webiny/app-admin\";\nimport { Drawer, Grid, OverlayLoader, Tabs } from \"@webiny/admin-ui\";\nimport type { FileItem } from \"~/types.js\";\nimport type { FormAPI, FormOnSubmit } from \"@webiny/form\";\nimport { Form } from \"@webiny/form\";\nimport { prepareFormData } from \"@webiny/app-headless-cms-common\";\nimport { FileDetailsProvider } from \"~/components/FileDetails/FileDetailsProvider.js\";\nimport { Preview } from \"./components/Preview.js\";\nimport { Actions } from \"./components/Actions.js\";\nimport { Content } from \"./components/Content.js\";\nimport { Extensions } from \"./components/Extensions.js\";\nimport { Description } from \"./components/Description.js\";\nimport { useFileModel } from \"~/hooks/useFileModel.js\";\nimport { useFileManagerViewConfig } from \"~/index.js\";\nimport { FileProvider } from \"~/contexts/FileProvider.js\";\n\ninterface FileDetailsInnerProps {\n file: FileItem;\n onForm: (form: FormAPI) => void;\n onClose: () => void;\n onSubmit: (fileData: FileItem) => void;\n}\n\nconst FileDetailsInner = ({ file, onForm, ...props }: FileDetailsInnerProps) => {\n const formRef = React.createRef<FormAPI>();\n\n useEffect(() => {\n if (formRef.current) {\n onForm(formRef.current);\n }\n }, []);\n\n const fileModel = useFileModel();\n const { fileDetails } = useFileManagerViewConfig();\n\n const [, leftPanel = \"1\", rightPanel = \"1\"] = fileDetails.width.split(\",\");\n\n const extensionFields = useMemo(() => {\n const fields = fileModel.fields.find(field => field.fieldId === \"extensions\");\n if (!fields?.settings?.fields) {\n return [];\n }\n return fields?.settings?.fields || [];\n }, [fileModel]);\n\n const onSubmit: FormOnSubmit<FileItem> = async data => {\n const fileData = prepareFormData(data, fileModel.fields);\n props.onSubmit({ ...file, ...fileData });\n };\n\n const basicFieldsElement = (\n <Grid>\n {fileDetails.fields.map(field => (\n <Grid.Column span={12} key={field.name}>\n {field.element}\n </Grid.Column>\n ))}\n </Grid>\n );\n\n const extensionFieldsElement =\n extensionFields.length > 0 ? <Extensions model={fileModel} /> : null;\n\n return (\n <Form data={file} onSubmit={onSubmit} ref={formRef}>\n {() => (\n <Content>\n <Content.Panel flex={parseFloat(leftPanel)}>\n <div className={\"flex flex-col justify-between gap-md h-full px-lg py-md\"}>\n <Actions />\n <Preview />\n </div>\n </Content.Panel>\n <Content.Panel flex={parseFloat(rightPanel)}>\n {fileDetails.groupFields ? (\n <Tabs\n size={\"md\"}\n spacing={\"lg\"}\n separator={true}\n tabs={[\n <Tabs.Tab\n key={\"basic-details\"}\n value={\"basic-details\"}\n trigger={\"Basic details\"}\n content={basicFieldsElement}\n />,\n <Tabs.Tab\n key={\"advanced-details\"}\n value={\"advanced-details\"}\n trigger={\"Advanced details\"}\n content={extensionFieldsElement}\n />\n ]}\n />\n ) : (\n <div className={\"p-lg\"}>\n {basicFieldsElement}\n <div className={\"mt-lg\"}>{extensionFieldsElement}</div>\n </div>\n )}\n </Content.Panel>\n </Content>\n )}\n </Form>\n );\n};\n\nexport interface FileDetailsProps {\n file?: FileItem;\n open: boolean;\n loading: string | null;\n onClose: () => void;\n onSave: (file: FileItem) => void;\n onSetFile?: (file: FileItem) => void;\n}\n\nexport const FileDetails = ({\n open,\n onClose,\n onSave,\n loading,\n file,\n onSetFile = noop\n}: FileDetailsProps) => {\n useHotkeys({\n zIndex: 50,\n disabled: !open,\n keys: {\n esc: onClose\n }\n });\n\n const { fileDetails } = useFileManagerViewConfig();\n\n const drawerWidth = fileDetails.width.split(\",\")[0];\n\n const formRef = useRef<FormAPI | null>(null);\n\n if (!file) {\n return null;\n }\n\n return (\n <FileProvider file={file}>\n <Drawer\n title={file.name}\n description={<Description />}\n width={drawerWidth}\n open={open}\n modal={true}\n bodyPadding={false}\n headerSeparator={true}\n footerSeparator={true}\n onClose={onClose}\n data-testid={\"fm.file-details.drawer\"}\n actions={\n <>\n <Drawer.CancelButton text={\"Cancel\"} />\n <Drawer.ConfirmButton\n text={\"Update\"}\n onClick={() => formRef.current?.submit()}\n />\n </>\n }\n >\n {loading && <OverlayLoader text={loading} />}\n <FileDetailsProvider hideFileDetails={onClose} onSetFile={onSetFile}>\n <FileDetailsInner\n onForm={form => {\n formRef.current = form;\n }}\n file={file}\n onClose={onClose}\n onSubmit={onSave}\n />\n </FileDetailsProvider>\n </Drawer>\n </FileProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACzD,OAAOC,IAAI,MAAM,gBAAgB;AACjC,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,MAAM,EAAEC,IAAI,EAAEC,aAAa,EAAEC,IAAI,QAAQ,kBAAkB;AAGpE,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,mBAAmB;AAC5B,SAASC,OAAO;AAChB,SAASC,OAAO;AAChB,SAASC,OAAO;AAChB,SAASC,UAAU;AACnB,SAASC,WAAW;AACpB,SAASC,YAAY;AACrB,SAASC,wBAAwB;AACjC,SAASC,YAAY;AASrB,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,MAAM;EAAE,GAAGC;AAA6B,CAAC,KAAK;EA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AO,eACHrF,KAAA,CAAA4C,aAAA,CAAA5C,KAAA,CAAAsF,QAAA,qBACItF,KAAA,CAAA4C,aAAA,CAACtC,MAAM,CAACiF,YAAY;MAACC,IAAI,EAAE;IAAS,CAAE,CAAC,eACvCxF,KAAA,CAAA4C,aAAA,CAACtC,MAAM,CAACmF,aAAa;MACjBD,IAAI,EAAE,QAAS;MACfE,OAAO,EAAEA,CAAA,KAAMjE,OAAO,CAACE,OAAO,EAAEgE,MAAM,CAAC;IAAE,CAC5C,CACH;EACL,GAEAnB,OAAO,iBAAIxE,KAAA,CAAA4C,aAAA,CAACpC,aAAa;IAACgF,IAAI,EAAEhB;EAAQ,CAAE,CAAC,eAC5CxE,KAAA,CAAA4C,aAAA,CAAChC,mBAAmB;IAACgF,eAAe,EAAEtB,OAAQ;IAACG,SAAS,EAAEA;EAAU,gBAChEzE,KAAA,CAAA4C,aAAA,CAACvB,gBAAgB;IACbE,MAAM,EAAEsE,IAAI,IAAI;MACZpE,OAAO,CAACE,OAAO,GAAGkE,IAAI;IAC1B,CAAE;IACFvE,IAAI,EAAEA,IAAK;IACXgD,OAAO,EAAEA,OAAQ;IACjB9B,QAAQ,EAAE+B;EAAO,CACpB,CACgB,CACjB,CACE,CAAC;AAEvB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Button","ActionButton","label","icon","onAction","disabled","className","props","createElement","text","onClick","containerClassName","variant","size"],"sources":["ActionButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@webiny/admin-ui\";\n\nexport interface ActionButtonProps {\n label: string;\n icon: JSX.Element;\n onAction: () => void;\n \"data-testid\"?: string;\n disabled?: boolean;\n className?: string;\n}\n\nexport const ActionButton = ({\n label,\n icon,\n onAction,\n disabled,\n className,\n ...props\n}: ActionButtonProps) => {\n return (\n <Button\n text={label}\n icon={icon}\n onClick={onAction}\n disabled={disabled}\n data-testid={props[\"data-testid\"]}\n containerClassName={className}\n variant={\"ghost\"}\n size={\"sm\"}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,kBAAkB;AAWzC,OAAO,MAAMC,YAAY,GAAGA,CAAC;EACzBC,KAAK;EACLC,IAAI;EACJC,QAAQ;EACRC,QAAQ;EACRC,SAAS;EACT,GAAGC;AACY,CAAC,KAAK;EACrB,oBACIR,KAAA,CAAAS,aAAA,CAACR,MAAM;IACHS,IAAI,EAAEP,KAAM;IACZC,IAAI,EAAEA,IAAK;IACXO,OAAO,EAAEN,QAAS;IAClBC,QAAQ,EAAEA,QAAS;IACnB,eAAaE,KAAK,CAAC,aAAa,CAAE;IAClCI,kBAAkB,EAAEL,SAAU;IAC9BM,OAAO,EAAE,OAAQ;IACjBC,IAAI,EAAE;EAAK,CACd,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","Button","ActionButton","label","icon","onAction","disabled","className","props","createElement","text","onClick","containerClassName","variant","size"],"sources":["ActionButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button } from \"@webiny/admin-ui\";\n\nexport interface ActionButtonProps {\n label: string;\n icon: React.JSX.Element;\n onAction: () => void;\n \"data-testid\"?: string;\n disabled?: boolean;\n className?: string;\n}\n\nexport const ActionButton = ({\n label,\n icon,\n onAction,\n disabled,\n className,\n ...props\n}: ActionButtonProps) => {\n return (\n <Button\n text={label}\n icon={icon}\n onClick={onAction}\n disabled={disabled}\n data-testid={props[\"data-testid\"]}\n containerClassName={className}\n variant={\"ghost\"}\n size={\"sm\"}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,kBAAkB;AAWzC,OAAO,MAAMC,YAAY,GAAGA,CAAC;EACzBC,KAAK;EACLC,IAAI;EACJC,QAAQ;EACRC,QAAQ;EACRC,SAAS;EACT,GAAGC;AACY,CAAC,KAAK;EACrB,oBACIR,KAAA,CAAAS,aAAA,CAACR,MAAM;IACHS,IAAI,EAAEP,KAAM;IACZC,IAAI,EAAEA,IAAK;IACXO,OAAO,EAAEN,QAAS;IAClBC,QAAQ,EAAEA,QAAS;IACnB,eAAaE,KAAK,CAAC,aAAa,CAAE;IAClCI,kBAAkB,EAAEL,SAAU;IAC9BM,OAAO,EAAE,OAAQ;IACjBC,IAAI,EAAE;EAAK,CACd,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","IconButton","Tooltip","ActionButton","icon","label","onAction","disabled","props","onClick","event","stopPropagation","createElement","content","trigger","variant","size"],"sources":["ActionButton.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { IconButton, Tooltip } from \"@webiny/admin-ui\";\n\nexport interface ActionButtonProps {\n icon: JSX.Element;\n label?: string;\n onAction: () => void;\n \"data-testid\"?: string;\n disabled?: boolean;\n}\n\nexport const ActionButton = ({ icon, label, onAction, disabled, ...props }: ActionButtonProps) => {\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n // Prevent the click event from propagating to the grid item component.\n event.stopPropagation();\n onAction && onAction();\n },\n [onAction]\n );\n\n return (\n <Tooltip\n content={label ?? \"Custom action\"}\n trigger={\n <IconButton\n variant={\"tertiary\"}\n size={\"sm\"}\n icon={icon}\n onClick={onClick}\n disabled={disabled}\n data-testid={props[\"data-testid\"]}\n />\n }\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,UAAU,EAAEC,OAAO,QAAQ,kBAAkB;AAUtD,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAAEC,IAAI;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAyB,CAAC,KAAK;EAC9F,MAAMC,OAAO,GAAGT,WAAW,CACtBU,KAA0C,IAAK;IAC5C;IACAA,KAAK,CAACC,eAAe,CAAC,CAAC;IACvBL,QAAQ,IAAIA,QAAQ,CAAC,CAAC;EAC1B,CAAC,EACD,CAACA,QAAQ,CACb,CAAC;EAED,oBACIP,KAAA,CAAAa,aAAA,CAACV,OAAO;IACJW,OAAO,EAAER,KAAK,IAAI,eAAgB;IAClCS,OAAO,eACHf,KAAA,CAAAa,aAAA,CAACX,UAAU;MACPc,OAAO,EAAE,UAAW;MACpBC,IAAI,EAAE,IAAK;MACXZ,IAAI,EAAEA,IAAK;MACXK,OAAO,EAAEA,OAAQ;MACjBF,QAAQ,EAAEA,QAAS;MACnB,eAAaC,KAAK,CAAC,aAAa;IAAE,CACrC;EACJ,CACJ,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useCallback","IconButton","Tooltip","ActionButton","icon","label","onAction","disabled","props","onClick","event","stopPropagation","createElement","content","trigger","variant","size"],"sources":["ActionButton.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { IconButton, Tooltip } from \"@webiny/admin-ui\";\n\nexport interface ActionButtonProps {\n icon: React.JSX.Element;\n label?: string;\n onAction: () => void;\n \"data-testid\"?: string;\n disabled?: boolean;\n}\n\nexport const ActionButton = ({ icon, label, onAction, disabled, ...props }: ActionButtonProps) => {\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n // Prevent the click event from propagating to the grid item component.\n event.stopPropagation();\n onAction && onAction();\n },\n [onAction]\n );\n\n return (\n <Tooltip\n content={label ?? \"Custom action\"}\n trigger={\n <IconButton\n variant={\"tertiary\"}\n size={\"sm\"}\n icon={icon}\n onClick={onClick}\n disabled={disabled}\n data-testid={props[\"data-testid\"]}\n />\n }\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,UAAU,EAAEC,OAAO,QAAQ,kBAAkB;AAUtD,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAAEC,IAAI;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAyB,CAAC,KAAK;EAC9F,MAAMC,OAAO,GAAGT,WAAW,CACtBU,KAA0C,IAAK;IAC5C;IACAA,KAAK,CAACC,eAAe,CAAC,CAAC;IACvBL,QAAQ,IAAIA,QAAQ,CAAC,CAAC;EAC1B,CAAC,EACD,CAACA,QAAQ,CACb,CAAC;EAED,oBACIP,KAAA,CAAAa,aAAA,CAACV,OAAO;IACJW,OAAO,EAAER,KAAK,IAAI,eAAgB;IAClCS,OAAO,eACHf,KAAA,CAAAa,aAAA,CAACX,UAAU;MACPc,OAAO,EAAE,UAAW;MACpBC,IAAI,EAAE,IAAK;MACXZ,IAAI,EAAEA,IAAK;MACXK,OAAO,EAAEA,OAAQ;MACjBF,QAAQ,EAAEA,QAAS;MACnB,eAAaC,KAAK,CAAC,aAAa;IAAE,CACrC;EACJ,CACJ,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ import type { FileItem } from "../../types.js";
|
|
|
3
3
|
export interface FileProps {
|
|
4
4
|
file: FileItem;
|
|
5
5
|
selected: boolean;
|
|
6
|
-
fileBody?: JSX.Element;
|
|
6
|
+
fileBody?: React.JSX.Element;
|
|
7
7
|
onSelect?: (event?: React.MouseEvent) => void;
|
|
8
8
|
onClick?: (event?: React.MouseEvent) => void;
|
|
9
9
|
multiple?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","LazyLoad","makeDecoratable","Text","TimeAgo","cn","CheckboxPrimitive","useFileManagerViewConfig","DefaultFileControls","onSelect","selected","browser","itemActions","grid","createElement","className","onClick","checked","onChange","map","action","key","name","element","DefaultFileBody","children","height","offset","DefaultFileLabel","file","size","as","type","datetime","createdOn","File","fileBody","id"],"sources":["File.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport LazyLoad from \"react-lazy-load\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { Text, TimeAgo, cn, CheckboxPrimitive } from \"@webiny/admin-ui\";\nimport { useFileManagerViewConfig } from \"~/modules/FileManagerRenderer/FileManagerView/FileManagerViewConfig.js\";\nimport type { FileItem } from \"~/types.js\";\n\nexport interface FileProps {\n file: FileItem;\n selected: boolean;\n fileBody?: JSX.Element;\n onSelect?: (event?: React.MouseEvent) => void;\n onClick?: (event?: React.MouseEvent) => void;\n multiple?: boolean;\n children: React.ReactNode;\n}\n\nexport type DefaultFileControlsProps = Pick<FileProps, \"selected\" | \"onSelect\">;\n\nconst DefaultFileControls = ({ onSelect, selected }: DefaultFileControlsProps) => {\n const { browser } = useFileManagerViewConfig();\n const { itemActions } = browser.grid;\n\n return (\n <>\n {onSelect ? (\n <div\n className={cn([\n \"p-xs rounded-md\",\n \"bg-neutral-base/30\",\n \"absolute top-sm left-sm\",\n selected ? \"visible\" : \"invisible group-hover:visible\"\n ])}\n >\n <CheckboxPrimitive\n onClick={onSelect}\n checked={selected}\n onChange={() => void 0}\n />\n </div>\n ) : null}\n <div\n className={cn([\n \"invisible group-hover:visible\",\n \"flex items-center gap-xxs\",\n \"p-xs\",\n \"absolute top-xs-plus right-xs-plus\"\n ])}\n >\n {itemActions.map(action => {\n return <Fragment key={action.name}>{action.element}</Fragment>;\n })}\n </div>\n </>\n );\n};\n\nexport type DefaultFileBodyProps = Pick<FileProps, \"selected\" | \"onSelect\" | \"children\">;\n\nconst DefaultFileBody = ({ selected, onSelect, children }: DefaultFileBodyProps) => {\n return (\n <div\n onClick={onSelect}\n className={cn([\"relative\", onSelect ? \"cursor-pointer\" : \"cursor-default\"])}\n >\n <DefaultFileControls selected={selected} onSelect={onSelect} />\n <LazyLoad\n height={150}\n offset={\"300px\"}\n data-testid={\"fm-file-wrapper-file-preview\"}\n className={cn([\n \"bg-neutral-muted\",\n \"flex items-center justify-center\",\n \"text-neutral-strong text-sm\"\n ])}\n >\n {children}\n </LazyLoad>\n </div>\n );\n};\n\ntype DefaultFileLabelProps = Pick<FileProps, \"file\">;\n\nconst DefaultFileLabel = ({ file }: DefaultFileLabelProps) => {\n return (\n <div className={\"px-md py-sm-extra\"} data-testid={\"fm-file-wrapper-file-label\"}>\n <Text size={\"sm\"} as={\"div\"} className={\"truncate text-neutral-primary\"}>\n {file.name}\n </Text>\n <Text size={\"sm\"} as={\"div\"} className={\"truncate text-neutral-dimmed\"}>\n {file.type} {\" // \"} <TimeAgo datetime={file.createdOn} />\n </Text>\n </div>\n );\n};\n\nexport const File = makeDecoratable(\n \"File\",\n ({ file, fileBody, selected, onSelect, children }: FileProps) => {\n return (\n <div\n className={cn([\n \"group\",\n \"bg-neutral-base rounded-lg\",\n \"shadow-sm hover:shadow-lg\",\n \"border-sm border-solid border-neutral-base hover:border-neutral-dimmed-darker\",\n selected && \"ring-md ring-primary-strong\",\n \"transition-shadow duration-250 ease-in-out\",\n \"overflow-hidden\"\n ])}\n data-testid={\"fm-list-wrapper-file\"}\n data-file-id={file.id}\n >\n {fileBody ?? (\n <DefaultFileBody selected={selected} onSelect={onSelect}>\n {children}\n </DefaultFileBody>\n )}\n <DefaultFileLabel file={file} />\n </div>\n );\n }\n);\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,IAAI,EAAEC,OAAO,EAAEC,EAAE,EAAEC,iBAAiB,QAAQ,kBAAkB;AACvE,SAASC,wBAAwB;AAejC,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAmC,CAAC,KAAK;EAC9E,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,wBAAwB,CAAC,CAAC;EAC9C,MAAM;IAAEK;EAAY,CAAC,GAAGD,OAAO,CAACE,IAAI;EAEpC,oBACId,KAAA,CAAAe,aAAA,CAAAf,KAAA,CAAAC,QAAA,QACKS,QAAQ,gBACLV,KAAA,CAAAe,aAAA;IACIC,SAAS,EAAEV,EAAE,CAAC,CACV,iBAAiB,EACjB,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ive","useFileManagerViewConfig","DefaultFileControls","onSelect","selected","browser","itemActions","grid","createElement","className","onClick","checked","onChange","map","action","key","name","element","DefaultFileBody","children","height","offset","DefaultFileLabel","file","size","as","type","datetime","createdOn","File","fileBody","id"],"sources":["File.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport LazyLoad from \"react-lazy-load\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { Text, TimeAgo, cn, CheckboxPrimitive } from \"@webiny/admin-ui\";\nimport { useFileManagerViewConfig } from \"~/modules/FileManagerRenderer/FileManagerView/FileManagerViewConfig.js\";\nimport type { FileItem } from \"~/types.js\";\n\nexport interface FileProps {\n file: FileItem;\n selected: boolean;\n fileBody?: React.JSX.Element;\n onSelect?: (event?: React.MouseEvent) => void;\n onClick?: (event?: React.MouseEvent) => void;\n multiple?: boolean;\n children: React.ReactNode;\n}\n\nexport type DefaultFileControlsProps = Pick<FileProps, \"selected\" | \"onSelect\">;\n\nconst DefaultFileControls = ({ onSelect, selected }: DefaultFileControlsProps) => {\n const { browser } = useFileManagerViewConfig();\n const { itemActions } = browser.grid;\n\n return (\n <>\n {onSelect ? (\n <div\n className={cn([\n \"p-xs rounded-md\",\n \"bg-neutral-base/30\",\n \"absolute top-sm left-sm\",\n selected ? \"visible\" : \"invisible group-hover:visible\"\n ])}\n >\n <CheckboxPrimitive\n onClick={onSelect}\n checked={selected}\n onChange={() => void 0}\n />\n </div>\n ) : null}\n <div\n className={cn([\n \"invisible group-hover:visible\",\n \"flex items-center gap-xxs\",\n \"p-xs\",\n \"absolute top-xs-plus right-xs-plus\"\n ])}\n >\n {itemActions.map(action => {\n return <Fragment key={action.name}>{action.element}</Fragment>;\n })}\n </div>\n </>\n );\n};\n\nexport type DefaultFileBodyProps = Pick<FileProps, \"selected\" | \"onSelect\" | \"children\">;\n\nconst DefaultFileBody = ({ selected, onSelect, children }: DefaultFileBodyProps) => {\n return (\n <div\n onClick={onSelect}\n className={cn([\"relative\", onSelect ? \"cursor-pointer\" : \"cursor-default\"])}\n >\n <DefaultFileControls selected={selected} onSelect={onSelect} />\n <LazyLoad\n height={150}\n offset={\"300px\"}\n data-testid={\"fm-file-wrapper-file-preview\"}\n className={cn([\n \"bg-neutral-muted\",\n \"flex items-center justify-center\",\n \"text-neutral-strong text-sm\"\n ])}\n >\n {children}\n </LazyLoad>\n </div>\n );\n};\n\ntype DefaultFileLabelProps = Pick<FileProps, \"file\">;\n\nconst DefaultFileLabel = ({ file }: DefaultFileLabelProps) => {\n return (\n <div className={\"px-md py-sm-extra\"} data-testid={\"fm-file-wrapper-file-label\"}>\n <Text size={\"sm\"} as={\"div\"} className={\"truncate text-neutral-primary\"}>\n {file.name}\n </Text>\n <Text size={\"sm\"} as={\"div\"} className={\"truncate text-neutral-dimmed\"}>\n {file.type} {\" // \"} <TimeAgo datetime={file.createdOn} />\n </Text>\n </div>\n );\n};\n\nexport const File = makeDecoratable(\n \"File\",\n ({ file, fileBody, selected, onSelect, children }: FileProps) => {\n return (\n <div\n className={cn([\n \"group\",\n \"bg-neutral-base rounded-lg\",\n \"shadow-sm hover:shadow-lg\",\n \"border-sm border-solid border-neutral-base hover:border-neutral-dimmed-darker\",\n selected && \"ring-md ring-primary-strong\",\n \"transition-shadow duration-250 ease-in-out\",\n \"overflow-hidden\"\n ])}\n data-testid={\"fm-list-wrapper-file\"}\n data-file-id={file.id}\n >\n {fileBody ?? (\n <DefaultFileBody selected={selected} onSelect={onSelect}>\n {children}\n </DefaultFileBody>\n )}\n <DefaultFileLabel file={file} />\n </div>\n );\n }\n);\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,IAAI,EAAEC,OAAO,EAAEC,EAAE,EAAEC,iBAAiB,QAAQ,kBAAkB;AACvE,SAASC,wBAAwB;AAejC,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,QAA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rC,KAAA,CAAAe,aAAA,CAACU,eAAe;IAACd,QAAQ,EAAEA,QAAS;IAACD,QAAQ,EAAEA;EAAS,GACnDgB,QACY,CACpB,eACD1B,KAAA,CAAAe,aAAA,CAACc,gBAAgB;IAACC,IAAI,EAAEA;EAAK,CAAE,CAC9B,CAAC;AAEd,CACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Textarea, Label } from "@webiny/admin-ui";
|
|
3
|
+
import { useBind } from "@webiny/form";
|
|
4
|
+
import { useFileOrUndefined } from "./useFileOrUndefined.js";
|
|
5
|
+
import { useFileManagerApi } from "../../index.js";
|
|
6
|
+
export const Description = () => {
|
|
7
|
+
const {
|
|
8
|
+
file
|
|
9
|
+
} = useFileOrUndefined();
|
|
10
|
+
const {
|
|
11
|
+
canEdit
|
|
12
|
+
} = useFileManagerApi();
|
|
13
|
+
const bind = useBind({
|
|
14
|
+
name: "description"
|
|
15
|
+
});
|
|
16
|
+
return /*#__PURE__*/React.createElement(Textarea, Object.assign({}, bind, {
|
|
17
|
+
label: /*#__PURE__*/React.createElement(Label, {
|
|
18
|
+
text: "Description"
|
|
19
|
+
}),
|
|
20
|
+
disabled: file ? !canEdit(file) : false,
|
|
21
|
+
placeholder: "Enter description"
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=Description.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Textarea","Label","useBind","useFileOrUndefined","useFileManagerApi","Description","file","canEdit","bind","name","createElement","Object","assign","label","text","disabled","placeholder"],"sources":["Description.tsx"],"sourcesContent":["import React from \"react\";\nimport { Textarea, Label } from \"@webiny/admin-ui\";\nimport { useBind } from \"@webiny/form\";\nimport { useFileOrUndefined } from \"./useFileOrUndefined.js\";\nimport { useFileManagerApi } from \"~/index.js\";\n\nexport const Description = () => {\n const { file } = useFileOrUndefined();\n const { canEdit } = useFileManagerApi();\n const bind = useBind({\n name: \"description\"\n });\n\n return (\n <Textarea\n {...bind}\n label={<Label text={\"Description\"} />}\n disabled={file ? !canEdit(file) : false}\n placeholder={\"Enter description\"}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,KAAK,QAAQ,kBAAkB;AAClD,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAM;IAAEC;EAAK,CAAC,GAAGH,kBAAkB,CAAC,CAAC;EACrC,MAAM;IAAEI;EAAQ,CAAC,GAAGH,iBAAiB,CAAC,CAAC;EACvC,MAAMI,IAAI,GAAGN,OAAO,CAAC;IACjBO,IAAI,EAAE;EACV,CAAC,CAAC;EAEF,oBACIV,KAAA,CAAAW,aAAA,CAACV,QAAQ,EAAAW,MAAA,CAAAC,MAAA,KACDJ,IAAI;IACRK,KAAK,eAAEd,KAAA,CAAAW,aAAA,CAACT,KAAK;MAACa,IAAI,EAAE;IAAc,CAAE,CAAE;IACtCC,QAAQ,EAAET,IAAI,GAAG,CAACC,OAAO,CAACD,IAAI,CAAC,GAAG,KAAM;IACxCU,WAAW,EAAE;EAAoB,EACpC,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./AccessControl.js\";\nexport * from \"./Name.js\";\nexport * from \"./Tags.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./AccessControl.js\";\nexport * from \"./Description.js\";\nexport * from \"./Name.js\";\nexport * from \"./Tags.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const FM_PERMISSIONS_SCHEMA: {
|
|
2
|
+
readonly prefix: "fm";
|
|
3
|
+
readonly fullAccess: true;
|
|
4
|
+
readonly entities: [{
|
|
5
|
+
readonly id: "file";
|
|
6
|
+
readonly title: "File";
|
|
7
|
+
readonly scopes: ["full", "own"];
|
|
8
|
+
readonly permission: "fm.file";
|
|
9
|
+
readonly actions: [{
|
|
10
|
+
readonly name: "rwd";
|
|
11
|
+
}];
|
|
12
|
+
}, {
|
|
13
|
+
readonly id: "settings";
|
|
14
|
+
readonly title: "Settings";
|
|
15
|
+
readonly scopes: ["full"];
|
|
16
|
+
readonly permission: "fm.settings";
|
|
17
|
+
}];
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createPermissionSchema } from "@webiny/app-admin";
|
|
2
|
+
export const FM_PERMISSIONS_SCHEMA = createPermissionSchema({
|
|
3
|
+
prefix: "fm",
|
|
4
|
+
fullAccess: true,
|
|
5
|
+
entities: [{
|
|
6
|
+
id: "file",
|
|
7
|
+
title: "File",
|
|
8
|
+
scopes: ["full", "own"],
|
|
9
|
+
permission: "fm.file",
|
|
10
|
+
actions: [{
|
|
11
|
+
name: "rwd"
|
|
12
|
+
}]
|
|
13
|
+
}, {
|
|
14
|
+
id: "settings",
|
|
15
|
+
title: "Settings",
|
|
16
|
+
scopes: ["full"],
|
|
17
|
+
permission: "fm.settings"
|
|
18
|
+
}]
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=permissionsSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPermissionSchema","FM_PERMISSIONS_SCHEMA","prefix","fullAccess","entities","id","title","scopes","permission","actions","name"],"sources":["permissionsSchema.ts"],"sourcesContent":["import { createPermissionSchema } from \"@webiny/app-admin\";\n\nexport const FM_PERMISSIONS_SCHEMA = createPermissionSchema({\n prefix: \"fm\",\n fullAccess: true,\n entities: [\n {\n id: \"file\",\n title: \"File\",\n scopes: [\"full\", \"own\"],\n permission: \"fm.file\",\n actions: [{ name: \"rwd\" }]\n },\n {\n id: \"settings\",\n title: \"Settings\",\n scopes: [\"full\"],\n permission: \"fm.settings\"\n }\n ]\n});\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,mBAAmB;AAE1D,OAAO,MAAMC,qBAAqB,GAAGD,sBAAsB,CAAC;EACxDE,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,IAAI;EAChBC,QAAQ,EAAE,CACN;IACIC,EAAE,EAAE,MAAM;IACVC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvBC,UAAU,EAAE,SAAS;IACrBC,OAAO,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAM,CAAC;EAC7B,CAAC,EACD;IACIL,EAAE,EAAE,UAAU;IACdC,KAAK,EAAE,UAAU;IACjBC,MAAM,EAAE,CAAC,MAAM,CAAC;IAChBC,UAAU,EAAE;EAChB,CAAC;AAET,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebinySdk } from "@webiny/app-admin/features/webinySdk/abstractions.js";
|
|
2
|
+
import type { FmFile } from "../shared/types.js";
|
|
3
|
+
import { GetFileGateway as GatewayAbstraction, type GetFileGatewayParams } from "./abstractions.js";
|
|
4
|
+
declare class GetFileGatewayImpl implements GatewayAbstraction.Interface {
|
|
5
|
+
private sdk;
|
|
6
|
+
constructor(sdk: WebinySdk.Interface);
|
|
7
|
+
execute(params: GetFileGatewayParams): Promise<FmFile>;
|
|
8
|
+
}
|
|
9
|
+
export declare const GetFileGateway: typeof GetFileGatewayImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetFileGateway>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WebinySdk } from "@webiny/app-admin/features/webinySdk/abstractions.js";
|
|
2
|
+
import { GetFileGateway as GatewayAbstraction } from "./abstractions.js";
|
|
3
|
+
import { FILE_FIELDS } from "../shared/FILE_FIELDS.js";
|
|
4
|
+
class GetFileGatewayImpl {
|
|
5
|
+
constructor(sdk) {
|
|
6
|
+
this.sdk = sdk;
|
|
7
|
+
}
|
|
8
|
+
async execute(params) {
|
|
9
|
+
const result = await this.sdk.fileManager.getFile({
|
|
10
|
+
id: params.id,
|
|
11
|
+
fields: FILE_FIELDS
|
|
12
|
+
});
|
|
13
|
+
if (result.isFail()) {
|
|
14
|
+
throw new Error(result.error.message);
|
|
15
|
+
}
|
|
16
|
+
return result.value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const GetFileGateway = GatewayAbstraction.createImplementation({
|
|
20
|
+
implementation: GetFileGatewayImpl,
|
|
21
|
+
dependencies: [WebinySdk]
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=GetFileGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinySdk","GetFileGateway","GatewayAbstraction","FILE_FIELDS","GetFileGatewayImpl","constructor","sdk","execute","params","result","fileManager","getFile","id","fields","isFail","Error","error","message","value","createImplementation","implementation","dependencies"],"sources":["GetFileGateway.ts"],"sourcesContent":["import { WebinySdk } from \"@webiny/app-admin/features/webinySdk/abstractions.js\";\nimport type { FmFile } from \"../shared/types.js\";\nimport { GetFileGateway as GatewayAbstraction, type GetFileGatewayParams } from \"./abstractions.js\";\nimport { FILE_FIELDS } from \"~/features/shared/FILE_FIELDS.js\";\n\nclass GetFileGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private sdk: WebinySdk.Interface) {}\n\n async execute(params: GetFileGatewayParams): Promise<FmFile> {\n const result = await this.sdk.fileManager.getFile({\n id: params.id,\n fields: FILE_FIELDS\n });\n\n if (result.isFail()) {\n throw new Error(result.error.message);\n }\n\n return result.value;\n }\n}\n\nexport const GetFileGateway = GatewayAbstraction.createImplementation({\n implementation: GetFileGatewayImpl,\n dependencies: [WebinySdk]\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sDAAsD;AAEhF,SAASC,cAAc,IAAIC,kBAAkB;AAC7C,SAASC,WAAW;AAEpB,MAAMC,kBAAkB,CAAyC;EAC7DC,WAAWA,CAASC,GAAwB,EAAE;IAAA,KAA1BA,GAAwB,GAAxBA,GAAwB;EAAG;EAE/C,MAAMC,OAAOA,CAACC,MAA4B,EAAmB;IACzD,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,GAAG,CAACI,WAAW,CAACC,OAAO,CAAC;MAC9CC,EAAE,EAAEJ,MAAM,CAACI,EAAE;MACbC,MAAM,EAAEV;IACZ,CAAC,CAAC;IAEF,IAAIM,MAAM,CAACK,MAAM,CAAC,CAAC,EAAE;MACjB,MAAM,IAAIC,KAAK,CAACN,MAAM,CAACO,KAAK,CAACC,OAAO,CAAC;IACzC;IAEA,OAAOR,MAAM,CAACS,KAAK;EACvB;AACJ;AAEA,OAAO,MAAMjB,cAAc,GAAGC,kBAAkB,CAACiB,oBAAoB,CAAC;EAClEC,cAAc,EAAEhB,kBAAkB;EAClCiB,YAAY,EAAE,CAACrB,SAAS;AAC5B,CAAC,CAAC","ignoreList":[]}
|