Skip to content
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

Add reusable blocks #2659

Closed
wants to merge 38 commits into from
Closed

Add reusable blocks #2659

wants to merge 38 commits into from

Commits on Oct 12, 2017

  1. Add 'core/reusable-block' block type

    This lets us parse reusable blocks from the HTML, and not much else.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    6e3431f View commit details
    Browse the repository at this point in the history
  2. Stub out Reusable Block UI, implement fetching and local editing

    Stubs out some of the editor UI so that we have a base to work from.
    Also adds the reducers and effects necessary to support fetching and
    local editing.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    6721b27 View commit details
    Browse the repository at this point in the history
  3. Implement reusable block persisting

     Adds an effect that responds to the PERSIST_REUSABLE_BLOCK action, and
     some UI for the confirmation dialog that appears when a reusable block
     is first modified.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    7f6dd91 View commit details
    Browse the repository at this point in the history
  4. Implement ATTACH_REUSABLE_BLOCK

    Adds an effect which lets us turn reusable blocks into regular blocks.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    ade0f06 View commit details
    Browse the repository at this point in the history
  5. Implement DETACH_REUSABLE_BLOCK

    Adds an effect which lets us turn regular blocks into reusable blocks,
    and stubs out some Advanced Options UI which triggers this effect.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    16588b8 View commit details
    Browse the repository at this point in the history
  6. Fetch and persist reusable blocks using the WP API Backbone client

    Adds the `gutenberg/v1/` endpoint to the WPI API Backbone client so that
    we can use `wp.api.models.ReusableBlocks` to fetch and save reusable
    blocks instead of our own (ugly) implementation.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    e9b4701 View commit details
    Browse the repository at this point in the history
  7. Clean up reusable block update actions

    Collapse SET_REUSABLE_BLOCK_NAME and UDPATE_REUSABLE_BLOCK_ATTRIBUTES
    into one UPDATE_REUSABLE_BLOCK action. This makes things read a little
    nicer.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    23162e3 View commit details
    Browse the repository at this point in the history
  8. Rename persistReusableBlock -> saveReusableBlock

    'persist' is a little verbose, and we already use the term 'save' when
    saving the Backbone model.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    fee015f View commit details
    Browse the repository at this point in the history
  9. Prefer 'id' instead of 'ref' when dealing with reusable blocks

    This keeps our variables names in sync with how things look in the API,
    and disambiguates between the ID stored in the post and the ID stored in
    redux.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    51f8a38 View commit details
    Browse the repository at this point in the history
  10. Rename ATTACH/DETACH actions

    Renames ATTACH_REUSABLE_BLOCK -> ATTACH_BLOCK and DETACH_REUSABLE_BLOCK
    -> DETACH_BLOCK. This makes it clearer that these actions take block
    UIDs, not reusable block IDs.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    d5c0c49 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    a6cd1dd View commit details
    Browse the repository at this point in the history
  12. Write tests for reusable block client API

    Write tests for reuasble block actions, selectors, reducer and factory
    methods.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    80ee61f View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    9fdcb50 View commit details
    Browse the repository at this point in the history
  14. Style 'Convert to Reusable Block' button

    Introduce a button new inspector control and use it for the 'Convert to
    Reusable Block' and 'Detach from Reusable Block' buttons.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    67d0ec6 View commit details
    Browse the repository at this point in the history
  15. Style reusable block dialogs and display them modally

    - Introduces a new Modal component, which presents its children modally
    - Changes ReusableBlockEdit to present NewReusableBlockDialog and
      SaveConfirmationDialog modally
    - Styles the reusable block dialogs to look like the design
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    2eb4f96 View commit details
    Browse the repository at this point in the history
  16. Add reusable blocks to the inserter

    Show reusable blocks that are available in the redux state tree in the
    inserter UI.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    6e5876e View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    256ddbb View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    2f89fea View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    2822984 View commit details
    Browse the repository at this point in the history
  20. Implement render_callback for reusable blocks

    Allow reusable blocks to be rendered by the server for posts and pages
    by registering them in PHP and defininig a `render_callback`.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    38887bb View commit details
    Browse the repository at this point in the history
  21. Replace reusable block modals with inline edit panel

    Replaces SaveConfirmationDialog, NewReusableBlockDialog, and Modal with
    ReusableBlockEditPanel. This panel sits at the bottom of a reusable
    block when selected and allows the user to explicitly edit and save the
    reusable block. The end result is a less ambiguous and more explicit
    UX.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    735e2c0 View commit details
    Browse the repository at this point in the history
  22. Give the <button> in <ButtonControl> an id

    This makes the `<label>` in the control behave correctly. According to
    the spec, `<button>` is a labelable element:
    https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Form_labelable
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    3d3affb View commit details
    Browse the repository at this point in the history
  23. Use an explicit isPrivate flag to hide block types from the inserter

    We don't wish to show the 'core/reusable-block' block type in the
    inserter. We were doing this by taking advantage of the fact that the
    inserter would ignore block types with a null category. This change
    makes this behaviour more explicit.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    4448ea2 View commit details
    Browse the repository at this point in the history
  24. Remove useless } else {

    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    f587eed View commit details
    Browse the repository at this point in the history
  25. DRY up do_blocks and gutenberg_render_block_core_reusable_block

    Refactor the common logic in `do_blocks` and
    `gutenberg_render_block_core_reusable_block` into a new
    `gutenberg_render_block` function.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    4b7f597 View commit details
    Browse the repository at this point in the history
  26. Combine FETCH_REUSABLE_BLOCK and FETCH_REUSABLE_BLOCKS

    Simplify fetching logic a little by DRYing up these two mostly-similar effects.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    9f0afb9 View commit details
    Browse the repository at this point in the history
  27. Remove ADD_REUSABLE_BLOCKS action, add ability to track saving

    Collapses the ADD_REUSABLE_BLOCKS action into UPDATE_REUSABLE_BLOCK and
    FETCH_REUSABLE_BLOCKS_SUCCESS. Also makes it so that the Redux store
    keeps track of whether or not a reusable block is being saved or has had
    an error while saving.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    baf43b3 View commit details
    Browse the repository at this point in the history
  28. Add reusable block 'saving' and 'save failure' UI

    Adds a spinner that indicates whether or not a reusable block is saving,
    and some UI that allows the user to retry the save if it fails.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    6cf3950 View commit details
    Browse the repository at this point in the history
  29. Rename {ATTACH,DETACH}_BLOCK to MAKE_BLOCK_{STATIC,REUSABLE}

    Avoid ambiguity around what 'attach' and 'detach' means by avoiding the
    its use in code alltogether.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    cd03ad3 View commit details
    Browse the repository at this point in the history
  30. Improve tests for actions, selectors and effects

    Slightly clean up the tests for reusable block actions and selectors,
    and change our effects tests to reduce our dependency on mocking
    selectors by taking advantage of the fact that MAKE_BLOCK_STATIC and
    MAKE_BLOCK_REUSABLE are relatively pure functions.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    49ec18c View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    fcdf318 View commit details
    Browse the repository at this point in the history
  32. Clean up <ButtonControl>

    Remove unnecessary {}s, split up long line, and collapse SCSS selectors
    into one line.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    e8c33c1 View commit details
    Browse the repository at this point in the history
  33. Clarify how we're using pickBy

    Add a comment which clarifies this weird way we're using _.pickBy.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    69e5705 View commit details
    Browse the repository at this point in the history
  34. Call blockType.save, not blockType.create

    Fix this typo. There's no such thing as `blockType.create`!
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    7fdb1d8 View commit details
    Browse the repository at this point in the history
  35. Use convertBlockTo{Static,Reusable} instead of makeBlock{Static,Reusa…

    …ble}
    
    It's a clearer action name since 'convert' is a less ambigious verb.
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    003c900 View commit details
    Browse the repository at this point in the history
  36. Remove unnecessary <Slot>

    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    1254e97 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    6faec68 View commit details
    Browse the repository at this point in the history
  38. Use animation and notices to indicate the reusable block save state

    - Makes the 'Save' button animate when a reusable block is saving
    - Makes a 'Reusable block updated' notice appear when the save is
      successful
    - Makes a 'Reusable block update failed' notice appear when the save
      fails
    noisysocks committed Oct 12, 2017
    Configuration menu
    Copy the full SHA
    5637827 View commit details
    Browse the repository at this point in the history