Fix usage bar in drive and read only teams

pull/1/head
yflory 5 years ago
parent 9a4da6e6e0
commit 980baf9ce3

@ -2232,6 +2232,7 @@ define([
updateUsage();
cb(null, $container);
return {
$container: $container,
stop: function () {
clearInterval(interval);
}

@ -538,10 +538,10 @@ define([
var metadataMgr = common.getMetadataMgr();
var sframeChan = common.getSframeChannel();
var priv = metadataMgr.getPrivateData();
var user = metadataMgr.getUserData();
// Initialization
Util.extend(APP, driveConfig.APP);
APP.$limit = driveConfig.$limit;
var proxy = driveConfig.proxy;
var folders = driveConfig.folders;
var files = proxy.drive;
@ -587,11 +587,6 @@ define([
// TOOLBAR
/* add a "change username" button */
if (!APP.readOnly) {
APP.$displayName.text(user.name || Messages.anonymous);
}
// DRIVE
var currentPath = APP.currentPath = LS.getLastOpenedFolder();
if (APP.newSharedFolder) {

@ -177,6 +177,7 @@ define([
var sframeChan = common.getSframeChannel();
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var user = metadataMgr.getUserData();
APP.disableSF = !privateData.enableSF && AppConfig.disableSharedFolders;
if (APP.newSharedFolder && !APP.loggedIn) {
@ -204,13 +205,19 @@ define([
var $rightside = toolbar.$rightside;
$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
APP.$displayName = APP.$bar.find('.' + Toolbar.constants.username);
var $displayName = APP.$bar.find('.' + Toolbar.constants.username);
metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous;
$displayName.text(name);
});
$displayName.text(user.name || Messages.anonymous);
/* add the usage */
var usageBar;
if (APP.loggedIn) {
common.createUsageBar(null, function (err, $limitContainer) {
usageBar = common.createUsageBar(null, function (err, $limitContainer) {
if (err) { return void DriveUI.logError(err); }
APP.$limit = $limitContainer;
}, true);
}
@ -256,16 +263,12 @@ define([
.addClass('fa-ban');
}
metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous;
APP.$displayName.text(name);
});
$('body').css('display', '');
if (!proxy.drive || typeof(proxy.drive) !== 'object') {
throw new Error("Corrupted drive");
}
var drive = DriveUI.create(common, {
$limit: usageBar && usageBar.$container,
proxy: proxy,
folders: folders,
updateObject: updateObject,

@ -295,22 +295,28 @@ define([
if (!proxy.drive || typeof(proxy.drive) !== 'object') {
throw new Error("Corrupted drive");
}
driveAPP.team = id;
// Provide secondaryKey
var teamData = (privateData.teams || {})[id] || {};
driveAPP.readOnly = !teamData.hasSecondaryKey;
if (APP.usageBar) { APP.usageBar.stop(); }
APP.usageBar = undefined;
if (!driveAPP.readOnly) {
APP.usageBar = common.createUsageBar(APP.team, function (err, $limitContainer) {
if (err) { return void DriveUI.logError(err); }
driveAPP.$limit = $limitContainer;
$limitContainer.attr('title', Messages.team_quota);
}, true);
driveAPP.team = id;
}
// Provide secondaryKey
var teamData = (privateData.teams || {})[id] || {};
driveAPP.readOnly = !teamData.hasSecondaryKey;
var drive = DriveUI.create(common, {
proxy: proxy,
folders: folders,
updateObject: updateObject,
updateSharedFolders: updateSharedFolders,
$limit: APP.usageBar && APP.usageBar.$container,
APP: driveAPP,
edPublic: APP.teamEdPublic,
editKey: teamData.secondaryKey
@ -1281,6 +1287,7 @@ define([
var sframeChan = common.getSframeChannel();
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var user = metadataMgr.getUserData();
readOnly = driveAPP.readOnly = metadataMgr.getPrivateData().readOnly;
@ -1305,11 +1312,12 @@ define([
var toolbar = Toolbar.create(configTb);
toolbar.$rightside.hide(); // hide the bottom part of the toolbar
// Update the name in the user menu
driveAPP.$displayName = $bar.find('.' + Toolbar.constants.username);
var $displayName = $bar.find('.' + Toolbar.constants.username);
metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous;
driveAPP.$displayName.text(name);
$displayName.text(name);
});
$displayName.text(user.name || Messages.anonymous);
// Load the Team module
var onEvent = function (obj) {

Loading…
Cancel
Save