Skip to content

Commit a74d42c

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 67704b3 commit a74d42c

File tree

7 files changed

+68
-2
lines changed

7 files changed

+68
-2
lines changed

invenio_app_rdm/config.py

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

1479+
APP_RDM_DEPOSIT_NG_FILES_UI = False
1480+
"""Feature toggle to enable the new Uppy uploader for the deposit form."""
14791481

14801482
RDM_DETAIL_SIDE_BAR_MANAGE_ATTRIBUTES_EXTENSION_TEMPLATE = None
14811483
"""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 %}
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 | tojson }}'>
5257

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

invenio_app_rdm/records_ui/views/deposits.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# under the terms of the MIT License; see LICENSE file for more details.
1111

1212
"""Routes for record-related pages provided by Invenio-App-RDM."""
13-
1413
from copy import deepcopy
1514

1615
from flask import current_app, g, redirect
@@ -25,6 +24,7 @@
2524
from invenio_rdm_records.resources.serializers import UIJSONSerializer
2625
from invenio_rdm_records.services.schemas import RDMRecordSchema
2726
from invenio_rdm_records.services.schemas.utils import dump_empty
27+
from invenio_records_resources.proxies import current_transfer_registry
2828
from invenio_records_resources.services.errors import PermissionDeniedError
2929
from invenio_search.engine import dsl
3030
from invenio_vocabularies.proxies import current_service as vocabulary_service
@@ -387,6 +387,8 @@ def get_form_config(**kwargs):
387387
publish_modal_extra=current_app.config.get(
388388
"APP_RDM_DEPOSIT_FORM_PUBLISH_MODAL_EXTRA"
389389
),
390+
default_transfer_type=current_transfer_registry.default_transfer_type,
391+
transfer_types=list(current_transfer_registry.get_transfer_types()),
390392
**kwargs,
391393
)
392394

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

Lines changed: 7 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
@@ -136,13 +139,15 @@ export class RDMDepositForm extends Component {
136139
groupsEnabled={groupsEnabled}
137140
allowEmptyFiles={allowEmptyFiles}
138141
customFieldsUI={customFieldsUI}
142+
useUppy={useUppy}
139143
>
140144
<DepositFormApp
141145
config={this.config}
142146
record={record}
143147
preselectedCommunity={preselectedCommunity}
144148
files={files}
145149
permissions={permissions}
150+
useUppy={useUppy}
146151
>
147152
<Overridable
148153
id="InvenioAppRdm.Deposit.FormFeedback.container"
@@ -196,7 +201,7 @@ export class RDMDepositForm extends Component {
196201
filesLocked={filesLocked}
197202
allowEmptyFiles={allowEmptyFiles}
198203
>
199-
<FileUploader
204+
<UploaderField
200205
isDraftRecord={!record.is_published}
201206
quota={this.config.quota}
202207
decimalSizeDisplay={this.config.decimal_size_display}
@@ -765,6 +770,7 @@ RDMDepositForm.propTypes = {
765770
permissions: PropTypes.object,
766771
filesLocked: PropTypes.bool,
767772
allowEmptyFiles: PropTypes.bool,
773+
useUppy: PropTypes.bool,
768774
};
769775

770776
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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-DashboardTab[data-uppy-acquirer-id="MyDevice"] {
28+
// .sr-only
29+
position: absolute;
30+
width: 1px;
31+
height: 1px;
32+
padding: 0;
33+
overflow: hidden;
34+
clip: rect(0, 0, 0, 0);
35+
word-wrap: normal;
36+
border: 0;
37+
}
38+
39+
.uppy-Dashboard-innerWrap {
40+
height: 300px;
41+
42+
&:has(#uppy-DashboardContent-panel--editor) {
43+
height: 500px;
44+
}
45+
}
46+
47+
.uppy-DashboardContent-bar, .uppy-StatusBar {
48+
z-index: 10;
49+
}

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)