Skip to content

Commit 2d22c07

Browse files
committed
deposit-ui: uppy uploader ui feature
* addresses the UI part of RFC 0072 * adds feature flag `APP_RDM_DEPOSIT_NG_FILES_UI` to enable the Uppy uploader UI * inveniosoftware/rfcs#91
1 parent 6fd3d3b commit 2d22c07

File tree

8 files changed

+75
-4
lines changed

8 files changed

+75
-4
lines changed

invenio_app_rdm/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,8 @@ def github_link_render(record):
14821482
APP_RDM_SUBCOMMUNITIES_LABEL = "Subcommunities"
14831483
"""Label for the subcommunities in the community browse page."""
14841484

1485+
APP_RDM_DEPOSIT_NG_FILES_UI_ENABLED = False
1486+
"""Feature toggle to enable the new Uppy uploader for the deposit form."""
14851487

14861488
RDM_DETAIL_SIDE_BAR_MANAGE_ATTRIBUTES_EXTENSION_TEMPLATE = None
14871489
"""Side bar manage attributes extension template."""

invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/deposit.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
{%- block css %}
66
{{ super() }}
77
<link rel="stylesheet" type="text/css" href="/communities/{{community.slug}}/community-theme-{{ community.revision_id }}.css">
8+
{%- if config.APP_RDM_DEPOSIT_NG_FILES_UI_ENABLED %}
9+
{{ webpack['uppy-file-uploader.css'] }}
10+
{%- endif %}
811
{%- endblock %}
912
{%- endif %}
1013

@@ -49,6 +52,8 @@
4952
value='{{ config.USERS_RESOURCES_GROUPS_ENABLED | tojson }}'>
5053
<input type="hidden" name="records-resources-allow-empty-files"
5154
value='{{ config.RECORDS_RESOURCES_ALLOW_EMPTY_FILES | tojson }}'>
55+
<input type="hidden" name="deposits-use-uppy-ui"
56+
value='{{ config.APP_RDM_DEPOSIT_NG_FILES_UI_ENABLED | tojson }}'>
5257

5358
{%- if forms_config %}
5459
<input type="hidden" name="deposits-config"

invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333

