Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

PRO-2355 document component admin UI extension patterns #153

Merged
merged 12 commits into from Jan 5, 2022
Merged

Conversation

boutell
Copy link
Member

@boutell boutell commented Nov 24, 2021

No description provided.

@boutell boutell requested a review from abea November 24, 2021 19:54
@linear
Copy link

linear bot commented Nov 24, 2021

PRO-2355 Document how to override admin UI components

This is not a deep dive into everything you can learn by reading the source of the component you're overriding. It's a guide to the two patterns for overriding itself (same name, and configuration).

docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
@abea
Copy link
Contributor

abea commented Nov 24, 2021

@boutell Are you looking for an initial review?

@boutell boutell changed the title PRO-2355 document component override patterns PRO-2355 document component admin UI extension patterns Nov 28, 2021
@boutell boutell marked this pull request as ready for review November 28, 2021 19:58
@boutell
Copy link
Member Author

boutell commented Nov 28, 2021

This is now ready for proper review. In the end I was able to cover the three major cases right now — override by name, override by configuration (for situations where subclassing makes override by name a bad idea), and custom schema fields, which includes a full example.

You can find a working example of the custom schema field shown here in the star-rating-field branch of testbed, which I'm also pushing as a PR, seems like a good idea to validate we don't break these.

Copy link
Contributor

@abea abea left a comment

Choose a reason for hiding this comment

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

A bunch of line notes and suggestions. The field type tutorial is awesome and deserves to be its own page.

docs/.vuepress/sidebar.js Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/.vuepress/sidebar.js Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
docs/guide/custom-ui.md Outdated Show resolved Hide resolved
…d in a better pedagogical order that emphasizes adding things (custom schema field types, custom columns) over overriding things
@boutell boutell requested a review from abea January 3, 2022 14:53
@boutell
Copy link
Member Author

boutell commented Jan 3, 2022

Implemented Bea's notes, added custom column coverage, and reorganized in a better pedagogical order that emphasizes adding things (custom schema field types, custom columns) over overriding things

@abea
Copy link
Contributor

abea commented Jan 3, 2022

@boutell The big thing I'm seeing as I start review is that the custom field types section is still part of the same UI page. That should be a separate code recipe page (how to).

docs/guide/custom-ui.md Outdated Show resolved Hide resolved

## Overriding standard Vue.js components through configuration

There can be only one `AposDocsManager` Vue.js component definition in a project, but sometimes we need different behavior for a specific piece type only. We could work around this by overriding a core component and adding conditional logic, but this results in code that is hard to maintain, and also means we are stuck maintaining a copy of a complex component and missing out on bug fixes and improvements. It would be better if we could **specify a different, custom component name to be used** to manage a particular piece type.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few previous comments that you don't seem to have addressed here.

Remove "Vue.js" from "only one AposDocsManager Vue.js component in a project". Not critical, but repetitive.

Remove "only" at the end of the second sentence as it's redundant.

We could work around this by overriding" to "We could override" (then, "and add"). Period after "hard to maintain," then new sentence.

It would be better if we could...

"Could" isn't necessary since the purpose here is to show they can. Simply "It would be better to specify...".

docs/guide/custom-ui.md Outdated Show resolved Hide resolved
The `AposWidget` component has **nothing to do with a typical site visitor experience.** It is used only when displaying our widget while the page is in edit mode. While overriding this component is rare, but the `@apostrophecms/rich-text-widget` module does so to provide a "click the text to edit" experience for rich text widgets. If you're just trying to enhance your widget with frontend JavaScript, you should write a [widget player](custom-widgets.md#client-side-javascript-for-widgets) instead.
:::

## Registering custom field types
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a code recipe page instead. It's a separate section in the navigation. If you break this out to a new page I can help with the nav.

I see the value for this topic in terms of expanding UI options. It would make sense to have a paragraph that introduces this idea and links over to the code recipe. There's simply more to custom field types than customizing UI.

docs/guide/custom-ui.md Show resolved Hide resolved
docs/guide/custom-ui.md Show resolved Hide resolved
@boutell boutell requested a review from abea January 5, 2022 14:29
@boutell
Copy link
Member Author

boutell commented Jan 5, 2022

I've refactored as requested. It makes sense for it to be a separate article. However I wanted to run a concern by you:

I'm not convinced this new article belongs in "cookbook" and not "guide." Compare it to "custom batch operations" or "custom widgets." It's similar in structure and its role is similarly to document a clearly defined core feature with examples. "Cookbook" so far seems to be the domain of things that aren't Apostrophe features per se but Apostrophe devs want to know more about, like navigation or specific hosting situations. Custom schema field types aren't a special case or a particular application, they are a primary feature with a well-defined boundary. As a user I would expect to be able to find them in the side nav of the guide with similar topics, but instead they are in the cookbook which is not part of that. "Advanced topics" within the guide seems like the more natural place.

@abea
Copy link
Contributor

abea commented Jan 5, 2022

That's a good point. It makes sense to me to put it in a nav section such as "Other customizations" parallel to "Other module config."

@boutell
Copy link
Member Author

boutell commented Jan 5, 2022 via email

@abea
Copy link
Contributor

abea commented Jan 5, 2022

sure

docs/guide/custom-ui.md Outdated Show resolved Hide resolved
@boutell boutell merged commit 65ed83a into main Jan 5, 2022
@abea abea deleted the pro-2355 branch January 5, 2022 16:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants