Create and store pads in a team
This commit is contained in:
parent
79ac44de7e
commit
306fc6cdb9
@ -175,6 +175,18 @@
|
|||||||
color: @colortheme_form-color;
|
color: @colortheme_form-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cp-creation-team {
|
||||||
|
.cp-dropdown-container {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
button, .cp-dropdown-content {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.cp-creation-expire {
|
.cp-creation-expire {
|
||||||
.cp-creation-expire-picker {
|
.cp-creation-expire-picker {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ define(function () {
|
|||||||
fileHashKey: 'FS_hash',
|
fileHashKey: 'FS_hash',
|
||||||
// sessionStorage
|
// sessionStorage
|
||||||
newPadPathKey: "newPadPath",
|
newPadPathKey: "newPadPath",
|
||||||
|
newPadTeamKey: "newPadTeam",
|
||||||
newPadFileData: "newPadFileData",
|
newPadFileData: "newPadFileData",
|
||||||
// Store
|
// Store
|
||||||
displayNameKey: 'cryptpad.username',
|
displayNameKey: 'cryptpad.username',
|
||||||
|
|||||||
@ -2652,7 +2652,6 @@ define([
|
|||||||
var type = metadataMgr.getMetadataLazy().type;
|
var type = metadataMgr.getMetadataLazy().type;
|
||||||
var fromFileData = privateData.fromFileData;
|
var fromFileData = privateData.fromFileData;
|
||||||
|
|
||||||
|
|
||||||
var $body = $('body');
|
var $body = $('body');
|
||||||
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
|
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
|
||||||
var urlArgs = (Config.requireConf && Config.requireConf.urlArgs) || '';
|
var urlArgs = (Config.requireConf && Config.requireConf.urlArgs) || '';
|
||||||
@ -2685,6 +2684,64 @@ define([
|
|||||||
return q;
|
return q;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Team pad
|
||||||
|
var team;
|
||||||
|
var teamExists = privateData.teams && Object.keys(privateData.teams).length;
|
||||||
|
var $teamBlock;
|
||||||
|
// storeInTeam can be
|
||||||
|
// * a team ID ==> store in the team drive, and the team will be the owner
|
||||||
|
// * -1 ==> store in the user drive, and the user will be the owner
|
||||||
|
// * undefined ==> ask
|
||||||
|
if (teamExists) {
|
||||||
|
var teamOptions = Object.keys(privateData.teams).map(function (teamId) {
|
||||||
|
var t = privateData.teams[teamId];
|
||||||
|
return {
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {
|
||||||
|
'data-value': teamId,
|
||||||
|
'href': '#'
|
||||||
|
},
|
||||||
|
content: 'TEAM: <b>' + t.name + '</b>' // XXX
|
||||||
|
};
|
||||||
|
});
|
||||||
|
teamOptions.unshift({
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {
|
||||||
|
'data-value': '-1',
|
||||||
|
'href': '#'
|
||||||
|
},
|
||||||
|
content: Messages.settings_cat_drive
|
||||||
|
});
|
||||||
|
teamOptions.unshift({
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {
|
||||||
|
'data-value': '',
|
||||||
|
'href': '#'
|
||||||
|
},
|
||||||
|
content: ' '
|
||||||
|
});
|
||||||
|
var teamDropdownConfig = {
|
||||||
|
text: " ", // Button initial text
|
||||||
|
options: teamOptions, // Entries displayed in the menu
|
||||||
|
isSelect: true,
|
||||||
|
common: common
|
||||||
|
};
|
||||||
|
$teamBlock = UIElements.createDropdown(teamDropdownConfig);
|
||||||
|
$teamBlock.find('a').click(function () {
|
||||||
|
var id = $(this).attr('data-value');
|
||||||
|
$teamBlock.setValue(id);
|
||||||
|
});
|
||||||
|
team = h('div.cp-creation-team', [
|
||||||
|
'Store in', // XXX
|
||||||
|
$teamBlock[0],
|
||||||
|
createHelper('#', "The pad will be stored in your team's drive. If this is an owned pad, it will be owned by the team.") // XXX
|
||||||
|
]);
|
||||||
|
if (privateData.storeInTeam) {
|
||||||
|
$teamBlock.setValue(privateData.storeInTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Owned pads
|
// Owned pads
|
||||||
// Default is Owned pad
|
// Default is Owned pad
|
||||||
var owned = h('div.cp-creation-owned', [
|
var owned = h('div.cp-creation-owned', [
|
||||||
@ -2749,6 +2806,7 @@ define([
|
|||||||
var $create = $(createDiv);
|
var $create = $(createDiv);
|
||||||
|
|
||||||
$(h('div#cp-creation-form', [
|
$(h('div#cp-creation-form', [
|
||||||
|
team,
|
||||||
owned,
|
owned,
|
||||||
expire,
|
expire,
|
||||||
password,
|
password,
|
||||||
@ -2954,12 +3012,19 @@ define([
|
|||||||
|
|
||||||
var $template = $creation.find('.cp-creation-template-selected');
|
var $template = $creation.find('.cp-creation-template-selected');
|
||||||
var templateId = $template.data('id') || undefined;
|
var templateId = $template.data('id') || undefined;
|
||||||
|
// Team
|
||||||
|
var team;
|
||||||
|
if ($teamBlock && $teamBlock.getValue()) {
|
||||||
|
team = privateData.teams[$teamBlock.getValue()] || {};
|
||||||
|
team.id = Number($teamBlock.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
owned: ownedVal,
|
owned: ownedVal,
|
||||||
password: passwordVal,
|
password: passwordVal,
|
||||||
expire: expireVal,
|
expire: expireVal,
|
||||||
templateId: templateId
|
templateId: templateId,
|
||||||
|
team: team
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var create = function () {
|
var create = function () {
|
||||||
|
|||||||
@ -660,6 +660,16 @@ define([
|
|||||||
|
|
||||||
if (typeof (data.title) !== "string") { return cb('Missing title'); }
|
if (typeof (data.title) !== "string") { return cb('Missing title'); }
|
||||||
|
|
||||||
|
if (common.initialTeam) {
|
||||||
|
// If the value is -1, it means the user drive was selected from the pad creation screen
|
||||||
|
// If the value is a positive Integer, force save in the team with the selected ID
|
||||||
|
if (common.initialTeam !== -1) {
|
||||||
|
// Team selected from the PCS or pad created from a team drive
|
||||||
|
data.teamId = common.initialTeam;
|
||||||
|
}
|
||||||
|
data.forceSave = 1;
|
||||||
|
delete common.initialTeam;
|
||||||
|
}
|
||||||
if (common.initialPath) {
|
if (common.initialPath) {
|
||||||
if (!data.path) {
|
if (!data.path) {
|
||||||
data.path = Array.isArray(common.initialPath) ? common.initialPath
|
data.path = Array.isArray(common.initialPath) ? common.initialPath
|
||||||
@ -1410,6 +1420,11 @@ define([
|
|||||||
delete sessionStorage[Constants.newPadPathKey];
|
delete sessionStorage[Constants.newPadPathKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sessionStorage[Constants.newPadTeamKey]) {
|
||||||
|
common.initialTeam = sessionStorage[Constants.newPadTeamKey];
|
||||||
|
delete sessionStorage[Constants.newPadTeamKey];
|
||||||
|
}
|
||||||
|
|
||||||
var channelIsReady = waitFor();
|
var channelIsReady = waitFor();
|
||||||
|
|
||||||
var msgEv = Util.mkEvent();
|
var msgEv = Util.mkEvent();
|
||||||
|
|||||||
@ -2243,6 +2243,7 @@ define([
|
|||||||
var arr = [];
|
var arr = [];
|
||||||
AppConfig.availablePadTypes.forEach(function (type) {
|
AppConfig.availablePadTypes.forEach(function (type) {
|
||||||
if (type === 'drive') { return; }
|
if (type === 'drive') { return; }
|
||||||
|
if (type === 'team') { return; }
|
||||||
if (type === 'contacts') { return; }
|
if (type === 'contacts') { return; }
|
||||||
if (type === 'todo') { return; }
|
if (type === 'todo') { return; }
|
||||||
if (type === 'file') { return; }
|
if (type === 'file') { return; }
|
||||||
@ -2392,7 +2393,10 @@ define([
|
|||||||
.click(function () {
|
.click(function () {
|
||||||
var type = $(this).attr('data-type') || 'pad';
|
var type = $(this).attr('data-type') || 'pad';
|
||||||
var path = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
var path = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
||||||
common.sessionStorage.put(Constants.newPadPathKey, path, function () {
|
nThen(function (waitFor) {
|
||||||
|
common.sessionStorage.put(Constants.newPadPathKey, path, waitFor());
|
||||||
|
common.sessionStorage.put(Constants.newPadTeamKey, APP.team, waitFor());
|
||||||
|
}).nThen(function () {
|
||||||
common.openURL('/' + type + '/');
|
common.openURL('/' + type + '/');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -3830,6 +3834,7 @@ define([
|
|||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
common.sessionStorage.put(Constants.newPadFileData, JSON.stringify(simpleData), waitFor());
|
common.sessionStorage.put(Constants.newPadFileData, JSON.stringify(simpleData), waitFor());
|
||||||
common.sessionStorage.put(Constants.newPadPathKey, currentPath, waitFor());
|
common.sessionStorage.put(Constants.newPadPathKey, currentPath, waitFor());
|
||||||
|
common.sessionStorage.put(Constants.newPadTeamKey, APP.team, waitFor());
|
||||||
}).nThen(function () {
|
}).nThen(function () {
|
||||||
common.openURL('/code/');
|
common.openURL('/code/');
|
||||||
});
|
});
|
||||||
@ -4020,7 +4025,10 @@ define([
|
|||||||
else if ($this.hasClass("cp-app-drive-context-newdoc")) {
|
else if ($this.hasClass("cp-app-drive-context-newdoc")) {
|
||||||
var ntype = $this.data('type') || 'pad';
|
var ntype = $this.data('type') || 'pad';
|
||||||
var path2 = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
var path2 = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
||||||
common.sessionStorage.put(Constants.newPadPathKey, path2, function () {
|
nThen(function (waitFor) {
|
||||||
|
common.sessionStorage.put(Constants.newPadPathKey, path2, waitFor());
|
||||||
|
common.sessionStorage.put(Constants.newPadTeamKey, APP.team, waitFor());
|
||||||
|
}).nThen(function () {
|
||||||
common.openURL('/' + ntype + '/');
|
common.openURL('/' + ntype + '/');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4312,7 +4320,7 @@ define([
|
|||||||
refresh();
|
refresh();
|
||||||
UI.removeLoadingScreen();
|
UI.removeLoadingScreen();
|
||||||
|
|
||||||
if (!APP.isTeam) {
|
if (!APP.team) {
|
||||||
sframeChan.query('Q_DRIVE_GETDELETED', null, function (err, data) {
|
sframeChan.query('Q_DRIVE_GETDELETED', null, function (err, data) {
|
||||||
var ids = manager.findChannels(data);
|
var ids = manager.findChannels(data);
|
||||||
var titles = [];
|
var titles = [];
|
||||||
|
|||||||
@ -523,6 +523,7 @@ define([
|
|||||||
// Get the metadata for sframe-common-outer
|
// Get the metadata for sframe-common-outer
|
||||||
Store.getMetadata = function (clientId, data, cb) {
|
Store.getMetadata = function (clientId, data, cb) {
|
||||||
var disableThumbnails = Util.find(store.proxy, ['settings', 'general', 'disableThumbnails']);
|
var disableThumbnails = Util.find(store.proxy, ['settings', 'general', 'disableThumbnails']);
|
||||||
|
var teams = store.modules['team'] && store.modules['team'].getTeamsData();
|
||||||
var metadata = {
|
var metadata = {
|
||||||
// "user" is shared with everybody via the userlist
|
// "user" is shared with everybody via the userlist
|
||||||
user: {
|
user: {
|
||||||
@ -544,7 +545,8 @@ define([
|
|||||||
isDriveOwned: Boolean(Util.find(store, ['driveMetadata', 'owners'])),
|
isDriveOwned: Boolean(Util.find(store, ['driveMetadata', 'owners'])),
|
||||||
support: Util.find(store.proxy, ['mailboxes', 'support', 'channel']),
|
support: Util.find(store.proxy, ['mailboxes', 'support', 'channel']),
|
||||||
pendingFriends: store.proxy.friends_pending || {},
|
pendingFriends: store.proxy.friends_pending || {},
|
||||||
supportPrivateKey: Util.find(store.proxy, ['mailboxes', 'supportadmin', 'keys', 'curvePrivate'])
|
supportPrivateKey: Util.find(store.proxy, ['mailboxes', 'supportadmin', 'keys', 'curvePrivate']),
|
||||||
|
teams: teams
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cb(JSON.parse(JSON.stringify(metadata)));
|
cb(JSON.parse(JSON.stringify(metadata)));
|
||||||
|
|||||||
@ -431,6 +431,16 @@ define([
|
|||||||
team.getTeam = function (id) {
|
team.getTeam = function (id) {
|
||||||
return ctx.teams[id];
|
return ctx.teams[id];
|
||||||
};
|
};
|
||||||
|
team.getTeamsData = function () {
|
||||||
|
var t = {};
|
||||||
|
Object.keys(teams).forEach(function (id) {
|
||||||
|
t[id] = {
|
||||||
|
name: teams[id].name,
|
||||||
|
edPublic: Util.find(teams[id], ['keys', 'edPublic'])
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return t;
|
||||||
|
};
|
||||||
team.getTeams = function () {
|
team.getTeams = function () {
|
||||||
return Object.keys(ctx.teams);
|
return Object.keys(ctx.teams);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -326,6 +326,7 @@ define([
|
|||||||
fromFileData: Cryptpad.fromFileData ? {
|
fromFileData: Cryptpad.fromFileData ? {
|
||||||
title: Cryptpad.fromFileData.title
|
title: Cryptpad.fromFileData.title
|
||||||
} : undefined,
|
} : undefined,
|
||||||
|
storeInTeam: Cryptpad.initialTeam || (Cryptpad.initialPath ? -1 : undefined)
|
||||||
};
|
};
|
||||||
if (window.CryptPad_newSharedFolder) {
|
if (window.CryptPad_newSharedFolder) {
|
||||||
additionalPriv.newSharedFolder = window.CryptPad_newSharedFolder;
|
additionalPriv.newSharedFolder = window.CryptPad_newSharedFolder;
|
||||||
@ -682,7 +683,11 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
|
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
|
||||||
|
if (typeof (data.value) === "undefined") {
|
||||||
|
delete sessionStorage[data.key];
|
||||||
|
} else {
|
||||||
sessionStorage[data.key] = data.value;
|
sessionStorage[data.key] = data.value;
|
||||||
|
}
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1201,7 +1206,13 @@ define([
|
|||||||
var rtConfig = {
|
var rtConfig = {
|
||||||
metadata: {}
|
metadata: {}
|
||||||
};
|
};
|
||||||
if (data.owned) {
|
if (data.team) {
|
||||||
|
Cryptpad.initialTeam = data.team.id;
|
||||||
|
}
|
||||||
|
if (data.owned && data.team && data.team.edPublic) {
|
||||||
|
rtConfig.metadata.owners = [data.team.edPublic];
|
||||||
|
// XXX Teams mailbox
|
||||||
|
} else if (data.owned) {
|
||||||
rtConfig.metadata.owners = [edPublic];
|
rtConfig.metadata.owners = [edPublic];
|
||||||
rtConfig.metadata.mailbox = {};
|
rtConfig.metadata.mailbox = {};
|
||||||
rtConfig.metadata.mailbox[edPublic] = Utils.crypto.encrypt(JSON.stringify({
|
rtConfig.metadata.mailbox[edPublic] = Utils.crypto.encrypt(JSON.stringify({
|
||||||
|
|||||||
@ -297,6 +297,7 @@ define([
|
|||||||
owned: cfg.owned,
|
owned: cfg.owned,
|
||||||
expire: cfg.expire,
|
expire: cfg.expire,
|
||||||
password: cfg.password,
|
password: cfg.password,
|
||||||
|
team: cfg.team,
|
||||||
template: cfg.template,
|
template: cfg.template,
|
||||||
templateId: cfg.templateId
|
templateId: cfg.templateId
|
||||||
}, cb);
|
}, cb);
|
||||||
|
|||||||
@ -30,9 +30,7 @@ define([
|
|||||||
Messages)
|
Messages)
|
||||||
{
|
{
|
||||||
var APP = {};
|
var APP = {};
|
||||||
var driveAPP = {
|
var driveAPP = {};
|
||||||
isTeam: true
|
|
||||||
};
|
|
||||||
//var SHARED_FOLDER_NAME = Messages.fm_sharedFolderName;
|
//var SHARED_FOLDER_NAME = Messages.fm_sharedFolderName;
|
||||||
|
|
||||||
var copyObjectValue = function (objRef, objToCopy) {
|
var copyObjectValue = function (objRef, objToCopy) {
|
||||||
@ -91,6 +89,7 @@ define([
|
|||||||
APP.module.execCommand('SUBSCRIBE', null, function () {
|
APP.module.execCommand('SUBSCRIBE', null, function () {
|
||||||
sframeChan.query('Q_SET_TEAM', null, function (err) {
|
sframeChan.query('Q_SET_TEAM', null, function (err) {
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
|
APP.team = null;
|
||||||
APP.buildUI(common);
|
APP.buildUI(common);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -184,7 +183,7 @@ define([
|
|||||||
|
|
||||||
// Team APP
|
// Team APP
|
||||||
|
|
||||||
var loadTeam = function (common, firstLoad) {
|
var loadTeam = function (common, id, firstLoad) {
|
||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
var proxy = {};
|
var proxy = {};
|
||||||
var folders = {};
|
var folders = {};
|
||||||
@ -199,6 +198,7 @@ define([
|
|||||||
if (!proxy.drive || typeof(proxy.drive) !== 'object') {
|
if (!proxy.drive || typeof(proxy.drive) !== 'object') {
|
||||||
throw new Error("Corrupted drive");
|
throw new Error("Corrupted drive");
|
||||||
}
|
}
|
||||||
|
driveAPP.team = id;
|
||||||
var drive = DriveUI.create(common, {
|
var drive = DriveUI.create(common, {
|
||||||
proxy: proxy,
|
proxy: proxy,
|
||||||
folders: folders,
|
folders: folders,
|
||||||
@ -255,6 +255,7 @@ define([
|
|||||||
APP.module.execCommand('SUBSCRIBE', id, function () {
|
APP.module.execCommand('SUBSCRIBE', id, function () {
|
||||||
sframeChan.query('Q_SET_TEAM', id, function (err) {
|
sframeChan.query('Q_SET_TEAM', id, function (err) {
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
|
APP.team = id;
|
||||||
buildUI(common, true);
|
buildUI(common, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -322,7 +323,7 @@ define([
|
|||||||
];
|
];
|
||||||
UI.addLoadingScreen();
|
UI.addLoadingScreen();
|
||||||
cb(content);
|
cb(content);
|
||||||
loadTeam(common, false);
|
loadTeam(common, APP.team, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user