Add folder sharing dialog (empty yet)

This commit is contained in:
Aleksander Machniak 2018-10-04 14:04:16 +00:00
parent 31634a76f6
commit db8e81e202
9 changed files with 131 additions and 4 deletions

View file

@ -190,6 +190,9 @@ function kolab_files_init()
// get ongoing sessions
file_api.request('folder_info', {folder: file_api.file_path(rcmail.env.file), sessions: 1}, 'folder_info_response');
}
else if (rcmail.env.action == 'share') {
// do nothing
}
else {
file_api.env.init_folder = rcmail.env.folder;
file_api.env.init_collection = rcmail.env.collection;
@ -518,6 +521,18 @@ function kolab_files_folder_edit_dialog()
file_api.folder_select_element(select, {selected: path, empty: true});
};
// folder sharing dialog
function kolab_files_folder_share_dialog()
{
var dialog = $('<iframe>').attr('src', rcmail.url('share', {folder: file_api.env.folder, _framed: 1}));
rcmail.simple_dialog(dialog, rcmail.gettext('kolab_files.foldershare'), null, {
cancel_button: 'close',
width: 600,
height: 500
});
};
// folder mounting dialog
function kolab_files_folder_mount_dialog()
{
@ -1945,6 +1960,12 @@ rcube_webmail.prototype.folder_rename = function(prop, elem, event)
kolab_files_folder_edit_dialog();
};
rcube_webmail.prototype.folder_share = function(prop, elem, event)
{
this.hide_menu('folderoptions', event);
kolab_files_folder_share_dialog();
};
rcube_webmail.prototype.folder_mount = function(prop, elem, event)
{
this.hide_menu('folderoptions', event);
@ -2022,6 +2043,21 @@ function kolab_files_ui()
return true;
};
// Check if specified folder (hierarchy) supports sharing
this.is_shareable = function(folder)
{
if (!folder)
folder = this.env.folder;
if (!folder)
return false;
var root = folder.split(this.env.directory_separator)[0],
caps = this.env.caps.MOUNTPOINTS && this.env.caps.MOUNTPOINTS[root] ? this.env.caps.MOUNTPOINTS[root] : this.env.caps;
return !!caps.ACL;
};
// folders list request
this.folder_list = function(params)
{
@ -2199,6 +2235,7 @@ function kolab_files_ui()
rcmail.enable_command('files-list', true);
rcmail.enable_command('files-folder-delete', 'folder-rename', !is_collection);
rcmail.enable_command('files-upload', !is_collection && this.is_writable());
rcmail.enable_command('folder-share', !is_collection && this.is_shareable());
rcmail.command('files-list', is_collection ? {collection: collection} : {folder: folder});
this.quota();

View file

@ -50,6 +50,7 @@ class kolab_files extends rcube_plugin
$this->register_action('prefs', array($this, 'actions'));
$this->register_action('open', array($this, 'actions'));
$this->register_action('edit', array($this, 'actions'));
$this->register_action('share', array($this, 'actions'));
$this->register_action('autocomplete', array($this, 'autocomplete'));
// we use libkolab::http_request() from libkolab with its configuration

View file

@ -106,7 +106,7 @@ class kolab_files_engine
$this->get_external_storage_drivers();
// these labels may be needed even if fetching ext sources failed
$this->plugin->add_label('folderauthtitle', 'authenticating');
$this->plugin->add_label('folderauthtitle', 'authenticating', 'foldershare');
}
if ($list_widget) {
@ -358,6 +358,19 @@ class kolab_files_engine
);
}
/**
* Template object for sharing form
*/
public function folder_share_form($attrib)
{
$folder = rcube_utils::get_input_value('folder', rcube_utils::INPUT_POST, true);
$form = $this->get_share_form($folder);
print_r($form);
$this->rc->output->set_env('folder', $folder);
}
/**
* Template object for file edit dialog/warnings
*/
@ -1073,6 +1086,16 @@ class kolab_files_engine
$this->file_opener(intval($_GET['_viewer']));
}
/**
* Handler for folder sharing action
*/
protected function action_share()
{
$this->rc->output->add_handler('share-form', array($this, 'folder_share_form'));
$this->rc->output->send('kolab_files.share');
}
/**
* Handler for "save all attachments into cloud" action
*/
@ -1555,6 +1578,36 @@ class kolab_files_engine
$this->rc->output->set_env('external_sources', $sources);
}
/**
* Get list of available external storage drivers
*/
protected function get_share_form($folder)
{
// first get configured sources from Chwala
$token = $this->get_api_token();
$request = $this->get_request(array('method' => 'sharing', 'folder' => $folder), $token);
// send request to the API
try {
$response = $request->send();
$status = $response->getStatus();
$body = @json_decode($response->getBody(), true);
if ($status == 200 && $body['status'] == 'OK') {
$form = $body['result'];
}
else {
throw new Exception($body['reason'] ?: "Failed to get sharing form information. Status: $status");
}
}
catch (Exception $e) {
rcube::raise_error($e, true, false);
return;
}
return $form;
}
/**
* Registers translation labels for folder lists in UI
*/

View file

@ -21,12 +21,15 @@ $labels['selectfiles'] = 'Select file(s) to attach...';
$labels['attachsel'] = 'Attach selected';
$labels['foldercreate'] = 'Create folder';
$labels['addfolder'] = 'Add folder';
$labels['foldershare'] = 'Share folder';
$labels['folderedit'] = 'Edit folder';
$labels['folderrename'] = 'Rename folder';
$labels['foldermount'] = 'Add storage';
$labels['folderdelete'] = 'Delete folder';
$labels['folderoptions'] = 'Folder options';
$labels['findfolders'] = 'Find folders';
$labels['findfiles'] = 'Find files';
$labels['share'] = 'Share';
$labels['folderinside'] = 'Insert inside';
$labels['foldername'] = 'Folder name';

View file

@ -132,12 +132,13 @@
<h3 id="aria-label-folderoptions" class="voice"><roundcube:label name="kolab_files.folderoptions" /></h3>
<ul class="toolbarmenu listing" role="menu" aria-labelledby="aria-label-folderoptions">
<roundcube:button type="link-menuitem" command="folder-create" label="kolab_files.addfolder" class="create disabled" classAct="create active" />
<roundcube:button type="link-menuitem" command="folder-rename" label="rename" class="rename" classAct="rename active" />
<roundcube:button type="link-menuitem" command="files-folder-delete" label="delete" class="delete" classAct="delete active" />
<roundcube:button type="link-menuitem" command="folder-rename" label="kolab_files.folderrename" class="rename" classAct="rename active" />
<roundcube:button type="link-menuitem" command="folder-share" label="kolab_files.foldershare" class="share" classAct="share active" />
<roundcube:button type="link-menuitem" command="files-folder-delete" label="kolab_files.folderdelete" class="delete" classAct="delete active" />
<roundcube:button type="link-menuitem" command="folders" task="settings" label="managefolders" class="folders" classAct="folders active" />
<roundcube:if condition="!empty(env:external_sources)" />
<roundcube:button type="link-menuitem" command="folder-mount" label="kolab_files.foldermount" class="mount storage" classAct="mount storage active" />
<roundcube:endif />
<roundcube:button type="link-menuitem" command="folders" task="settings" label="managefolders" class="folders" classAct="folders active" />
</ul>
</div>

View file

@ -0,0 +1,9 @@
<roundcube:include file="includes/layout.html" />
<h1 class="voice"><roundcube:label name="kolab_files.foldershare" /></h1>
<div class="formcontent">
<roundcube:object name="share-form" id="shareform" class="tabbed propform" />
</div>
<roundcube:include file="includes/footer.html" />

View file

@ -76,6 +76,7 @@
<h3 id="aria-label-folderoptions" class="voice"><roundcube:label name="kolab_files.folderoptions" /></h3>
<ul id="folderoptionsmenu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-folderoptions">
<li role="menuitem"><roundcube:button type="link" command="folder-rename" label="rename" classAct="active" /></li>
<li role="menuitem"><roundcube:button type="link" command="folder-share" label="kolab_files.share" classAct="active" /></li>
<li role="menuitem"><roundcube:button type="link" command="files-folder-delete" label="delete" classAct="active" /></li>
<roundcube:if condition="!empty(env:external_sources)" />
<li role="menuitem"><roundcube:button type="link" command="folder-mount" label="kolab_files.foldermount" classAct="active" /></li>

View file

@ -0,0 +1,18 @@
<roundcube:object name="doctype" value="html5" />
<html>
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
</head>
<body class="iframe fullheight">
<h1 class="voice"><roundcube:label name="kolab_files.foldershare" /></h1>
<div id="folder-share" class="boxcontent">
<roundcube:object name="share-form" id="folder-shareform" class="tabbed" />
</div>
<roundcube:include file="/includes/footer.html" />
</body>
</html>

View file

@ -45,6 +45,10 @@ a.button.saveas:before {
content: @fa-var-times;
}
.listing li a.share:before {
content: @fa-var-share-alt;
}
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset a.btn-link.options.add-folder {
order: -1;