-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for dynamic panes #99
Conversation
Note that not all lines actually need to be covered; however, they should explicitly be marked as ignored for coverage, preferably with a comment explaining why they need not be tested. This only applies to TypeScript files, to ease a gradual transition.
This commit introduces a new Pad pane that can read Pads created by the old one. It is intended as a testbed for experimenting with a new setup for Panes in which their concerns are more clearly separated. Specifically, it aims to achieve the following goals: - Extract data access into a separate module. This potentially allows these modules to be re-used in other apps, to ensure data compatibility. - Separate DOM manipulation from data manipulation. This makes it easier to update the view without risk of breaking something else. - Add a wrapper to intermediate between the old and the new API. Hopefully we can let go of the old API in time, but that first requires more clarity on what needs to be preserved. - Separate creation of new items from viewing them. Since the data model can be shared between different apps/panes, no single pane should be responsible for creating new instances, as that would be redundant with the equivalent methods in different panes. - Separate item viewing from item discovery. Panes are responsible for viewing specific pieces of data (in this case: a notepad). This is useful for e.g. when a user is linked to a resource directly, allowing them to browse a specific piece of data. Discovering what data is available on one's Pod in general is a separate task - one could imagine e.g. a listing of simply all notepads in a Pod, sorted by date. Clicking one of those would bring you to the Scratchpad Pane. This API is not final. Note that it makes use of async/await, and therefore imports @babel/polyfill. Because mashlib overwrites `require`, we cannot yet include it globally, so the import has to be added to every file using ES modules and async/await.
This is to make sure use cases that require authentication work.
This makes it easier to later add additional params, which I expect to happen.
This commit also makes sure that the threshold is achieved, either by adding tests or ignoring them for coverage (with the reason explained).
Added primarily to test navigating between different resources without a full page refresh.
Note that getPanes() can only be used server-side. To actually load them, the server should generate client-side scripts that actually include the pane, preferably without already including the pane's code in the initial payload.
I just extracted a few unrelated commits out into #100, so it can more easily be reviewed/merged in pieces. Apologies if you already pulled this branch locally. If so, and you did not make changes yet locally, please run:
|
|
||
// Note: there might be a more appropriate project to hold this definition: | ||
export interface PaneDefinition { | ||
icon: string; | ||
name: string; | ||
label: (subject: Node) => string | null; | ||
render: (subject: Node, dom: HTMLDocument, options?: unknown) => HTMLElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First feedback by @megoth: move store
to be part of options
in render
and mintNew
. (Not sure if there's a better solution for label
?)
Reference: https://github.com/solid/solid-ui/pull/64#pullrequestreview-242711412
For others reading this - this is a proposal connected to #103 |
As noted in this comment we'll postpone this work until we have more work done on other parts of the data browser. I do think there are some code in this PR that we'll merge in as separate PRs, but for now I'll close this PR. |
(This PR builds on #100, and is thus easier to review if that is merged first.)
This Pull Request contains a new Pane ("scratchpad", similar to pad) whose only goal is to demonstrate the concepts. It is intended as a starting point for a discussion of how best to implement dynamic loading of panes, and how to structure a Pane's code. In other words: feel free to liberally criticise anything in here :)
It proposes that:
window.UI
, because a developer can then not reliably trace where a piece of code came from. Instead, e.g. store instances are passed as parameters - which is why this depends on https://github.com/solid/solid-ui/pull/64, and whyoutline/manager.js
was modified.data.ts
) is decoupled from the Pane definition (although it's currently in the same package). This makes it easier for third parties to create apps that manipulate the same data in the same way. It could also allow for e.g. a dashboard-like replacement for the current HTML home page of the data browser, which can re-use that code to e.g. initialise new resources that can be read by that pane.label
method to determine whether a pane should be shown, to lower the barrier to entry for new developers.Open challenges:
An overview of what's what in this PR, to hopefully make it easier to review:
Stricter ESLint and test coverage setup (for TypeScript files).Moved to Refinement of test setup #100.packages/panes
: this is where separate Node packages (i.e. with their ownpackage.json
) for panes could live.packages/initialise.js
(and other scripts it references): sincenpm run watch
only compiles and startssolid-panes
, this script does the same for all panes in separate packages insidepackages/panes
.view.ts
anddata.ts
: view and data access for a pane (scratchpad, in this case). And their test files.packages/panes/webpack-config-panes
: the only non-pane insidepackages/panes
. This exports a method that can be used to initialise the Webpack config for a pane in a separate package. Currently only used by the scratchpad, but allows different panes to re-use the configuration if needed.pad/padPane.ts
: a rewrite of the regular pad Pane from Javascript to TypeScript, no functional changes. Mostly done to be able to compare scratchpad.Apologies for the enormous code drop, but given that it's quite a task to move to dynamic panes, I'm afraid there's just a lot to discuss. As said, nothing here is set in stone, as far as I care.
Fixes #72.