You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Posts window: the bulkActions filter receives no mode, so a plugin cannot keep a posts-only action out of the Pages window #854
openstation.postsWindow.bulkActions is applied as applyFilters( HOOK_FILTER_BULK_ACTIONS, defaults ) in resolveBulkActions( defaults ) (apps/posts/parts/columns.ts, trunk 6fd8d43a, 1.1.10). The defaults builder right above it takes mode: 'posts' | 'pages' and words its own confirm by it, but the filter callback gets only the array: no mode, no ctx. The filter is resolved once per window on the first bulk-bar paint.
A plugin registering an action that only makes sense for posts (say a scheduler that refuses core's publish and unpublish boundaries) therefore paints the button in the Pages window too. The only way to keep it out is at run() time, where ctx.body is available: we walk it for the undocumented desktop-mode-pages root class and refuse with a toast, and the server refuses pages regardless. That leaves a button the window shows and then declines.
Ask
Pass the mode to the filter, in the shape the columns filter or the status-segments filter would also benefit from, for example applyFilters( HOOK_FILTER_BULK_ACTIONS, defaults, { mode } ). Documenting the root class as the Pages discriminator would be a smaller step; the filter argument is the clean one, since defaultBulkActions( mode ) already has it in hand.
Found while adding a posts-only bulk action from a plugin, which had to read the window's DOM to tell the two modes apart. Happy to take it: #856 passes the mode.
Activity
Posts: hand the bulk-actions and columns filters the window mode (Wor…