diff --git a/src/lib/components/form/moldure/search/FilterBuilder/serializers/StaticQueryStringSerializer.js b/src/lib/components/form/moldure/search/FilterBuilder/serializers/StaticQueryStringSerializer.js index 04c17fd..91c38e9 100644 --- a/src/lib/components/form/moldure/search/FilterBuilder/serializers/StaticQueryStringSerializer.js +++ b/src/lib/components/form/moldure/search/FilterBuilder/serializers/StaticQueryStringSerializer.js @@ -38,11 +38,7 @@ export class StaticQueryStringSerializer extends QueryStringSerializer { 'OR', 'value' ), - recordTypes: new ValueField( - 'form.recordTypes', - 'parent.type', - 'OR' - ), + recordTypes: new ValueField('form.recordTypes', 'parent.type', 'OR'), resourceTypes: new ValueField( 'form.resourceTypes', 'metadata.resource_type.id', diff --git a/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.css b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.css new file mode 100644 index 0000000..9642129 --- /dev/null +++ b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.css @@ -0,0 +1,23 @@ +/* + * This file is part of GEO-Components-React. + * Copyright (C) 2022 GEO Secretariat. + * + * GEO-Components-React is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +.table-external-files .ui.container .grid p { + overflow-wrap: break-word; +} + +.table-external-files .ui.grid .row .column.pt-0 { + padding-top: 0 !important; +} + +.table-external-files .ui.grid .row .column.pt-1 { + padding-top: 1px !important; +} + +.table-external-files .ui.table td { + overflow: visible; +} diff --git a/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.js b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.js new file mode 100644 index 0000000..36c59f9 --- /dev/null +++ b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.js @@ -0,0 +1,221 @@ +/* + * This file is part of GEO-Components-React. + * Copyright (C) 2022 GEO Secretariat. + * + * GEO-Components-React is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +import React, { useMemo } from 'react'; + +import { BaseGlobalFilter } from '../../base'; +import { PaginableTable } from '../../moldure'; + +import _get from 'lodash/get'; +import _isNil from 'lodash/isNil'; + +import regeneratorRuntime from 'regenerator-runtime'; +import { useAsyncDebounce } from 'react-table'; + +import { Grid, Button, Icon, Header, Dropdown, Label } from 'semantic-ui-react'; + +import './ExternalFilesTable.css'; + +/** + * External files table. + */ +export const ExternalFilesTable = ({ tableData, tableConfig }) => { + const tableColumnsDefinition = useMemo(() => { + return [ + // Defining invisible columns that are used as the index for the table filter + { + Header: () => null, + id: 'idx_key', + accessor: 'key', + }, + { + Header: () => null, + id: 'idx_mimetype', + accessor: 'mimetype', + }, + { + Header: () => null, + id: 'idx_metadata', + accessor: 'metadata', + }, + // Content column + { + Header: () => null, + id: 'external-files-table', + Cell: ({ row }) => { + // Getting data + const { original: rowData } = row; + + // Preparing data + // Provider + const rowSource = _get(rowData, 'source'); + + // Name, checksum and size + const rowKey = _get(rowData, 'key'); + const rowSize = _get(rowData, 'size'); + const rowChecksum = _get(rowData, 'checksum'); + + // Download and preview URL + const rowPreviewUrl = _get(rowData, 'url_preview'); + const rowDownloadUrl = _get(rowData, 'url_download'); + + return ( + + + +
+ + +
+ + + + + + + + + + + {rowChecksum} +
+ +
+
+
+
+
+
+ + + {!_isNil(rowPreviewUrl) && ( + + )} + + + + +
+ + + + + + + + +

+ Preview +

+
+ + +

+ Download +

+
+
+
+
+
+
+
+
+
+ ); + }, + }, + ]; + }); + + const tableDataMemoized = useMemo(() => tableData); + + return ( +
+ ( + + )} + showHeader={false} + {...tableConfig} + /> +
+ ); +}; diff --git a/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.stories.js b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.stories.js new file mode 100644 index 0000000..0ca81cf --- /dev/null +++ b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.stories.js @@ -0,0 +1,31 @@ +/* + * This file is part of GEO-Components-React. + * Copyright (C) 2022 GEO Secretariat. + * + * GEO-Components-React is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +import React from 'react'; + +import { ExternalFilesTable as ExternalFilesTableComponent } from './ExternalFilesTable'; + +import externalFilesData from '../../../../../mocks/table/table-external-files.json'; + +export default { + title: 'Table/Thematic/External Files Table', + component: ExternalFilesTableComponent, +}; + +/** + * Component template + */ +const Template = (args) => ; + +/** + * Component stories + */ +export const Base = Template.bind({}); +Base.args = { + tableData: externalFilesData, +}; diff --git a/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.test.js b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.test.js new file mode 100644 index 0000000..001e181 --- /dev/null +++ b/src/lib/components/table/thematic/ExternalFilesTable/ExternalFilesTable.test.js @@ -0,0 +1,23 @@ +/* + * This file is part of GEO-Components-React. + * Copyright (C) 2022 GEO Secretariat. + * + * GEO-Components-React is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +import React from 'react'; + +import { ExternalFilesTable } from './ExternalFilesTable'; + +import { render } from '../../../../../setupTestRenders'; + +import externalFilesData from '../../../../../mocks/table/table-external-files.json'; + +describe('ExternalFilesTable tests', () => { + describe('Render tests', () => { + it('should render with the required props without crashing', () => { + render(); + }); + }); +}); diff --git a/src/lib/components/table/thematic/ExternalFilesTable/index.js b/src/lib/components/table/thematic/ExternalFilesTable/index.js new file mode 100644 index 0000000..8d00634 --- /dev/null +++ b/src/lib/components/table/thematic/ExternalFilesTable/index.js @@ -0,0 +1,9 @@ +/* + * This file is part of GEO-Components-React. + * Copyright (C) 2022 GEO Secretariat. + * + * GEO-Components-React is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ + +export { ExternalFilesTable } from './ExternalFilesTable'; diff --git a/src/lib/components/table/thematic/ExternalResourceTable/youtube.css b/src/lib/components/table/thematic/ExternalResourceTable/youtube.css index fc4b521..957e2b4 100644 --- a/src/lib/components/table/thematic/ExternalResourceTable/youtube.css +++ b/src/lib/components/table/thematic/ExternalResourceTable/youtube.css @@ -7,9 +7,9 @@ */ .youtube-embed { - border-radius: 3px; + border-radius: 3px; } .youtube-embed-container { - padding: 20px; + padding: 20px; } diff --git a/src/lib/components/table/thematic/RelatedResourceTable/RelatedResourceTable.css b/src/lib/components/table/thematic/RelatedResourceTable/RelatedResourceTable.css index 244e42b..c7f8b14 100644 --- a/src/lib/components/table/thematic/RelatedResourceTable/RelatedResourceTable.css +++ b/src/lib/components/table/thematic/RelatedResourceTable/RelatedResourceTable.css @@ -7,5 +7,5 @@ */ .related-resource-table .ui.accordion .title { - padding: 0; + padding: 0; } diff --git a/src/lib/components/table/thematic/index.js b/src/lib/components/table/thematic/index.js index 654cfec..f8c1fbb 100644 --- a/src/lib/components/table/thematic/index.js +++ b/src/lib/components/table/thematic/index.js @@ -11,3 +11,5 @@ export { RelatedResourceTable } from './RelatedResourceTable'; export { RelatedPackagesTable } from './RelatedPackagesTable'; export { UserStoriesTable } from './UserStoriesTable'; export { RecordsTable } from './RecordsTable'; + +export { ExternalFilesTable } from './ExternalFilesTable'; diff --git a/src/mocks/table/table-external-files.json b/src/mocks/table/table-external-files.json new file mode 100644 index 0000000..762da8d --- /dev/null +++ b/src/mocks/table/table-external-files.json @@ -0,0 +1,38 @@ +[ + { + "key": "File Name.zip", + "checksum": "md5:afea585e933b456af6e1686byuhg212", + "size": 60740526, + "mimetype": "application/zip", + "metadata": null, + "url_download": "https://link-to-zenodo.org/records-file-link", + "url_preview": "https://link-to-zenodo.org/preview-file-link" + }, + { + "key": "File Name.json", + "checksum": "md5:afea585e933b456af6e1686byuhg212", + "size": 60740526, + "mimetype": "application/json", + "metadata": null, + "url_download": "https://link-to-zenodo.org/records-file-link", + "url_preview": "https://link-to-zenodo.org/preview-file-link" + }, + { + "key": "File Name.pdf", + "checksum": "md5:afea585e933b456af6e1686byuhg212", + "size": 60740526, + "mimetype": "application/pdf", + "metadata": null, + "url_download": "https://link-to-zenodo.org/records-file-link", + "url_preview": "https://link-to-zenodo.org/preview-file-link" + }, + { + "key": "File Name.tif", + "checksum": "md5:afea585e933b456af6e1686byuhg212", + "size": 60740526, + "mimetype": "image/tiff", + "metadata": null, + "url_download": "https://link-to-zenodo.org/records-file-link", + "url_preview": "https://link-to-zenodo.org/preview-file-link" + } +]