3434
{% macro preview_file_box(file, pid, is_preview, record, include_deleted) %}
35+
{%- set is_remote_file = file.transfer.type == 'R' %}
3536
<div class="ui accordion panel mb-10 {{record.ui.access_status.id}}" href="#files-preview-accordion-panel">
3637
<h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
3738
<div
@@ -53,9 +54,22 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
5354
aria-labelledby="files-preview-accordion-trigger"
5455
class="active content preview-container pt-0 {{record.ui.access_status.id}}"
5556
>
57+
{%- if is_remote_file %}
58+
<div class="ui info message">
59+
<div class="header">
60+
{{ _('This file cannot be previewed') }}
61+
</div>
62+
<ul class="list">
63+
<li>{{ _('This file is an external reference and not stored directly in this repository.
64+
To access its content, please download it and open it locally.') }}
65+
</li>
66+
</ul>
67+
</div>
68+
{%- else %}
5669
<div>
5770
{{ preview_file('invenio_app_rdm_records.record_file_preview', pid_value=pid, filename=file.key, is_preview=is_preview, include_deleted=include_deleted) }}
5871
</div>
72+
{%- endif %}
5973
</div>
6074
</div>
6175
{%- endmacro %}
@@ -93,6 +107,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
93107
{% endif %}
94108
{% for file in files %}
95109
{% if not file.access.hidden %}
110+
{%- set is_remote_file = file.transfer.type == 'R' %}
96111
{% if is_preview %}
97112
{%- set file_url_download = url_for(download_endpoint, pid_value=pid, filename=file.key, download=1, preview=1) %}
98113
{%- set file_url_preview = url_for(preview_endpoint, pid_value=pid, filename=file.key, preview=1, include_deleted=include_deleted_value) %}
@@ -107,16 +122,18 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
107122
<div>
108123
<a href="{{ file_url_download }}">{{ file.key }}</a>
109124
</div>
125+
{%- if not is_remote_file %}
110126
<small class="ui text-muted font-tiny">{{ file.checksum }}
111127
<div class="ui icon inline-block" data-tooltip="{{_('This is the file fingerprint (checksum), which can be used to verify the file integrity.')}}">
112128
<i class="question circle checksum icon"></i>
113129
</div>
114130
</small>
131+
{%- endif %}
115132
</td>
116-
<td>{{ file.size|filesizeformat(binary=binary_sizes) }}</td>
133+
<td>{%- if is_remote_file %}{{_("N/A (external)")}}{%- else -%}{{ file.size|filesizeformat(binary=binary_sizes) }}{%- endif %}</td>
117134
<td class="right aligned">
118135
<span>
119-
{% if with_preview and file_type|lower is previewable %}
136+
{% if with_preview and file_type|lower is previewable and not is_remote_file %}
120137
<a role="button" class="ui compact mini button preview-link" href="{{ file_url_preview }}" target="preview-iframe" data-file-key="{{file.key}}">
121138
<i class="eye icon" aria-hidden="true"></i>{{_("Preview")}}
122139
</a>
@@ -140,7 +157,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
140157
<h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0">
141158
<div role="button" id="files-list-accordion-trigger" aria-controls="files-list-accordion-panel" aria-expanded="true" tabindex="0" class="trigger">
142159
{{ _("Files") }}
143-
<small class="text-muted">{% if files %} ({{files|sum(attribute='size')|filesizeformat(binary=binary_sizes)}}){% endif %}</small>
160+
<small class="text-muted">{% if files %} ({{files|map(attribute='size', default=0)|sum()|filesizeformat(binary=binary_sizes)}}){% endif %}</small>
144161
<i class="angle right icon" aria-hidden="true"></i>
145162
</div>
146163
</h3>

invenio_app_rdm/records_ui/views/deposits.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from invenio_rdm_records.resources.serializers import UIJSONSerializer
2626
from invenio_rdm_records.services.schemas import RDMRecordSchema
2727
from invenio_rdm_records.services.schemas.utils import dump_empty
28+
from invenio_records_resources.proxies import current_transfer_registry
2829
from invenio_records_resources.services.errors import PermissionDeniedError
2930
from invenio_search.engine import dsl
3031
from invenio_vocabularies.proxies import current_service as vocabulary_service
@@ -387,6 +388,8 @@ def get_form_config(**kwargs):
387388
publish_modal_extra=current_app.config.get(
388389
"APP_RDM_DEPOSIT_FORM_PUBLISH_MODAL_EXTRA"
389390
),
391+
default_transfer_type=current_transfer_registry.default_transfer_type,
392+
transfer_types=list(current_transfer_registry.get_transfer_types()),
390393
**kwargs,
391394
)
392395

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
DeleteButton,
2121
DepositStatusBox,
2222
FileUploader,
23+
UppyUploader,
2324
FormFeedback,
2425
IdentifiersField,
2526
PIDField,
@@ -114,13 +115,15 @@ export class RDMDepositForm extends Component {
114115
allowRecordRestriction,
115116
groupsEnabled,
116117
allowEmptyFiles,
118+
useUppy,
117119
} = this.props;
118120

119121
// Adding section id to custom fields UI, to be used for accordions
120122
const customFieldsUI = this.config.custom_fields.ui.map((section) => ({
121123
...section,
122124
id: section.section.toLowerCase().replace(/\s+/g, "-") + "-section",
123125
}));
126+
const UploaderField = useUppy ? UppyUploader : FileUploader;
124127

125128
return (
126129
<Overridable
@@ -196,13 +199,14 @@ export class RDMDepositForm extends Component {
196199
filesLocked={filesLocked}
197200
allowEmptyFiles={allowEmptyFiles}
198201
>
199-
<FileUploader
202+
<UploaderField
200203
isDraftRecord={!record.is_published}
201204
quota={this.config.quota}
202205
decimalSizeDisplay={this.config.decimal_size_display}
203206
showMetadataOnlyToggle={permissions?.can_manage_files}
204207
allowEmptyFiles={allowEmptyFiles}
205208
filesLocked={filesLocked}
209+
fileUploadConcurrency={config.fileUploadConcurrency}
206210
/>
207211
</Overridable>
208212
</AccordionField>
@@ -765,6 +769,7 @@ RDMDepositForm.propTypes = {
765769
permissions: PropTypes.object,
766770
filesLocked: PropTypes.bool,
767771
allowEmptyFiles: PropTypes.bool,
772+
useUppy: PropTypes.bool,
768773
};
769774

770775
RDMDepositForm.defaultProps = {

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ReactDOM.render(
2121
preselectedCommunity={getInputFromDOM("deposits-draft-community")}
2222
files={getInputFromDOM("deposits-record-files")}
2323
config={getInputFromDOM("deposits-config")}
24+
useUppy={getInputFromDOM("deposits-use-uppy-ui")}
2425
permissions={getInputFromDOM("deposits-record-permissions")}
2526
filesLocked={getInputFromDOM("deposits-record-locked-files")}
2627
recordRestrictionGracePeriod={getInputFromDOM(
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2025 CESNET
3+
*
4+
* Invenio RDM Records is free software; you can redistribute it and/or modify
5+
* it under the terms of the MIT License; see LICENSE file for more details.
6+
*/
7+
8+
@import "@uppy/core/dist/style.min.css";
9+
@import "@uppy/dashboard/dist/style.min.css";
10+
@import "@uppy/image-editor/dist/style.min.css";
11+
12+
.uppy-Dashboard-AddFiles {
13+
padding: 1.2rem;
14+
}
15+
.uppy-Dashboard-AddFiles-info {
16+
display: block;
17+
}
18+
19+
.uppy-Dashboard-note {
20+
padding-top: 3rem;
21+
}
22+
23+
.uppy-Dashboard-inner {
24+
border-radius: 0 0 5px 5px;
25+
}
26+
27+
.uppy-Dashboard-innerWrap {
28+
height: 300px;
29+
30+
&:has(#uppy-DashboardContent-panel--editor) {
31+
height: 500px;
32+
}
33+
}
34+
35+
.uppy-DashboardContent-bar, .uppy-StatusBar {
36+
z-index: 10;
37+
}

invenio_app_rdm/theme/webpack.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"invenio-domains-administration": "./js/invenio_app_rdm/administration/domains/index.js",
4141
"invenio-audit-logs-administration": "./js/invenio_app_rdm/administration/auditLogs/index.js",
4242
"invenio-communities-browse": "./js/invenio_app_rdm/subcommunity/browse.js",
43+
"uppy-file-uploader": "./less/invenio_app_rdm/file_uploader/uppy.less",
4344
},
4445
dependencies={
4546
"@babel/runtime": "^7.9.0",

0 commit comments

Comments
 (0)