Skip to content

Add ability to register private blocks, sets and presets #28

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

Draft
wants to merge 95 commits into
base: main
Choose a base branch
from

Conversation

robdekort
Copy link
Contributor

@robdekort robdekort commented Jan 24, 2025

This PR by @marcorieser and me is a refactor of the commands addon that adds the ability to register custom private locations for blocks, sets and presets.

To register custom content:

  1. Publish the config file.
  2. Add paths for either blocks, sets or presets.
  3. Make sure each block, set or preset contains a config.php using the following pattern.
return [
    'handle' => 'pricing',
    'name' => 'Pricing tiers & features',
    'description' => 'Create and list pricing tiers and feature tables.',
    'operations' => [
        // Adds the ability to rename a collection handle. Use `{{ handle }}` in your files.
        [
            'type' => 'rename'
        ],
        // Runs a custom CLI command.
        [
            'type' => 'run',
            'command' => 'composer require vendor/package',
            'processing_message' => 'Installing vendor/package',
            'success_message' => 'Package installed.'
        ],
        // Copy a file, optionallly add the option to skip the operation.
        [
            'type' => 'copy',
            'input' => 'source.file',
            'output' => 'destination.file',
            'skippable' => false // Default.
        ],
        // Update the page builder with a new block.
        [
            'type' => 'update_page_builder',
            'block' => [
                'name' => 'Title',
                'instructions' => 'Instructions',
                'icon' => 'icon',
                'handle' => 'handle',
            ]
        ],
        // Update Bard with a new set.
        [
            'type' => 'update_article_sets',
            'block' => [
                'name' => 'Title',
                'instructions' => 'Instructions',
                'icon' => 'icon',
                'handle' => 'handle',
            ]
        ],
        // Add permissions to role. Use `{{ handle }}` when working with a renamable collection.
        [
            'type' => 'update_role',
            'role' => 'role_handle',
            'permissions' => ['view {{ handle }} entries', 'edit {{ handle }} entries', 'create {{ handle }} entries', 'delete {{ handle }} entries', 'publish {{ handle }} entries', 'reorder {{ handle }} entries', 'edit other authors {{ handle }} entries', 'publish other authors {{ handle }} entries', 'delete other authors {{ handle }} entries']
        ],
        // Attach collections to navigation.
        [
            'type' => 'attach_collections_to_navigation',
            'navigation' => 'handle',
            'collections' => ['collection_handle_1', 'collection_handle_2']
        ],
        // Attach taxonomy to collections.
        [
            'type' => 'attach_taxonomy_to_collections',
            'taxonomy' => 'handle',
            'collections' => ['collection_handle_1', 'collection_handle_2']
        ],
        // Notify the user with a message in the CLI. The user has to hit enter to continue.
        [
            'type' => 'notify',
            'content' => "All done."
        ],
    ]
];

@robdekort robdekort marked this pull request as draft January 24, 2025 08:50
@marcorieser marcorieser requested a review from Copilot March 31, 2025 10:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the ability to register custom private blocks, sets, and presets by refactoring the commands addon.

  • Added a new changelog section for version v8.17.0 (Unreleased) outlining new features, improvements, and fixes
  • Updated the changelog entries to reference the new registration functionality
Files not reviewed (8)
  • composer.json: Language not supported
  • config/statamic-peak-commands.php: Language not supported
  • phpunit.xml: Language not supported
  • resources/blocks/call_to_action/config.php: Language not supported
  • resources/blocks/cards/config.php: Language not supported
  • resources/blocks/collection/config.php: Language not supported
  • resources/blocks/columns/config.php: Language not supported
  • resources/blocks/divider/config.php: Language not supported
Comments suppressed due to low confidence (1)

CHANGELOG.md:6

  • [nitpick] Consider rephrasing for clarity. For example, 'Register your own private blocks, sets, and presets for installation.' may better reflect the PR's intent.
- The ability to load in your own private blocks, sets and presets to install. #28 by @marcorieser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants