This commit is contained in:
Zuzanna 2026-09-08 15:13:46 +00:00 committed by GitHub
commit eafd54a1be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 66 additions and 11 deletions

View File

@ -82,6 +82,10 @@
}
}
}
&.cp-disabled {
opacity: 0.5;
}
.cp-usergrid-user-avatar {
min-height: 40px;
}

View File

@ -1317,10 +1317,10 @@ const factory = (Sortify, UserObject, ProxyManager,
var list = {};
var types = query.types;
var where = query.where;
var filter = query.filter || {};
var filter = query.filter || {};
var isFiltered = function (type, data) {
var filtered;
var fType = filter.fileType || [];
var fType = filter.fileType || [];
if (type === 'file' && fType.length) {
if (!data.fileType) { return true; }
filtered = !fType.some(function (t) {
@ -1351,6 +1351,22 @@ const factory = (Sortify, UserObject, ProxyManager,
cb(list);
};
// Get all teams where a given pad is stored
Store.getPadTeams = function (userId, data, cb) {
var channel = data && data.channel;
if (!channel) { return void cb({error: 'EINVAL'}); }
var teamIds = [];
getAllStores().forEach(function (s) {
if (!s.id) { return; } // Skip our own drive, we only want teams here
var chans = s.manager.findChannel(channel, true);
if (chans && chans.length) {
teamIds.push(s.id);
}
});
cb(teamIds);
};
// Get the first pad we can find in any of our drives and return its file data
// NOTE: This is currently only used for template: this won't search inside shared folders
Store.getPadData = function (clientId, id, cb) {

View File

@ -45,6 +45,7 @@ const factory = AStore => {
LIST_ALL_TAGS: Store.listAllTags,
GET_TEMPLATES: Store.getTemplates,
GET_SECURE_FILES_LIST: Store.getSecureFilesList,
GET_PAD_TEAMS: Store.getPadTeams,
GET_PAD_DATA: Store.getPadData,
GET_PAD_DATA_FROM_CHANNEL: Store.getPadDataFromChannel,
GET_STRONGER_HASH: Store.getStrongerHash,

View File

@ -184,7 +184,7 @@ define([
el = h('div.cp-usergrid-user'+(data.selected?'.cp-selected':'')+(config.large?'.large':''), {
'data-ed': data.edPublic,
'data-teamid': data.teamId,
'data-teamid': data.id,
'data-curve': data.curvePublic || '',
'data-name': name.toLowerCase(),
'data-order': i,

View File

@ -1246,6 +1246,11 @@ define([
cb(void 0, list);
});
};
common.getPadTeams = function (query, cb) {
postMessage("GET_PAD_TEAMS", query, function (teams) {
cb(teams);
});
};
// Get a template href from its id
common.getPadData = function (id, cb) {
postMessage("GET_PAD_DATA", id, function (data) {

View File

@ -82,13 +82,32 @@ define([
}
if (Object.keys(teams).length) {
var teamsList = UIElements.getUserGrid(Messages.share_linkTeam, {
common: common,
noFilter: true,
large: true,
data: teams
}, refreshButtons);
$div.append(teamsList.div);
common.getPadTeams({channel: config.channel}, function (err, teamIds) {
if (err) { console.error(err); }
teamIds = teamIds || [];
var teamsList = UIElements.getUserGrid(Messages.share_linkTeam, {
common: common,
noFilter: true,
large: true,
data: teams
}, refreshButtons);
teamsList.icons.forEach(function (icon) {
var inTeam = teamIds.some(function (id) {
return String(id) === icon.getAttribute('data-teamid');
});
if (inTeam) {
$(icon).addClass('cp-disabled');
$(icon).on('click', function (e) {
e.preventDefault();
return false;
});
}
});
$div.append(teamsList.div);
});
}
var shareButton = {

View File

@ -1533,6 +1533,10 @@ define([
});
});
});
sframeChan.on('Q_GET_PAD_TEAMS', function (types, cb) {
Cryptpad.getPadTeams(types, cb);
});
};
addCommonRpc(sframeChan, isSafe);

View File

@ -689,6 +689,12 @@ define([
});
};
funcs.getPadTeams = function (query, cb) {
ctx.sframeChan.query('Q_GET_PAD_TEAMS', query, function (err, data) {
cb(err || data?.error, data);
});
};
funcs.getCache = function () {
return ctx.cache;
};

File diff suppressed because one or more lines are too long