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

feat(app): dynamic Techdocs addons #2238

Merged
merged 32 commits into from
Feb 10, 2025

Conversation

dzemanov
Copy link
Member

@dzemanov dzemanov commented Jan 23, 2025

Description

This change adds support for dynamically loading Techdocs Addons. It creates a wrapper for techdocs-module-addons-contrib which contains techdocs extensions:

  • LightBox
  • ReportIssue
  • TextSize
  • ExpandableNavigation

A plugin can export a Techdocs extension like:

export const TextSize = techdocsModuleAddonsContribPlugin.provide(
  createTechDocsAddonExtension({
    name: 'TextSize',
    location: TechDocsAddonLocations.Settings,
    component: TextSizeAddon,
  }),
);

Use new configuration option:

frontend:
  backstage.plugin-techdocs-module-addons-contrib:
    techdocsAddons:
      - importName: TextSize

Which issue(s) does this PR fix

PR acceptance criteria

Please make sure that the following steps are complete:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

How to test changes / Special notes to the reviewer

You can add to app-config.yaml this config:

techdocs:
  builder: 'local'

dynamicPlugins:
  rootDirectory: dynamic-plugins-root
  frontend:
    backstage.plugin-techdocs:
      routeBindings:
        targets:
          - importName: techdocsPlugin
        bindings:
          - bindTarget: catalogPlugin.externalRoutes
            bindMap:
              viewTechDoc: techdocsPlugin.routes.docRoot
          - bindTarget: scaffolderPlugin.externalRoutes
            bindMap:
              viewTechDoc: techdocsPlugin.routes.docRoot
      dynamicRoutes:
        - path: /docs
          importName: TechDocsIndexPage
          menuItem:
            icon: docs
            text: Docs
        - path: /docs/:namespace/:kind/:name/*
          importName: TechDocsReaderPage
      mountPoints:
        - mountPoint: entity.page.docs/cards
          importName: EntityTechdocsContent
          config:
            layout:
              gridColumn: "1 / -1"
            if:
              allOf:
                - isTechDocsAvailable
        - mountPoint: search.page.results
          importName: TechDocsSearchResultListItem
        - mountPoint: search.page.filters
          importName: TechdocsSearchFilter
        - mountPoint: search.page.types
          importName: techdocsSearchType
          config:
            props:
              name: Documentation
              icon: docs

    backstage.plugin-techdocs-module-addons-contrib:
      techdocsAddons:
        - importName: TextSize
        - importName: LightBox
        - importName: ReportIssue
        - importName: ExpandableNavigation
2025-01-24.12-39-47.mp4

@dzemanov dzemanov marked this pull request as draft January 23, 2025 08:38
@dzemanov dzemanov changed the title Techdocs addons feat(app): dynamic Techdocs addons Jan 23, 2025
@dzemanov dzemanov force-pushed the techdocs-addons branch 4 times, most recently from 5187cf2 to fdd354b Compare January 23, 2025 09:21
Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

@dzemanov
Copy link
Member Author

/cc @gashcrumb can you take a look if this approach is alright? There is a bug with ReportIssue and maybe ExpandableNavigation but otherwise addons should work correctly. TextSize addon adds settings at the docs top which can change the size of text, LightBox enables to view pictures in overlay.

@dzemanov
Copy link
Member Author

ReportIssue bug is fixed.
Not sure if I can use importName for the filtering for TechDocs dynamic components or is there something better / safer to use.

@dzemanov dzemanov marked this pull request as ready for review January 23, 2025 17:59
@openshift-ci openshift-ci bot requested a review from coreydaley January 23, 2025 17:59
Copy link
Contributor

Copy link
Contributor

@dzemanov
Copy link
Member Author

Removed previously added "@backstage/plugin-techdocs-react" dependency to app and removed importName filtering.
Introduced option of passing dynamicConfig to staticJSXContent.

Copy link
Contributor

@dzemanov
Copy link
Member Author

dzemanov commented Feb 3, 2025

/cc @davidfestal
/cc @kadel
/cc @christoph-jerolimov

Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
@dzemanov
Copy link
Member Author

/retest

Copy link
Contributor

@christoph-jerolimov
Copy link
Member

For some reason I didn't understand yet, the latest version didn't worked on a cluster.

Absolutely no dynamic plugin is loaded. We need to check if its this PR or a general issue. But to be save I mark this as

/hold

@PatAKnight
Copy link
Member

@christoph-jerolimov I was able to make it work on a cluster. Wonder if there was some other issue that was popping up for you?

Screenshot from 2025-02-10 12-16-57

@@ -471,6 +471,9 @@ dynamicPlugins:
props:
name: Documentation
icon: docs
backstage.plugin-techdocs-module-addons-contrib:
Copy link
Member

Choose a reason for hiding this comment

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

I've seen both a . and a - used as the org/package separator. I think we should consider that inconsistency here confuses users, and I wonder if we shouldn't just stick with using -. I'll have a 2nd comment on this in the plugin's scalprum config :-)

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 would maybe let it be this way for now, but we can do a following bulk update for all the plugins that have it this way.

Copy link
Member

Choose a reason for hiding this comment

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

yep, I don't know if there's any formal convention here so maybe one needs to be established.

"dist",
"dist-scalprum"
],
"scalprum": {
Copy link
Member

@gashcrumb gashcrumb Feb 10, 2025

Choose a reason for hiding this comment

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

Is it necessary to add this config? Without it I believe the scalprum name would be backstage-plugin-techdocs-module-addons-contrib which I think actually is less confusing as it's taken from the package.json name. I just worry these slight differences here and there confuse users, I recently had a conversation around this field, the package name and what is used in the configuration. Maybe not something to fix right now but to consider very soon.

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, not necessary. I have seen both versions being used, it would be great to unify this.

Copy link
Member

@gashcrumb gashcrumb left a comment

Choose a reason for hiding this comment

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

I did a quick local test using the PR image and could see the add-ons installed, very nice! A couple comments but nothing that needs to be addressed in this PR.

@christoph-jerolimov
Copy link
Member

I've tested it now again on a new cluster and couldn't reproduce my earlier issue. 🤷‍♂️

/lgtm
/unhold

Copy link

openshift-ci bot commented Feb 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christoph-jerolimov, gashcrumb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [christoph-jerolimov,gashcrumb]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 56cbf89 into redhat-developer:main Feb 10, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants