Skip to content

Commit

Permalink
[NEW] Download button for each file in fileslist (#12874)
Browse files Browse the repository at this point in the history
* Add menu icon to fileslist items and implement download-action.

* Import global popover
  • Loading branch information
alexbartsch authored and rodrigok committed Dec 20, 2018
1 parent 9f53f32 commit 6215f34
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<span class="attachments__details">{{formatTimestamp uploadedAt}}</span>
</span>
</a>

{{> icon file=. block="attachments-menu js-action" icon="menu"}}

</li>
{{/each}}
</ul>
Expand Down
37 changes: 37 additions & 0 deletions packages/rocketchat-ui-flextab/client/tabs/uploadedFilesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Mongo } from 'meteor/mongo';
import { fixCordova } from 'meteor/rocketchat:lazy-load';
import { ReactiveVar } from 'meteor/reactive-var';
import { DateFormat } from 'meteor/rocketchat:lib';
import { popover } from 'meteor/rocketchat:ui';
import { Template } from 'meteor/templating';
import _ from 'underscore';

Expand Down Expand Up @@ -119,4 +120,40 @@ Template.uploadedFilesList.events({
return t.limit.set(t.limit.get() + 50);
}
}, 200),

'click .js-action'(e) {
e.currentTarget.parentElement.classList.add('active');

const config = {
columns: [
{
groups: [
{
items: [
{
icon: 'import',
name: t('Download'),
action: () => {
const a = document.createElement('a');
a.href = this.file.url;
a.download = this.file.name;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(this.file.url);
a.remove();
},
},
],
},
],
},
],
currentTarget: e.currentTarget,
onDestroyed:() => {
e.currentTarget.parentElement.classList.remove('active');
},
};

popover.open(config);
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,21 @@

.attachments {
&__item {
position: relative;

margin-bottom: 10px;

transition: background-color 300ms linear;

&.active,
&:hover {
cursor: pointer;

background-color: #f7f8fa;

.attachments-menu {
display: inline-block;
}
}

&-link {
Expand Down Expand Up @@ -231,6 +237,24 @@
}
}

.attachments-menu {
position: absolute;
top: 8px;
right: 8px;

display: none;

color: var(--color-darkest);

font-size: 16px;

fill: currentColor;

&:hover {
fill: var(--rc-color-button-primary);
}
}

.contextual-bar__content.mail-messages {
& .rc-popup-list {
z-index: 1;
Expand Down

0 comments on commit 6215f34

Please sign in to comment.