-
Notifications
You must be signed in to change notification settings - Fork 173
refactor(ui): support custom file display name resolver #3274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zubeydecivelek
wants to merge
1
commit into
inveniosoftware:master
Choose a base branch
from
zubeydecivelek:update-files-macros
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,8 +31,13 @@ | |||||
| {%- endmacro %} | ||||||
|
|
||||||
|
|
||||||
| {% macro preview_file_box(file, pid, is_preview, record, include_deleted) %} | ||||||
| {% macro preview_file_box(file, pid, is_preview, record, include_deleted, resolve_display_name=None) %} | ||||||
| {%- set is_remote_file = file.transfer.type == transfer_types.REMOTE %} | ||||||
| {%- if resolve_display_name %} | ||||||
| {%- set display_name = resolve_display_name(file) or file.key %} | ||||||
| {%- else %} | ||||||
| {%- set display_name = file.key %} | ||||||
| {%- endif %} | ||||||
| <div class="ui accordion panel mb-10 {{record.ui.access_status.id}}" href="#files-preview-accordion-panel"> | ||||||
| <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | ||||||
| <div | ||||||
|
|
@@ -44,7 +49,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | |||||
| class="trigger" | ||||||
| aria-label="{{ _('File preview') }}" | ||||||
| > | ||||||
| <span id="preview-file-title">{{ file.key }}</span> | ||||||
| <span id="preview-file-title">{{ display_name }}</span> | ||||||
| <i class="angle right icon" aria-hidden="true"></i> | ||||||
| </div> | ||||||
| </h3> | ||||||
|
|
@@ -82,7 +87,8 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | |||||
| download_endpoint='invenio_app_rdm_records.record_file_download', | ||||||
| preview_endpoint='invenio_app_rdm_records.record_file_preview', | ||||||
| is_media=false, | ||||||
| permissions=None | ||||||
| permissions=None, | ||||||
| resolve_display_name=None | ||||||
| ) %} | ||||||
| <table class="ui striped table files fluid {{record.ui.access_status.id}}"> | ||||||
| <thead> | ||||||
|
|
@@ -108,6 +114,11 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | |||||
| {% for file in files %} | ||||||
| {% if not file.access.hidden %} | ||||||
| {%- set is_remote_file = file.transfer.type == transfer_types.REMOTE %} | ||||||
| {%- if resolve_display_name %} | ||||||
| {%- set display_name = resolve_display_name(file) or file.key %} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| {%- else %} | ||||||
| {%- set display_name = file.key %} | ||||||
| {%- endif %} | ||||||
| {% if is_preview %} | ||||||
| {%- set file_url_download = url_for(download_endpoint, pid_value=pid, filename=file.key, download=1, preview=1) %} | ||||||
| {%- set file_url_preview = url_for(preview_endpoint, pid_value=pid, filename=file.key, preview=1, include_deleted=include_deleted_value) %} | ||||||
|
|
@@ -120,7 +131,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | |||||
| <tr> | ||||||
| <td class="ten wide"> | ||||||
| <div> | ||||||
| <a href="{{ file_url_download }}">{{ file.key }}</a> | ||||||
| <a href="{{ file_url_download }}">{{ display_name }}</a> | ||||||
| </div> | ||||||
| {%- if not is_remote_file %} | ||||||
| <small class="ui text-muted font-tiny">{{ file.checksum or _("Checksum not yet calculated.") }} | ||||||
|
|
@@ -151,7 +162,7 @@ <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | |||||
| {%- endmacro %} | ||||||
|
|
||||||
|
|
||||||
| {% macro file_list_box(files, pid, is_preview, include_deleted, record, permissions) %} | ||||||
| {% macro file_list_box(files, pid, is_preview, include_deleted, record, permissions, resolve_display_name=None) %} | ||||||
| {%- set binary_sizes = not config.APP_RDM_DISPLAY_DECIMAL_FILE_SIZES %} | ||||||
| <div class="ui accordion panel mb-10 {{ record.ui.access_status.id }}" href="#files-list-accordion-panel"> | ||||||
| <h3 class="active title panel-heading {{ record.ui.access_status.id }} m-0"> | ||||||
|
|
@@ -174,13 +185,13 @@ <h4 class="inline">{{ record.ui.access_status.title_l10n }}</h4> | |||||
| </div> | ||||||
| {% endif %} | ||||||
| <div> | ||||||
| {{ file_list(files, pid, is_preview, include_deleted, record=record,download_endpoint="invenio_app_rdm_records.record_file_download", permissions=permissions) }} | ||||||
| {{ file_list(files, pid, is_preview, include_deleted, record=record,download_endpoint="invenio_app_rdm_records.record_file_download", permissions=permissions, resolve_display_name=resolve_display_name) }} | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| {%- endmacro %} | ||||||
|
|
||||||
| {% macro media_file_list_box(files, pid, is_preview, include_deleted, record, permissions) %} | ||||||
| {% macro media_file_list_box(files, pid, is_preview, include_deleted, record, permissions, resolve_display_name=None) %} | ||||||
| {%- set binary_sizes = not config.APP_RDM_DISPLAY_DECIMAL_FILE_SIZES %} | ||||||
| <div class="ui accordion panel mb-10 {{ record.access.record }}" href="#media-files-preview-accordion-panel"> | ||||||
| <h3 class="active title panel-heading {{ record.access.record }} m-0"> | ||||||
|
|
@@ -204,7 +215,7 @@ <h4 class="inline">{{ record.ui.access_status.title_l10n }}</h4> | |||||
| </div> | ||||||
| {% endif %} | ||||||
| <div> | ||||||
| {{ file_list(files, pid, is_preview, include_deleted, record=record, with_preview=false, download_endpoint="invenio_app_rdm_records.record_media_file_download", is_media=true, permissions=permissions) }} | ||||||
| {{ file_list(files, pid, is_preview, include_deleted, record=record, with_preview=false, download_endpoint="invenio_app_rdm_records.record_media_file_download", is_media=true, permissions=permissions, resolve_display_name=resolve_display_name) }} | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.