Skip to content

Add pickers for rule creation with control API and CLI examples#3285

Open
owenpearson wants to merge 1 commit intomainfrom
rule-creation-example-pickers
Open

Add pickers for rule creation with control API and CLI examples#3285
owenpearson wants to merge 1 commit intomainfrom
rule-creation-example-pickers

Conversation

@owenpearson
Copy link
Member

@owenpearson owenpearson commented Mar 19, 2026

AIT-375

Adds pickers for channel/integration rule creation examples so that where applicable, users can choose between:

  • Using the website dashboard UI (all the existing examples were doing this)
  • Using the Control REST API
  • Using the Ably CLI

The UI looks like this:
image

Some possible future enhancements which I haven't implemented here could be to:

  • Persist users choice in the browser.
  • Add icons for each option.
  • Add examples using terraform or other options (e.g. ably-control-go)

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 82605437-2d9f-4b4a-8dff-a47f29b6c03a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rule-creation-example-pickers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mschristensen mschristensen added the review-app Create a Heroku review app label Mar 19, 2026
@ably-ci ably-ci temporarily deployed to ably-docs-rule-creation-3srjl1 March 19, 2026 12:18 Inactive
children: ReactNode;
}

export const MethodPicker: React.FC<MethodPickerProps> = ({ children }) => {
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] Could probably benefit from unit tests for this

Copy link
Member Author

Choose a reason for hiding this comment

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

good shout, i've added a few now 👍

<div className="my-5">
<div className="flex gap-1 border-b border-neutral-300 dark:border-neutral-800 mb-5">
{methods.map((method) => (
<button
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] Could add aria attributes role="tab" and aria-selected

Copy link
Member Author

Choose a reason for hiding this comment

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

also a good idea - i've added some accessibility attributes now


Refer to the [Control API reference](/docs/api/control-api) for a full list of available parameters.

</Method>
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] Noticed in a few that we don't always have a CLI method. Due to lack of CLI support or something else?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah the CLI doesn't support a few of the rule types. tbh I wanted to avoid opening a can of worms with this work but I'll make an issue on the CLI repo so that we fix this properly in future by adding support for them in the CLI

}
});

const [activeMethod, setActiveMethod] = useState(methods[0] ?? 'dashboard');
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] Did you consider saving the user choice of method? Like we do for languages?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did consider it, but i decided to leave it for a future enhancement :)

@m-hulbert m-hulbert added review-app Create a Heroku review app and removed review-app Create a Heroku review app labels Mar 24, 2026
@ably-ci ably-ci had a problem deploying to ably-docs-rule-creation-bpicwr March 24, 2026 16:40 Failure
Copy link
Contributor

@m-hulbert m-hulbert left a comment

Choose a reason for hiding this comment

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

This is a cool little feature, Owen! Just a few comments:

  • I think we should name this Tabs and Tab rather than use 'Method'. This is to avoid confusion from LLMs, but also means it's more widely usable.
  • I think we might need to bound this somewhat, so it's obvious where the tab ends and the copy continues.
  • Channel rule --> Rule throughout please.

```
</Code>

Refer to the [Control API reference](/docs/api/control-api) for a full list of available parameters.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to link to this for every command considering we already link out to the docs on the Control API. If it's important enough to include then we should make the path a link to the reference for itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, all good feedback. i've addressed all the above now 👍


const MethodContext = createContext<MethodContextType | undefined>(undefined);

const METHOD_LABELS: Record<string, string> = {
Copy link
Contributor

@m-hulbert m-hulbert Mar 24, 2026

Choose a reason for hiding this comment

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

Ah missed this - I also don't think we should be hardcoding this. At the end of the day it's a label on a tab, so this should just take whatever value is defined by the author to make this a flexible component.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah good point, it's generic now 👍

@owenpearson owenpearson force-pushed the rule-creation-example-pickers branch from 14f6fdd to be09949 Compare March 25, 2026 21:47
@ably-ci ably-ci temporarily deployed to ably-docs-rule-creation-bpicwr March 25, 2026 21:48 Inactive
@ably-ci ably-ci temporarily deployed to ably-docs-rule-creation-pchjly March 25, 2026 21:48 Inactive
@owenpearson owenpearson force-pushed the rule-creation-example-pickers branch from be09949 to 357bdc5 Compare March 25, 2026 22:00
@ably-ci ably-ci temporarily deployed to ably-docs-rule-creation-pchjly March 25, 2026 22:00 Inactive
@matt423
Copy link
Member

matt423 commented Mar 26, 2026

@owenpearson Will re-review changes shortly but just an FYI yarn lint is failing in the meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

5 participants