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(scaffolder/next): Markdown text output #17641

Merged
merged 8 commits into from
May 9, 2023

Conversation

voximity
Copy link
Contributor

@voximity voximity commented May 3, 2023

Hey, I just made a Pull Request!

This PR adds support for text outputs on templates in scaffolder/next. Addresses #17596.

output:
  text:
    - title: Test Text
      content: |
        Hello, world! This is some markdown!

        ```
        console.log("Hello, world!");
        ```

image

They appear like link outputs, but can be clicked to reveal a box that renders their content as Markdown.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
    • No tests are done on existing scaffolder output, so this was skipped
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Signed-off-by: Zander Franks <zander@zanderf.net>
Signed-off-by: Zander Franks <zander@zanderf.net>
Signed-off-by: Zander Franks <zander@zanderf.net>
@voximity voximity requested a review from a team as a code owner May 3, 2023 22:58
@voximity voximity requested a review from benjdlambert May 3, 2023 22:58
@github-actions github-actions bot added documentation Improvements or additions to documentation area:scaffolder Everything and all things related to the scaffolder project area labels May 3, 2023
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented May 3, 2023

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/plugin-scaffolder-common plugins/scaffolder-common minor v1.2.7
@backstage/plugin-scaffolder-react plugins/scaffolder-react minor v1.3.1-next.1

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

Uffizzi Preview deployment-24272 was deleted.

Signed-off-by: Zander Franks <zander@zanderf.net>
Signed-off-by: Zander Franks <zander@zanderf.net>
Copy link
Member

@benjdlambert benjdlambert left a comment

Choose a reason for hiding this comment

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

Nice! thanks for this! Looking great. Just a few comments here!

.changeset/heavy-penguins-burn.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can get some tests for this too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm working on writing some tests, but I'm having trouble with the call to useRouteRef(entityRouteRef); in LinkOutputs.tsx:

image

Are there some Jest features or some parent component to render around DefaultTemplateOutputs that will solve this problem?

Copy link
Member

Choose a reason for hiding this comment

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

You could try using renderInTestApp instead, and look for some examples with having entityRouteRef being used in mountedRoutes i think it is.

Something like this should work:

wrapInTestApp(
<>
<TestApiProvider
apis={[
[stackOverflowApiRef, mockStackOverflowApi],
[catalogApiRef, mockCatalogApi],
[starredEntitiesApiRef, starredEntitiesApi],
[searchApiRef, { query: () => Promise.resolve({ results: [] }) }],
[
configApiRef,
new ConfigReader({
stackoverflow: {
baseUrl: 'https://api.stackexchange.com/2.2',
},
}),
],
]}
>
<Story />
</TestApiProvider>
</>,
{
mountedRoutes: {
'/hello-company': searchPlugin.routes.root,
'/catalog/:namespace/:kind/:name': entityRouteRef,
},
},
),

The mountedRoutes part is important with the entityRouteRef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, this works! I've written a small test for DefaultTemplateOutputs. Let me know what you think! I couldn't think of an intuitive way to dynamically test the body of text outputs because of Markdown -- we could fix this by hard-coding test cases instead of reading from the output object.

docs/features/software-templates/writing-templates.md Outdated Show resolved Hide resolved
plugins/scaffolder-common/src/Template.v1beta3.schema.json Outdated Show resolved Hide resolved
voximity and others added 2 commits May 4, 2023 12:37
Signed-off-by: Zander Franks <zander@zanderf.net>
Signed-off-by: Zander <me@zanderf.net>
Copy link
Member

@benjdlambert benjdlambert left a comment

Choose a reason for hiding this comment

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

Just a comment about what to do with the build failure.

text:
- title: More information
content: |
Access the \[remote repository\](${{ steps['publish'].output.remoteUrl }}).
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I think that this example isn't compatible with our tooling which checks that all links are valid. Might be a little bug there. I wonder if we can just do simpler example here for now so we can get this in the release and we can take a look at that bug which is making this fail at a later date.

Signed-off-by: Zander Franks <zander@zanderf.net>
@benjdlambert
Copy link
Member

Nice thanks!

@benjdlambert benjdlambert merged commit 94dbeba into backstage:master May 9, 2023
29 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2023

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.14.0 release, scheduled for Tue, 16 May 2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:scaffolder Everything and all things related to the scaffolder project area documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants