Skip to content
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

[NEW] WebDAV Integration (User file provider) #11679

Merged
merged 17 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ rocketchat:ui-vrecord
rocketchat:user-data-download
rocketchat:version
rocketchat:videobridge
rocketchat:webdav
rocketchat:webrtc
rocketchat:wordpress
rocketchat:nrr
Expand Down
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
[email protected]
Expand Down
2 changes: 0 additions & 2 deletions packages/rocketchat-file-upload/ufs/Webdav/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class WebdavStore extends UploadFS.Store {

super(options);


const client = new Webdav(
options.connection.credentials.server,
options.connection.credentials.username,
Expand Down Expand Up @@ -127,7 +126,6 @@ export class WebdavStore extends UploadFS.Store {
writeStream.pipe(webdavStream);
return writeStream;
};

}
}

Expand Down
13 changes: 13 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@
"Copy": "Copy",
"Copy_to_clipboard": "Copy to clipboard",
"COPY_TO_CLIPBOARD": "COPY TO CLIPBOARD",
"could-not-access-webdav": "Could not access WebDAV",
"Count": "Count",
"Country": "Country",
"Country_Afghanistan": "Afghanistan",
Expand Down Expand Up @@ -971,6 +972,7 @@
"Drop_to_upload_file": "Drop to upload file",
"Dry_run": "Dry run",
"Dry_run_description": "Will only send one email, to the same address as in From. The email must belong to a valid user.",
"duplicated-account": "Duplicated account",
"Duplicate_archived_channel_name": "An archived Channel with name `#%s` exists",
"Duplicate_archived_private_group_name": "An archived Private Group with name '%s' exists",
"Duplicate_channel_name": "A Channel with name '%s' exists",
Expand Down Expand Up @@ -1065,6 +1067,7 @@
"error-importer-not-defined": "The importer was not defined correctly, it is missing the Import class.",
"error-input-is-not-a-valid-field": "__input__ is not a valid __field__",
"error-invalid-actionlink": "Invalid action link",
"error-invalid-account": "Invalid Account",
"error-invalid-arguments": "Invalid arguments",
"error-invalid-asset": "Invalid asset",
"error-invalid-channel": "Invalid channel.",
Expand Down Expand Up @@ -2279,6 +2282,7 @@
"Save_changes": "Save changes",
"Save_Mobile_Bandwidth": "Save Mobile Bandwidth",
"Save_to_enable_this_action": "Save to enable this action",
"Save_To_Webdav": "Save to WebDAV",
"Saved": "Saved",
"Saving": "Saving",
"Scan_QR_code": "Using an authenticator app like Google Authenticator, Authy or Duo, scan the QR code. It will display a 6 digit code which you need to enter below.",
Expand Down Expand Up @@ -2658,7 +2662,9 @@
"Upload_file_description": "File description",
"Upload_file_name": "File name",
"Upload_file_question": "Upload file?",
"Upload_Folder_Path": "Upload Folder Path",
"Upload_user_avatar": "Upload avatar",
"Upload_From" : "Upload from __name__",
"Uploading_file": "Uploading file...",
"Uptime": "Uptime",
"URL": "URL",
Expand Down Expand Up @@ -2826,6 +2832,13 @@
"We_are_offline_Sorry_for_the_inconvenience": "We are offline. Sorry for the inconvenience.",
"We_have_sent_password_email": "We have sent you an email with password reset instructions. If you do not receive an email shortly, please come back and try again.",
"We_have_sent_registration_email": "We have sent you an email to confirm your registration. If you do not receive an email shortly, please come back and try again.",
"WebDAV_Accounts": "WebDAV Accounts",
"Webdav_add_new_account": "Add new WebDAV account",
"webdav-account-saved": "WebDAV account saved",
"Webdav_Integration_Enabled": "Webdav Integration Enabled",
"Webdav_Server_URL": "WebDAV Server Access URL",
"Webdav_Username": "WebDAV Username",
"Webdav_Password": "WebDAV Password",
"Webhook_URL": "Webhook URL",
"Webhooks": "Webhooks",
"WebRTC_direct_audio_call_from_%s": "Direct audio call from %s",
Expand Down
11 changes: 9 additions & 2 deletions packages/rocketchat-lib/lib/messageBox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
RocketChat.messageBox = {};
import EventEmitter from 'wolfy87-eventemitter';

RocketChat.messageBox = new EventEmitter;

RocketChat.messageBox.actions = new class {
constructor() {
Expand Down Expand Up @@ -31,7 +33,12 @@ RocketChat.messageBox.actions = new class {

this.actions[group].push({ ...config, label });
}

remove(group, expression) {
if (!group || !this.actions[group]) {
return false;
}
return (this.actions[group] = this.actions[group].filter((action) => expression.test(action.id)));
}
get(group) {
if (!group) {
return Object.keys(this.actions).reduce((ret, key) => {
Expand Down
20 changes: 10 additions & 10 deletions packages/rocketchat-livechat/.app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/rocketchat-ui-account/client/accountFlex.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ <h1 class="sidebar-flex__title">{{_ "My_Account"}}</h1>

{{> sidebarItem menuItem "Security" "lock" "account" "security" }}

{{> sidebarItem menuItem "Integrations" "code" "account" "integrations" }}

{{#if accessTokensEnabled}}
{{> sidebarItem menuItem "Personal_Access_Tokens" "key" "account" "tokens" }}
{{/if}}
Expand Down
28 changes: 28 additions & 0 deletions packages/rocketchat-ui-account/client/accountIntegrations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template name="accountIntegrations">
<section class="page-container page-home page-static">
{{> header sectionName="Integrations"}}

<div class="content">
<form id="integrations" autocomplete="off">
<fieldset class="rc-form-legend">
<div class="section">
<h1>{{_ "WebDAV"}}</h1>
<div class="section-content border-component-color">
<div class="input-line double-col">
<label for="webdav-accounts">{{_ "WebDAV_Accounts"}}</label>
<div class="rc-select">
<select id="webdav-accounts" class="rc-select__element" style="text-transform: none" multiple>
{{#each webdavAccounts}}
<option value="{{this._id}}">{{getOptionValue this}}</option>
{{/each}}
</select>
</div>
<button class="rc-button rc-button--cancel webdav-account-remove"><span>{{_ "Remove"}}</span></button>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</section>
</template>
33 changes: 33 additions & 0 deletions packages/rocketchat-ui-account/client/accountIntegrations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global */

import toastr from 'toastr';

Template.accountIntegrations.helpers({
webdavAccounts() {
return RocketChat.models.WebdavAccounts.find().fetch();
},
getOptionValue(account) {
return account.name || `${ account.username }@${ account.server_url.replace(/^https?\:\/\//i, '') }`;
},
});

Template.accountIntegrations.events({
'click .webdav-account-remove'(e) {
e.preventDefault();
const selectEl = document.getElementById('webdav-accounts');
const { options } = selectEl;
const selectedOption = selectEl.value;
const optionIndex = Array.from(options).findIndex((option) => option.value === selectedOption);

Meteor.call('removeWebdavAccount', selectedOption, function(error) {
if (error) {
return toastr.error(t(error.error));
}

toastr.success(t('webdav-account-removed'));
modal.close();
});

selectEl.remove(optionIndex);
},
});
2 changes: 2 additions & 0 deletions packages/rocketchat-ui-account/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ Package.onUse(function(api) {

api.addFiles('client/account.html', 'client');
api.addFiles('client/accountFlex.html', 'client');
api.addFiles('client/accountIntegrations.html', 'client');
api.addFiles('client/accountPreferences.html', 'client');
api.addFiles('client/accountProfile.html', 'client');
api.addFiles('client/avatar/avatar.html', 'client');
api.addFiles('client/avatar/prompt.html', 'client');

api.addFiles('client/account.js', 'client');
api.addFiles('client/accountFlex.js', 'client');
api.addFiles('client/accountIntegrations.js', 'client');
api.addFiles('client/accountPreferences.js', 'client');
api.addFiles('client/accountProfile.js', 'client');
api.addFiles('client/avatar/avatar.js', 'client');
Expand Down
16 changes: 16 additions & 0 deletions packages/rocketchat-ui-master/public/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/rocketchat-ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ Template.messageBox.onCreated(function() {
this.dataReply = new ReactiveVar(''); // if user is replying to a mssg, this will contain data of the mssg being replied to
this.isMessageFieldEmpty = new ReactiveVar(true);
this.sendIcon = new ReactiveVar(false);
RocketChat.messageBox.emit('created', this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep this? It is not being used anywhere but still there is some value.

});

Meteor.startup(function() {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui/client/views/app/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ this.modal = {
this.config = config;

if (config.dontAskAgain) {
const dontAskAgainList = RocketChat.getUserPreference(Meteor.user(), 'dontAskAgainList');
const dontAskAgainList = RocketChat.getUserPreference(Meteor.userId(), 'dontAskAgainList');

if (dontAskAgainList && dontAskAgainList.some((dontAsk) => dontAsk.action === config.dontAskAgain.action)) {
this.confirm(true);
Expand Down Expand Up @@ -61,7 +61,7 @@ this.modal = {
errorEl.style.display = 'block';
},
onKeydown(e) {
if (e.key === 'Enter') {
if (e.key === 'Enter' && !/input|textarea|button/i.test(e.currentTarget.activeElement.tagName)) {
e.preventDefault();
e.stopPropagation();

Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-webdav/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RocketChat WebDAV

Package for RocketChat users to interact with WebDAV servers (Tested with ownCloud and Nextcloud).
45 changes: 45 additions & 0 deletions packages/rocketchat-webdav/client/actionButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* globals modal, RocketChat*/

Meteor.startup(function() {

RocketChat.MessageAction.addButton({
id: 'webdav-upload',
icon: 'upload',
label: t('Save_To_Webdav'),
condition: (message) => {
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}
if (RocketChat.models.WebdavAccounts.findOne() == null) {
return false;
}
if (!message.file) {
return false;
}

return RocketChat.settings.get('Webdav_Integration_Enabled');
},
action() {
const [, message] = this._arguments;
const [attachment] = message.attachments;
const { file } = message;
const url = RocketChat.getURL(attachment.title_link, { full: true });
modal.open({
data: {
message,
attachment,
file,
url,
},
title: t('Save_To_Webdav'),
content: 'selectWebdavAccount',
showCancelButton: true,
showConfirmButton: false,
closeOnCancel: true,
html: true,
});
},
order: 100,
group: 'menu',
});
});
43 changes: 43 additions & 0 deletions packages/rocketchat-webdav/client/addWebdavAccount.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template name="addWebdavAccount">
<form id="add-webdav" class="content-background-color color-primary-font-color">
<div class="fields">
<div class="rc-input">
<label class="rc-input__label" for="serverURL">
<div class="rc-input__wrapper">
<input name="name" id="serverName" type="text" class="rc-input__element" autocapitalize="off" autocorrect="off" placeholder="{{_ 'Name_optional' }}"
autofocus>
<div class="input-error"></div>
</div>
</label>
</div>
<div class="rc-input">
<label class="rc-input__label" for="serverURL">
<div class="rc-input__wrapper">
<input name="serverURL" id="serverURL" type="text" class="rc-input__element" autocapitalize="off" autocorrect="off" placeholder="{{_ 'Webdav_Server_URL' }}"
autofocus>
<div class="input-error"></div>
</div>
</label>
</div>
<div class="rc-input">
<label class="rc-input__label" for="username">
<div class="rc-input__wrapper">
<input name="username" id="username" type="text" class="rc-input__element" autocapitalize="off" autocorrect="off" placeholder="{{_ 'Username' }}" autofocus>
<div class="input-error"></div>
</div>
</label>
</div>
<div class="rc-input">
<label class="rc-input__label" for="pass">
<div class="rc-input__wrapper">
<input name="pass" id="pass" type="password" class="rc-input__element" autocapitalize="off" autocorrect="off" placeholder="{{_ 'Password' }}" autofocus>
<div class="input-error"></div>
</div>
</label>
</div>
</div>
<div class="submit">
<button class="rc-button rc-button--primary"><span>{{btnAddNewServer}}</span></button>
</div>
</form>
</template>
Loading