mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Use table title instead of ID in ACL UI
Summary: Use table titles (i.e. the raw data widget titles) in dropdowns and other parts of the Acess Rules page, instead of the table ID. This is particularly meant for summary tables which have/had an ID of the form `GristSummary_SourceTable_N`, but https://phab.getgrist.com/D3508 is changing that anyway. The server method `getAclResources` now returns more metadata about each table so that the UI can display titles. Test Plan: Extended and updated `nbrowser/AccessRules2.ts`. Added a small unit test for constructing table titles from the new description returned by `getAclResources`. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3494
This commit is contained in:
@@ -156,6 +156,27 @@ export interface PermissionDataWithExtraUsers extends PermissionData {
|
||||
exampleUsers: UserAccessData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic metadata about a table returned by `getAclResources()`.
|
||||
*/
|
||||
export interface AclTableDescription {
|
||||
title: string; // Raw data widget title
|
||||
colIds: string[]; // IDs of all columns in table
|
||||
groupByColLabels: string[] | null; // Labels of groupby columns for summary tables, or null.
|
||||
}
|
||||
|
||||
export function getTableTitle(table: AclTableDescription): string {
|
||||
let {title} = table;
|
||||
if (table.groupByColLabels) {
|
||||
title += ' ' + summaryGroupByDescription(table.groupByColLabels);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
export function summaryGroupByDescription(groupByColumnLabels: string[]): string {
|
||||
return `[${groupByColumnLabels.length ? 'by ' + groupByColumnLabels.join(", ") : "Totals"}]`;
|
||||
}
|
||||
|
||||
export interface ActiveDocAPI {
|
||||
/**
|
||||
* Closes a document, and unsubscribes from its userAction events.
|
||||
@@ -300,7 +321,7 @@ export interface ActiveDocAPI {
|
||||
* for editing ACLs. It is only available to users who can edit ACLs, and lists all resources
|
||||
* regardless of rules that may block access to them.
|
||||
*/
|
||||
getAclResources(): Promise<{[tableId: string]: string[]}>;
|
||||
getAclResources(): Promise<{[tableId: string]: AclTableDescription}>;
|
||||
|
||||
/**
|
||||
* Wait for document to finish initializing.
|
||||
|
||||
Reference in New Issue
Block a user