diff --git a/.changeset/dull-onions-remember.md b/.changeset/dull-onions-remember.md new file mode 100644 index 0000000000..f309bf5c4c --- /dev/null +++ b/.changeset/dull-onions-remember.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-stackstorm': patch +--- + +Add props to StackstormHome for Header Customization diff --git a/plugins/stackstorm/api-report.md b/plugins/stackstorm/api-report.md index 3e3d79fe27..7a307847cd 100644 --- a/plugins/stackstorm/api-report.md +++ b/plugins/stackstorm/api-report.md @@ -6,10 +6,18 @@ /// import { BackstagePlugin } from '@backstage/core-plugin-api'; +import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; +// @public (undocumented) +export type StackstormHomeProps = { + title?: string; + subtitle?: string; + headerButtons?: React_2.ReactNode[]; +}; + // @public -export const StackstormPage: () => JSX.Element; +export const StackstormPage: (props: StackstormHomeProps) => JSX.Element; // @public export const stackstormPlugin: BackstagePlugin< diff --git a/plugins/stackstorm/package.json b/plugins/stackstorm/package.json index 1f3a014b0a..9125ac08af 100644 --- a/plugins/stackstorm/package.json +++ b/plugins/stackstorm/package.json @@ -40,6 +40,7 @@ "@backstage/theme": "workspace:^", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", + "@types/react": "^16.13.1 || ^17.0.0", "react-use": "^17.2.4" }, "peerDependencies": { @@ -57,7 +58,6 @@ "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", "@types/node": "*", - "@types/react": "^16.13.1 || ^17.0.0", "msw": "^1.0.0" }, "files": [ diff --git a/plugins/stackstorm/src/components/StackstormHome/StackstormHome.test.tsx b/plugins/stackstorm/src/components/StackstormHome/StackstormHome.test.tsx index 897cec61c1..e3db4c0cac 100644 --- a/plugins/stackstorm/src/components/StackstormHome/StackstormHome.test.tsx +++ b/plugins/stackstorm/src/components/StackstormHome/StackstormHome.test.tsx @@ -35,4 +35,19 @@ describe('StackstormHome', () => { ); expect(screen.getByText('Welcome to StackStorm!')).toBeInTheDocument(); }); + + it('should render props', async () => { + await renderInTestApp( + + Test Header Button]} + /> + , + ); + expect(screen.getByText('Test Title')).toBeInTheDocument(); + expect(screen.getByText('Test Subtitle')).toBeInTheDocument(); + expect(screen.getByText('Test Header Button')).toBeInTheDocument(); + }); }); diff --git a/plugins/stackstorm/src/components/StackstormHome/StackstormHome.tsx b/plugins/stackstorm/src/components/StackstormHome/StackstormHome.tsx index d96d45e82d..1bb9031815 100644 --- a/plugins/stackstorm/src/components/StackstormHome/StackstormHome.tsx +++ b/plugins/stackstorm/src/components/StackstormHome/StackstormHome.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react'; +import React, { Fragment } from 'react'; import { IconButton } from '@material-ui/core'; import { Header, @@ -27,12 +27,30 @@ import { ExecutionsTable } from '../ExecutionsTable'; import { PacksTable } from '../PacksTable/PacksTable'; import { ActionsList } from '../ActionsList'; -export const StackstormHome = () => ( +/** + * @public + */ +export type StackstormHomeProps = { + title?: string; + subtitle?: string; + headerButtons?: React.ReactNode[]; +}; + +export const StackstormHome = (props: StackstormHomeProps) => ( -
- - - +
+ {props.headerButtons ? ( + props.headerButtons.map((headerButton, idx) => ( + {headerButton} + )) + ) : ( + + + + )}
diff --git a/plugins/stackstorm/src/components/StackstormHome/index.ts b/plugins/stackstorm/src/components/StackstormHome/index.ts index 2063d21f34..7809223ede 100644 --- a/plugins/stackstorm/src/components/StackstormHome/index.ts +++ b/plugins/stackstorm/src/components/StackstormHome/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { StackstormHome } from './StackstormHome'; +export { StackstormHome, type StackstormHomeProps } from './StackstormHome'; diff --git a/plugins/stackstorm/src/index.ts b/plugins/stackstorm/src/index.ts index b64ae207e4..6775a000fa 100644 --- a/plugins/stackstorm/src/index.ts +++ b/plugins/stackstorm/src/index.ts @@ -21,3 +21,4 @@ */ export { stackstormPlugin, StackstormPage } from './plugin'; +export { type StackstormHomeProps } from './components/StackstormHome';