Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1124 +/- ##
=======================================
Coverage 90.74% 90.74%
=======================================
Files 23 23
Lines 670 670
Branches 182 182
=======================================
Hits 608 608
Misses 51 51
Partials 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment was marked as resolved.
This comment was marked as resolved.
Because it just looks weird to me. From a clean declaration perspective, I would agree with But mixing something like But more importantly, I like to be consistent across our APIs here, and considering we have multiple APIs that do similar approaches, like FileAction, NewFileMenu, Views..., I think we should stick to one type of pattern here. That way it's easy to know what to expect when you work with the |
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
d994eb4 to
d9c2e53
Compare
|
Done @susnux ! |
| displayName: (context: ActionContext) => string | ||
| /** Translatable title for of the action */ | ||
| title?: (files: Node[], view: View) => string | ||
| title?: (context: ActionContext) => string | ||
| /** Svg as inline string. <svg><path fill="..." /></svg> */ | ||
| iconSvgInline: (files: Node[], view: View) => string | ||
| iconSvgInline: (context: ActionContext) => string | ||
| /** Condition wether this action is shown or not */ | ||
| enabled?: (files: Node[], view: View) => boolean | ||
| enabled?: (context: ActionContext) => boolean |
There was a problem hiding this comment.
@susnux I'm second guessing myself here, do you think we also need the full context here?
nodes: Node[], view: View, folder: Folder, content: Node[],
Or would only nodes: Node[], view: View should be enough ?
There was a problem hiding this comment.
I think we could probably stick closer to the original implementation
export type ActionContextBase = {
nodes: Node[],
view: View,
}
export type ActionContext = {
folder: Folder,
content: Node[],
} & ActionContextBase
export type ActionContextSingle = {
nodes: [Node],
} & ActionContext
export type ViewActionContext = {
view: View,
folder: Folder,
}export interface FileActionData {
/** Unique ID */
id: string
/** Translatable string displayed in the menu */
displayName: (context: ActionContextBase) => string
/** Translatable title for of the action */
title?: (context: ActionContextBase) => string
/** Svg as inline string. <svg><path fill="..." /></svg> */
iconSvgInline: (context: ActionContextBase) => string
/** Condition wether this action is shown or not */
enabled?: (context: ActionContextBase) => boolean
/**
* Function executed on single file action
* @return true if the action was executed successfully,
* false otherwise and null if the action is silent/undefined.
* @throws Error if the action failed
*/
exec: (context: ActionContextSingle) => Promise<boolean|null>,
/**
* Function executed on multiple files action
* @return true if the action was executed successfully,
* false otherwise and null if the action is silent/undefined.
* @throws Error if the action failed
*/
execBatch?: (context: ActionContext) => Promise<(boolean|null)[]>There was a problem hiding this comment.
Especially "enabled" should also have the folder, because some actions only work in specific parent folders
There was a problem hiding this comment.
ok, for enabled. But the other might not need it. Wdyt ?
Following discussion on #1113
This would be a breaking change unless we add a conversion layer to support the old legacy way.
BUT, the cleanest way, imho, is to quickly update server and communicate to devs asap