Closed bradenmacdonald closed 5 years ago
A quick thought: you talk about the need to cache results of computing top level blocks. If this computation is cached by means of a flag in the block itself, it can become "sticky", i.e. once a block is found to be a top level block, it remains so thereafter until a user explicitly removes the flag.
In that way, a block stays in the library even if it is later added as a child to other blocks.
@bradenmacdonald @ormsbee
A couple of questions:
I guess I was assuming that in general, blocks designed for re-use should be put at the top of the bundle/library. Though it's certainly possible to re-use child blocks.
Do you think we need a separate mechanism for flagging blocks as "suitable for re-use"?
@bradenmacdonald
Do you think we need a separate mechanism for flagging blocks as "suitable for re-use"?
That certainly is more flexible but whether we need that flexibility or can work around it depends on product requirements. I don't think any users will be using the library 2 interface in Studio immediately so maybe we come back to this later?
Closing as this should be resolved by #53.
Warning: brain dump.
At this time, the evolution of the bundle format used for content libraries in blockstore-relay and my draft runtime PR is described in this docstring.
One aspect of this design that has proven a bit more complex than I hoped is the following:
Another way of phrasing the existing design is:
definition.xml
file represents a definition<xblock-include ...>
directive exists anywhere in the bundle referencing a particular definition, it's an explicit usage of that definition<xblock-include ...>
directives in the bundle reference a particular definition, that definition is called a "top level block" and gets an implicit usage with the same usage ID as its definition ID. Top level blocks are the blocks that one sees when listing the contents of a library.This design has these nice properties:
But it has these problems:
<xblock-include usage="..." ...>
elements). This can be slow, although cacheable. (Also, in practice this is optimized considerably since the runtime knows not to bother reading definition files of types likehtml
that cannot have children.)So although those may not be big problems, they don't feel like a particularly elegant or clean design. I would be open to better ideas before anything gets too entrenched.
Some ideas I considered but discarded:
manifest
file that explicitly lists the usages of top-level blocks in the bundle. (Rejected because we need to be able to publish changes to individual blocks at a time, and there's no way to atomically publish changes to only one line in a manifest file using the blockstore drafts API while leaving other changed lines in the draft unaffected. Also because this can created orphaned definitions that are neither top-level blocks nor children of any other blocks. Also because IDs in the manifest can become out of sync with the definitions if there are any bugs or write conflicts.).top-level
alongside thedefinition.xml
file: this allows draft/publish of individual blocks and marking blocks as top-level or not regardless of how many usages they have (nice), and it can never have IDs that are out of sync, but it still allows orphaned blocks. It's also a bit inelegant to have these extra files.definition.xml
orchild-definition.xml
depending on whether they are "top level with optional other usages" (definition) or "not top level" (child-definition). Still allows orphans though.<xblock-include
directives anyways, so we can detect them and display them as top-level blocks along with a warning.