mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1be1e5f647
Summary: This reverts the behavior of onOptions, which had unintentionally changed recently and no longer matched the API documentation. Test Plan: Existing tests. Reviewers: jarek Reviewed By: jarek Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4064
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
/**
|
|
* Custom widget manifest definition.
|
|
*/
|
|
export interface ICustomWidget {
|
|
/**
|
|
* Widget friendly name, used on the UI.
|
|
*/
|
|
name: string;
|
|
/**
|
|
* Widget unique id, probably in npm package format @gristlabs/custom-widget-name.
|
|
*/
|
|
widgetId: string;
|
|
/**
|
|
* Custom widget main page URL.
|
|
*/
|
|
url: string;
|
|
/**
|
|
* Optional desired access level.
|
|
*/
|
|
accessLevel?: AccessLevel;
|
|
/**
|
|
* If set, Grist will render the widget after `grist.ready()`.
|
|
*
|
|
* This is used to defer showing a widget on initial load until it has finished
|
|
* applying the Grist theme.
|
|
*/
|
|
renderAfterReady?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Widget access level.
|
|
*/
|
|
export enum AccessLevel {
|
|
/**
|
|
* Default, no access to Grist.
|
|
*/
|
|
none = "none",
|
|
/**
|
|
* Read only access to table the widget is based on.
|
|
*/
|
|
read_table = "read table",
|
|
/**
|
|
* Full access to document on user's behalf.
|
|
*/
|
|
full = "full",
|
|
}
|
|
|
|
export function isSatisfied(current: AccessLevel, minimum: AccessLevel) {
|
|
function ordered(level: AccessLevel) {
|
|
switch(level) {
|
|
case AccessLevel.none: return 0;
|
|
case AccessLevel.read_table: return 1;
|
|
case AccessLevel.full: return 2;
|
|
default: throw new Error(`Unrecognized access level ${level}`);
|
|
}
|
|
}
|
|
return ordered(current) >= ordered(minimum);
|
|
}
|