Skip to content

Commit f574d1c

Browse files
adliusfuta-ikedabrianjgeigerchth0n1x
authored
Merge feature branch into develop (#1562)
* add guid-node.files and guid-node.files.provider routes (#1476) * File list select (#1478) * Try using checkboxes for file selection * Change checkbox focus * More changes for file multi-select * Other file selection logic * Fix/add tests * Add leftnav content * Add rudimentary test for guid files route * Rename action to prevent future confusion * Remove text-selection on shift click * Disable file selection for registries * Fix test * Aria-labels for file- and folder-items * Fix test * [ENG-3725] Upload and new folder (#1482) * fix file actions menu (#1484) * [ENG-3730] Delete file on list view and detail view (#1486) * delete file * fix element stacking context * file-detail page onDelete redirect * disable delete for registrations * [ENG-3726] Add all providers to files page (#1485) - Ticket: [ENG-3726] - Feature flag: n/a ## Purpose To allow the files page for projects to work properly with all providers. This includes turning off existing functionality for providers that do not support that functionality, and preparing for future functionality to be turned off. ## Summary of Changes 1. Add ProviderFiles and Files for each provider 2. Modify <provider>File and <provider>ProviderFile to turn off select functionality 3. Only show Revisions/Tags panel if you can either see revisions or tags 4. Only show revisions button if the provider has meaningful revision information 5. Only show tags for OSF Storage 6. Increase the number of FileProviders we fetch from default to 20 (we have 12 providers) 7. Add flags providerHandlesVersioning, shouldShowRevisions, shouldShowTags, userCanDownloadAsZip, and userCanMoveToHere. 8. Fix up currentUserPermissions 9. Make userCanMoveToHere especially useful for OSF Storage, checking for storage limits 10. Move OsfStorageManager to StorageManager and generalize for all providers 11. Selectively disable Download As Zip (especially for Github folders) 12. Disable folder creation and upload if no write permissions 13. Disable hashes in revisions tab if there are no hashes to show 14. Add back in Storage Providers to the moved section of the translations file 15. Fix tests 16. Add `target` to FileProvider Mirage 17. Allow deletes only when user has write permission 18. Disallow uploading to OSFStorage if over storage limit * [ENG-3761] LeftNav links and page styling (#1492) ## Purpose Add the provider links to the leftnav and style the outer portions of the page ## Summary of Changes 1. Add hero banner 2. Add provider links to leftnav 3. Fix broken translation * [ENG-3788]Delete folder (#1493) * delete folder * CR followup * [ENG-3722] Move file (#1487) * Generalize ancestry and breadcrumbs for file move * More changes for move-file-modal * Turn goToFolder into function * Update a perform call to fn * Draft: add move file modal component * Remove unneeded logic * Handle file errors/conflicts * Capture exception for file move failure * Add move file logic to file-actions-menu * Prevent wrong files/nodes from being loaded when changing level * Add test * Types * Check permissions * Making a mut point * Styling and some demo feedback * Add message for invalid move destinations * Fix tests * Update test and mirage * Remove move option for file detail page * Remove redundant logic and improve translation string readability * Add skip option. Show cancel button only before move * A11y fixes (#1495) * [No ticket] Create folder error handling (#1494) ## Purpose - Add disable logic and error handling for create-folder modal ## Summary of Changes - Rearrange and add translation files for create-folder modal - Add `disable` tag to the `Create Folder` button when the task is already running * Show unviewed files as bolder font-weight than viewed files (#1501) ## Purpose When a new version of a file is put up, people who haven't seen it yet should show it as unviewed, which in this case means a bolder font-weight in the file list. ## Summary of Changes 1. Update model 2. Update file object 3. Add style if the version hasn't been viewed * Use date_modified instead of modified for date sorting (#1499) ## Purpose Fix sorting by date modified ## Summary of Changes 1. Use date_modified instead of modified for sorting to match the recently fixed backend. * [ENG-3724] Delete multiple files (#1498) * delete multiple files * CR followup * one moar thing * [ENG-3729] Add file checkout icon and logic; (#1502) ## Purpose - Add checkout file icon and logic to show/hide stuff based on it ## Summary of Changes - Add isCheckedOut property for osf-storage-files - Add checkedOut logic for showing/hiding file operations (hide rename, delete, move) * [ENG-3797] Add icons for storage providers (#1506) ## Purpose - Add provider logos to move-file-modal for easier provider selection ## Summary of Changes - Added a new folder `public/assets/images/addons/icons/` which contain icons for file providers - Exclude these icons from fingerprinting as the fingerprint getting added to the filenames was causing issues - Add icons for storage providers in move-file-modal * [ENG-3723] Allow copy of files/folders (#1497) - Ticket: [ENG-3723] - Feature flag: n/a ## Purpose - Allow users to copy files and folders ## Summary of Changes - Update MoveFileModal to handle copying by using a new argument `@preserveOriginal` - Update invocation of MoveFileModal to account for copy action - Change translation strings based on copy or move mode - Add slightly better user messages in case they want to copy items out of a read-only provider - Add copy method to file model * [ENG-3811] Leftnav links with differing permissions (#1505) ## Purpose Adjust which leftnav links are seen with different permission levels and AVOL/VOLs. ## Summary of Changes 1. Hide Addons for read-only users 2. Hide everything but Overview, Files, Wiki, and Registrations from VOL 3. Hide Registrations for AVOL users * Prevent dropdown and content from being obscured (#1503) ## Purpose - Allow users to select file actions in mobile view ## Summary of Changes - Add z-index to file/folder action dropdown triggers for mobile/tablet * [ENG-3806] Move files bugs (#1509) ## Purpose - Address bugs found for move files/folders capabilities ## Summary of Changes - Load all file-providers when fetching a node's file providers - Show provider icons properly * Add data-test selectors for copy/move/delete buttons (#1508) ## Purpose Allow selenium tests (and ours) to access the move, copy, and delete buttons more easily ## Summary of Changes 1. Add data test selectors to file and folder action menus * [ENG-3811] Handle fetching errors (#1507) ## Purpose Catch some errors when fetching resources ## Summary of Changes 1. Catch errors when loading a list of files from File and all of the provider-files. 2. Catch error loading the providers from the route 3. Report error when provider is not passed to the manager (which usually means a problem loading the provider) 4. Add error messages to translations file * Revert "[ENG-3811] Handle fetching errors (#1507)" (#1512) This reverts commit 1977c8b. * [ENG-3811] Misc files page bugs 1 (#1514) ## Purpose Fix a few bugs on the files page ## Summary of Changes 1. Don't reload files page when clicking files link in sidebar 2. Put padding around whole filebrowser 3. Try to make the pulser work on MFR when changing versions on the file detail page - note that this is hard to test locally because MFR doesn't work, but the theory seems sound. 4. Disable delete button when delete task is running 5. Hide horizontal rules in ordered list from aria * Fix upload (#1510) * retry spinner; respect parallelUpload limit * add dragging highlight; add done and cancel buttons * add tracked-built-ins as dependency * finalize * remove highlight when dragndrop is finished * remove comment * [ENG-3811] Display errors when fetch fails (#1513) ## Purpose Catch and display some errors when fetching resources ## Summary of Changes 1. Catch errors when loading a list of files from File and all of the provider-files. 2. Catch error loading the providers from the route 3. Report error when provider is not passed to the manager (which usually means a problem loading the provider) 4. Add error messages to translations file 5. Set owner from the model instances * Add side nav toggle (#1515) * add sidenav toggle * add aria label to toggle button * change aria label text * [ENG-3806] Multi file move bugs (#1511) ## Purpose - Limit simultaneous move/copy tasks to 3 at a time to avoid issues with requests getting throttled ## Summary of Changes - Add `enqueue` and `maxConcurrency: 3` to copy and move tasks - Add new message for files waiting to be moved/copied - Actually cancel move/copy tasks that haven't started when the user closes the modal * Add a 5px outline offset (#1516) * add a 5px outline offset * add outline offset for folder items * add provider logo to breadcrumbs (#1518) * Hide date when isMobile (#1517) * hide date when isMobile * add @isDesktop param to tests * [ENG-3720] Rename File Modal (#1490) * updated logic for file rename modal, added aria labels, resolved focus bug on user input, resolved file parameter when passed as an argument, resolved cancel functionality, entering debug for save upon enter and finishing tests. * added tests for enabled and disabled logic for matching file name and user input, added data test selectors to handlebars file. * added and updated values for file rename modal aria label and message notifications. * adding missing merged files from hard reset. * adding back removed tests. * adding back removed acceptance test for files-test. * adding assests back. * Deleting test file Deleing added test file * Readded deleted parameters Readded deleted parameters to ember-composable-helpers * Correcting assets Adding back the missing 'assets/images/addons/icons' from the merge * readded user input, added formatting issues for the modal on mobile, began debugging test failure, updated translations strings and file name, removed stubbed objects in Mirage test file for file item. * readded formatting for mobile view, updated OsfStorageManger to StorageManager with import. * removed RenameLink, converted OsfLink to Button, removed href and input value, removed if template logic, added DropdownItem class to button, updated validate function to get tracked property, removed unnecessary tracked properties. * removed file item component class, removed export for file item component, removed id for userInput, repositioned invocation of FileRenameModal to within FileActio nsMenu. * removed toggleRenameModal parameter inside FileActionsMenu invocation, removed unnecessary formatting for the FileRenameModal, removed currentUserPermissions within the modal, repositioned button to within currentUserCanDelete logic for FileActionsMenu template file. * removed styles for RenameModal. * Reverting changes to test. Reverting changes to test to match Develop * Updating test from feature/files-page-redesign branch Updating test from code found on Develop to code found on feature/file-page-redesign. * updated test code with feature/files-page-redesign branch instead of develop, added trailing space after FileActionsMenu template file. * revert test file * remove excessive line * fix tests * address CR Co-authored-by: Ashley Robinson <ashley@cos.io> Co-authored-by: Yuhuai Liu <yuhuai@cos.io> * [ENG-3811] Text styling for move/copy modal destinations (#1519) * Wrap text for move modal destinations * Fix left-align issues for invalid move/copy destinations * Stop reloading file after move (#1523) * [ENG-3811] Firefox multi file select (#1521) Ticket: ENG-3811 Feature flag: n/a Purpose Allow users to shift-click files/folders and select a range in firefox * Add parallelUploads limit for Github (#1520) * add parallelUploads limit for Github * set parallelUploadsLimit on File * sequential delete * green check icons * disable rename on detail view (#1525) * Allow renaming of folders (#1526) * allow renaming of folders * Update lib/osf-components/addon/components/file-browser/folder-item/template.hbs Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> * increase gutter z-index (#1527) * increase z-index of dialog background (#1529) * add z-index to main column (#1528) * Actually cancel moves on modal close (#1531) * Fix a11y problems with unseen file versions (#1530) ## Purpose Fix accessibility problems related to unseen file versions ## Summary of Changes 1. Make the bold text bolder 2. Have the aria label change based on whether you've seen the version or not * Add progress indicators, specify size limits, and moar (#1524) * add get-anything and floor helper; add progress indicators; fix some behaviors; I hate dropzone. * fix drag drop cancel * fix x button behavior * set timeout to null (#1533) * [ENG-3811] Queue move (#1534) ## Purpose - Show better message when file moves are queued ## Summary of Changes - cram the xhr status onto the file model's `move` and `copy` methods (Shoutout to @adlius ) - check status on move-file-modal template and show more informative message * Don't show copy button or allow selections if view only (#1532) ## Purpose Prevent copy from being an option if using a view-only link. ## Summary of Changes 1. Pass around isViewOnly 2. Disable selections for view_only links 3. Hide copy button for view_only links * Don't allow copying of folders in VOL (#1536) ## Purpose Prevent the copy button from showing up on the folder menu when in a View Only Link ## Summary of Changes 1. Hide the button conditionally * added styling for file rename modal width. (#1539) ## Purpose These changes update the width of the modal to accommodate fifty percent of the viewport width. ## Summary of Changes 1. lib/osf-components/addon/components/file-browser/file-rename-modal/styles.scss -Styling was added to the styles.scss file for the FileRenameModal component * Prevent replace on rename conflict (#1540) - Ticket: [ENG-3811] - Feature flag: n/a ## Purpose - Don't replace files/folders when there is a name conflict - instead appends (1), (2), etc depending on number of duplicate file/folder names discovered (similar to macOS's handling of dupe file names) * add column-gap; remove width (#1541) * Fix rendering location of dropdown in mobile view (#1535) * fix rendering location of dropdown in mobile view * Make it a11y compliant * add aria label * [ENG-3849] Add file sizes to list view (#1542) ## Purpose Show the file sizes on the files page list view ## Summary of Changes 1. Make the flexbox into pretty columns 2. Add the file sizes to the list view * [ENG-3822] Update file help modal (#1522) ## Purpose - Add new content to the file help modal based on what users are able to do ## Summary of Changes - Add new sections for selecting, moving/copying, uploading files, and selecting file-providers - Add logic to help modal to show/hide selecting, moving/copying, uploading based on what is allowed in the current view * Tracked isLoading; set to true when parameter refreshes (#1544) * tracked isLoading; set to true when parameter refreshes * dont care about lastDownload * Fix storage limit async call and DRY (#1537) ## Purpose When the backend is fixed for the storage limit calculation problem, this will still be needed to ensure that the call completes before the calculation is made. ## Summary of Changes 1. Await the call to storage 2. DRY up the code * Disable copying for registration files (#1545) ## Purpose Make sure the copy option is not available if you're viewing a registrations' files ## Summary of Changes 1. Add a getter for target is registration 2. Disable copy button on file menu 3. Disable copy button on folder menu * [ENG-3811] Fix status monkeypatch for empty request data (#1543) ## Purpose - Show informative message for moves/copies that have been queued ## Summary of Changes - Fix how we add status to the returned data - For requests that are immediately processed (201), the returned data is an object that we could patch data onto - For requests that are queued (202), the returned data is an empty string, so the patch did not work * add enter behavior for rename and create folder modals; reload list after renaming (#1551) * [ENG-3811] Make it easier to select rows (#1547) ## Purpose When I added the file sizes, I made the flex box act columnar. This had the side-effect of extending the divs/buttons that had a z-index of 9, making the click target for a selection much smaller than it had been. This reduces the surface area of the z-indexed items to just be the clickable targets and prevents the button from extending the width of the column in the case of folders. ## Summary of Changes 1. Juggle around z-index 2. Restrict size of button to not be the width of the column * [ENG-3811] Fix storage limit code (#1550) ## Purpose Make storage usage actually work in the places it needs to. The basic problem was that, while getters get magic from ember to wait for async calls as part of .get(), they don't get access to that if the gets are in another async function. So I moved the getters for the storage limit into the getters for the properties that need that info. ## Summary of Changes 1. Remove async helper function 2. Update `userCanMoveToHere` 3. Fix incorrect property on multi-select move button 4. Add 'withStorage' trait where needed ## Side Effects You have to use the 'withStorage' trait if you want a mirage node that can use its files page. * Improve selected item highlight contrast (#1553) * improve selected contrast * change highlight color to color-text-blue-dark * Wrap current destination node in move-file-modal (#1554) ## Purpose - Prevent current destination node name from getting cut off in move/copy file modal in mobile ## Summary of Changes - Wrap. That. Text * add exceeds storage limit error message (#1548) * [ENG-3811] Handle specific file move error cases (#1552) ## Purpose - Show better error messages for over storage limit and dupe file names ## Summary of Changes - Update modal header text to show users the move/copy has finished - Add new messages for over storage limit (507) and dupe file names (409) - Add test * [ENG-3811] Warning for special chars in help modal (#1555) ## Purpose - add some text to warn users about special characters in the file browser's help modal ## Summary of Changes - Update translation for Upload and Rename section of help modal * Show add new dropdown on the other right side (the left side) (#1556) ## Purpose - Adjust where the "Add new file" dropdown content shows up to prevent it from going off screen ## Summary of Changes - Switch counterintuitive argument * set maxConcurrency to 1 (#1558) * [ENG-3811] Miscellaneous bugs (#1546) ## Purpose The purpose of this change was to update the variable storing the original file name. Upon a successful rename, it should update to the accepted value even on subsequent renames. ## Summary of Changes 1. lib/osf-components/addon/components/file-browser/file-rename-modal/component.ts -Added a return statement to the resetFileNameValue() function for code hygiene and added a function for updating the original file name * Change help guide link for registrations (#1560) ## Purpose - Update help link depending on viewing registration files or project files ## Summary of Changes - Add condition to help modal - Add translation * Change currentUserHasViewed to showAsUnviewed (#1559) ## Purpose Change the attribute on the file model for showing unviewed files to match the new back-end. ## Summary of Changes 1. Change the file model 2. Change the file class * Update z-index for checkout icon (#1561) - Ticket: [ENG-3811] - Feature flag: n/a ## Purpose - Show hover text for checked out files Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Co-authored-by: Brian Geiger <bgeiger@cos.io> Co-authored-by: chth0n1x <82047646+chth0n1x@users.noreply.github.com> Co-authored-by: Ashley Robinson <ashley@cos.io>
1 parent e75ba45 commit f574d1c

File tree

150 files changed

+5639
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+5639
-564
lines changed

app/guid-file/-components/file-detail-layout/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
.MainColumn {
88
flex-grow: 3;
9+
z-index: 1;
910

1011
h3 {
1112
text-overflow: ellipsis;

app/guid-file/controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Controller from '@ember/controller';
22
import { action } from '@ember/object';
3+
import RouterService from '@ember/routing/router-service';
34
import { inject as service } from '@ember/service';
45
import { tracked } from '@glimmer/tracking';
56
import { taskFor } from 'ember-concurrency-ts';
@@ -9,6 +10,7 @@ import Toast from 'ember-toastr/services/toast';
910
export default class GuidFile extends Controller {
1011
@service media!: Media;
1112
@service toast!: Toast;
13+
@service router!: RouterService;
1214

1315
@tracked revisionsOpened = false;
1416
@tracked tagsOpened = false;
@@ -76,4 +78,9 @@ export default class GuidFile extends Controller {
7678
}
7779
}
7880
}
81+
82+
@action
83+
onDelete() {
84+
this.router.transitionTo('guid-node.files', this.model.fileModel.target.get('id'));
85+
}
7986
}

app/guid-file/route.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ import Analytics from 'ember-osf-web/services/analytics';
1212
import MetaTags, { HeadTagDef } from 'ember-osf-web/services/meta-tags';
1313
import Ready from 'ember-osf-web/services/ready';
1414
import OsfStorageFile from 'ember-osf-web/packages/files/osf-storage-file';
15+
import BitbucketFile from 'ember-osf-web/packages/files/bitbucket-file';
16+
import BoxFile from 'ember-osf-web/packages/files/box-file';
17+
import DataverseFile from 'ember-osf-web/packages/files/dataverse-file';
18+
import DropboxFile from 'ember-osf-web/packages/files/dropbox-file';
19+
import FigshareFile from 'ember-osf-web/packages/files/figshare-file';
20+
import GithubFile from 'ember-osf-web/packages/files/github-file';
21+
import GitlabFile from 'ember-osf-web/packages/files/gitlab-file';
22+
import GoogleDriveFile from 'ember-osf-web/packages/files/google-drive-file';
23+
import OneDriveFile from 'ember-osf-web/packages/files/one-drive-file';
24+
import OwnCloudFile from 'ember-osf-web/packages/files/own-cloud-file';
25+
import S3File from 'ember-osf-web/packages/files/s3-file';
1526
import CurrentUserService from 'ember-osf-web/services/current-user';
1627
import RegistrationModel from 'ember-osf-web/models/registration';
1728

@@ -51,8 +62,50 @@ export default class GuidFile extends Route {
5162
if (target.withdrawn === true) {
5263
this.transitionTo('guid-registration', target.id);
5364
}
54-
const osfStorageFile = new OsfStorageFile(this.currentUser, file);
55-
return osfStorageFile;
65+
const provider = file.provider;
66+
let storageFile;
67+
68+
switch(provider){
69+
case 'osfstorage':
70+
storageFile = new OsfStorageFile(this.currentUser, file);
71+
break;
72+
case 'bitbucket':
73+
storageFile = new BitbucketFile(this.currentUser, file);
74+
break;
75+
case 'box':
76+
storageFile = new BoxFile(this.currentUser, file);
77+
break;
78+
case 'dataverse':
79+
storageFile = new DataverseFile(this.currentUser, file);
80+
break;
81+
case 'dropbox':
82+
storageFile = new DropboxFile(this.currentUser, file);
83+
break;
84+
case 'figshare':
85+
storageFile = new FigshareFile(this.currentUser, file);
86+
break;
87+
case 'github':
88+
storageFile = new GithubFile(this.currentUser, file);
89+
break;
90+
case 'gitlab':
91+
storageFile = new GitlabFile(this.currentUser, file);
92+
break;
93+
case 'googledrive':
94+
storageFile = new GoogleDriveFile(this.currentUser, file);
95+
break;
96+
case 'onedrive':
97+
storageFile = new OneDriveFile(this.currentUser, file);
98+
break;
99+
case 'owncloud':
100+
storageFile = new OwnCloudFile(this.currentUser, file);
101+
break;
102+
case 's3':
103+
storageFile = new S3File(this.currentUser, file);
104+
break;
105+
default:
106+
this.transitionTo('not-found', guid);
107+
}
108+
return storageFile;
56109
} catch (error) {
57110
this.transitionTo('not-found', guid);
58111
throw error;

app/guid-file/template.hbs

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
({{t 'general.version'}}: {{this.viewedVersion}})
2222
{{/if}}
2323
</h2>
24-
<FileActionsMenu @item={{this.model.fileModel}} />
24+
<FileActionsMenu @item={{this.model}} @onDelete={{this.onDelete}} @allowRename={{false}} />
2525
</div>
2626
</:header>
2727
<:body>
@@ -33,70 +33,78 @@
3333
</div>
3434
</:body>
3535
<:right>
36-
{{#if this.revisionsOpened}}
37-
<section data-test-revisions-tab local-class='FileDetail__revisions'>
38-
<h2 local-class='FileDetail__right-section-heading'>{{t 'general.revisions'}}</h2>
39-
<ol local-class='FileDetail__revision-list' reversed>
40-
<hr>
41-
{{#if this.model.getRevisions.isRunning}}
42-
<LoadingIndicator @dark={{true}} />
43-
{{else}}
44-
{{#each this.model.waterButlerRevisions as |version|}}
45-
<FileVersion
46-
@version={{version}}
47-
@downloadUrl={{this.model.links.download}}
48-
@changeVersion={{this.changeVersion}}
49-
/>
50-
<hr>
36+
{{#if (or this.model.shouldShowTags this.model.shouldShowRevisions) }}
37+
{{#if this.revisionsOpened}}
38+
<section data-test-revisions-tab local-class='FileDetail__revisions'>
39+
<h2 local-class='FileDetail__right-section-heading'>{{t 'general.revisions'}}</h2>
40+
<ol local-class='FileDetail__revision-list' reversed>
41+
<hr aria-hidden='true'>
42+
{{#if this.model.getRevisions.isRunning}}
43+
<LoadingIndicator @dark={{true}} />
5144
{{else}}
52-
{{t 'file_detail.no_revisions'}}
53-
{{/each}}
54-
{{/if}}
55-
</ol>
56-
</section>
57-
{{/if}}
58-
{{#if this.tagsOpened}}
59-
<div local-class='RightContainer'>
60-
<h2>{{t 'general.tags'}}</h2>
61-
<TagsWidget
62-
@taggable={{this.model.fileModel}}
63-
@readOnly={{not this.model.userCanEditMetadata}}
64-
@inline={{true}}
65-
/>
66-
</div>
45+
{{#each this.model.waterButlerRevisions as |version|}}
46+
<FileVersion
47+
@version={{version}}
48+
@downloadUrl={{this.model.links.download}}
49+
@changeVersion={{this.changeVersion}}
50+
/>
51+
<hr aria-hidden='true'>
52+
{{else}}
53+
{{t 'file_detail.no_revisions'}}
54+
{{/each}}
55+
{{/if}}
56+
</ol>
57+
</section>
58+
{{/if}}
59+
{{#if this.tagsOpened}}
60+
<div local-class='RightContainer'>
61+
<h2>{{t 'general.tags'}}</h2>
62+
<TagsWidget
63+
@taggable={{this.model.fileModel}}
64+
@readOnly={{not this.model.userCanEditMetadata}}
65+
@inline={{true}}
66+
/>
67+
</div>
68+
{{/if}}
6769
{{/if}}
6870
</:right>
6971
<:rightButtons>
70-
{{#if this.media.isMobile}}
71-
<BsButton
72-
data-test-file-renderer-button
73-
data-analytics-name='File renderer button'
74-
local-class='SlideButtons {{if this.rightColumnClosed 'Active'}}'
75-
@size='lg'
76-
@onClick={{this.toggleFileRenderer}}
77-
>
78-
<FaIcon @icon='file-alt' @fixedWidth={{true}}/>
79-
</BsButton>
72+
{{#if (or this.model.shouldShowTags this.model.shouldShowRevisions) }}
73+
{{#if this.media.isMobile}}
74+
<BsButton
75+
data-test-file-renderer-button
76+
data-analytics-name='File renderer button'
77+
local-class='SlideButtons {{if this.rightColumnClosed 'Active'}}'
78+
@size='lg'
79+
@onClick={{this.toggleFileRenderer}}
80+
>
81+
<FaIcon @icon='file-alt' @fixedWidth={{true}}/>
82+
</BsButton>
83+
{{/if}}
84+
{{#if this.model.shouldShowRevisions}}
85+
<BsButton
86+
aria-label={{if this.revisionsOpened (t 'file_detail.close_revisions') (t 'file_detail.view_revisions')}}
87+
data-test-versions-button
88+
data-analytics-name='Versions button'
89+
local-class='SlideButtons {{if this.revisionsOpened 'Active'}}'
90+
@size='lg'
91+
@onClick={{this.toggleRevisions}}
92+
>
93+
<FaIcon @icon='history' @fixedWidth={{true}}/>
94+
</BsButton>
95+
{{/if}}
96+
{{#if this.model.shouldShowTags}}
97+
<BsButton
98+
aria-label={{if this.tagsOpened (t 'file_detail.close_tags') (t 'file_detail.view_tags')}}
99+
data-test-tags-button
100+
data-analytics-name='Tags button'
101+
local-class='SlideButtons {{if this.tagsOpened 'Active'}}'
102+
@size='lg'
103+
@onClick={{this.toggleTags}}
104+
>
105+
<FaIcon @icon='tags' @fixedWidth={{true}}/>
106+
</BsButton>
107+
{{/if}}
80108
{{/if}}
81-
<BsButton
82-
aria-label={{if this.revisionsOpened (t 'file_detail.close_revisions') (t 'file_detail.view_revisions')}}
83-
data-test-versions-button
84-
data-analytics-name='Versions button'
85-
local-class='SlideButtons {{if this.revisionsOpened 'Active'}}'
86-
@size='lg'
87-
@onClick={{this.toggleRevisions}}
88-
>
89-
<FaIcon @icon='history' @fixedWidth={{true}}/>
90-
</BsButton>
91-
<BsButton
92-
aria-label={{if this.tagsOpened (t 'file_detail.close_tags') (t 'file_detail.view_tags')}}
93-
data-test-tags-button
94-
data-analytics-name='Tags button'
95-
local-class='SlideButtons {{if this.tagsOpened 'Active'}}'
96-
@size='lg'
97-
@onClick={{this.toggleTags}}
98-
>
99-
<FaIcon @icon='tags' @fixedWidth={{true}}/>
100-
</BsButton>
101109
</:rightButtons>
102110
</GuidFile::-Components::FileDetailLayout>

app/guid-node/controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Controller from '@ember/controller';
2+
import RouterService from '@ember/routing/router-service';
3+
import { inject as service } from '@ember/service';
4+
5+
6+
export default class GuidNode extends Controller {
7+
@service router!: RouterService;
8+
9+
get shouldHideNodeNavbar() {
10+
return this.router.currentRouteName === 'guid-node.files.provider';
11+
}
12+
}

app/guid-node/files/index/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class GuidNodeFileIndexRoute extends Route.extend({}) {
4+
beforeModel() {
5+
return this.replaceWith('guid-node.files.provider', 'osfstorage');
6+
}
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Controller from '@ember/controller';
2+
import { inject as service } from '@ember/service';
3+
import Media from 'ember-responsive';
4+
5+
export default class GuidNodeFilesProvider extends Controller {
6+
@service media!: Media;
7+
8+
get isDesktop() {
9+
return this.media.isDesktop;
10+
}
11+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
import { waitFor } from '@ember/test-waiters';
4+
import { task } from 'ember-concurrency';
5+
import { taskFor } from 'ember-concurrency-ts';
6+
7+
import Intl from 'ember-intl/services/intl';
8+
import Toast from 'ember-toastr/services/toast';
9+
import FileProviderModel from 'ember-osf-web/models/file-provider';
10+
import NodeModel from 'ember-osf-web/models/node';
11+
import { Permission } from 'ember-osf-web/models/osf-model';
12+
import { GuidRouteModel } from 'ember-osf-web/resolve-guid/guid-route';
13+
import CurrentUser from 'ember-osf-web/services/current-user';
14+
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';
15+
16+
export default class GuidNodeFilesProviderRoute extends Route.extend({}) {
17+
@service currentUser!: CurrentUser;
18+
@service intl!: Intl;
19+
@service toast!: Toast;
20+
21+
@task
22+
@waitFor
23+
async fileProviderTask(guidRouteModel: GuidRouteModel<NodeModel>, fileProviderId: string) {
24+
const node = await guidRouteModel.taskInstance;
25+
try {
26+
const fileProviders = await node.queryHasMany(
27+
'files',
28+
{
29+
'page[size]': 20,
30+
},
31+
);
32+
const provider = fileProviders.findBy('id', fileProviderId) as FileProviderModel;
33+
const hasWritePermission = node.currentUserPermissions.includes(Permission.Write);
34+
const isViewOnly = Boolean(this.currentUser.viewOnlyToken);
35+
return {provider, fileProviders, node, hasWritePermission, isViewOnly};
36+
} catch (e) {
37+
const errorMessage = this.intl.t(
38+
'osf-components.file-browser.errors.load_file_providers',
39+
);
40+
captureException(e, { errorMessage });
41+
this.toast.error(getApiErrorMessage(e), errorMessage);
42+
return {};
43+
}
44+
}
45+
46+
model(params: { providerId: string }) {
47+
const node = this.modelFor('guid-node');
48+
const fileProviderId = node.guid + ':' + params.providerId;
49+
return {
50+
node,
51+
providerName: params.providerId,
52+
providerTask: taskFor(this.fileProviderTask).perform(node, fileProviderId),
53+
};
54+
}
55+
}

0 commit comments

Comments
 (0)