Slightly improve types
Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
@@ -46,4 +46,14 @@ Looking at the flow above, a common release lifecycle could be:
|
||||
|
||||
## Usage
|
||||
|
||||
### Importing
|
||||
|
||||
The plugin exports a single full-page extension `GitHubReleaseManagerPage`, which one can add to an app like a usual top-level tool on a dedicated route.
|
||||
|
||||
### Configuration
|
||||
|
||||
The plugin is configurable either via props or the select elements on the page.
|
||||
|
||||
If project configuration is provided via props, the select elements are disabled. It is also possible to omit components from the page via props, as well as attaching callbacks for successful executions.
|
||||
|
||||
See the plugin's dev folder (`dev/index.tsx`) to see some examples.
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
import React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
import { Typography } from '@material-ui/core';
|
||||
|
||||
import {
|
||||
gitHubReleaseManagerPlugin,
|
||||
GitHubReleaseManagerPage,
|
||||
} from '../src/plugin';
|
||||
import { InfoCardPlus } from '../src/components/InfoCardPlus';
|
||||
|
||||
function DevWrapper({ children }: { children: React.ReactNode }) {
|
||||
return <div style={{ padding: 30 }}>{children}</div>;
|
||||
@@ -31,21 +32,30 @@ createDevApp()
|
||||
.registerPlugin(gitHubReleaseManagerPlugin)
|
||||
.addPage({
|
||||
title: 'Dynamic',
|
||||
path: '/dynamic',
|
||||
element: (
|
||||
<>
|
||||
<Alert severity="info">Configure via select inputs</Alert>
|
||||
<DevWrapper>
|
||||
<InfoCardPlus>
|
||||
<Typography variant="h4">Dev notes</Typography>
|
||||
<Typography>Configure plugin via select inputs</Typography>
|
||||
</InfoCardPlus>
|
||||
|
||||
<DevWrapper>
|
||||
<GitHubReleaseManagerPage />
|
||||
</DevWrapper>
|
||||
</>
|
||||
<GitHubReleaseManagerPage />
|
||||
</DevWrapper>
|
||||
),
|
||||
})
|
||||
.addPage({
|
||||
title: 'Static',
|
||||
path: '/static',
|
||||
element: (
|
||||
<DevWrapper>
|
||||
<Alert severity="info">Statically configured via props</Alert>
|
||||
<InfoCardPlus>
|
||||
<Typography variant="h4">Dev notes</Typography>
|
||||
<Typography>
|
||||
Configure plugin statically by passing props to the
|
||||
`GitHubReleaseManagerPage` component
|
||||
</Typography>
|
||||
</InfoCardPlus>
|
||||
|
||||
<GitHubReleaseManagerPage
|
||||
project={{
|
||||
@@ -59,9 +69,14 @@ createDevApp()
|
||||
})
|
||||
.addPage({
|
||||
title: 'Omit',
|
||||
path: '/omit',
|
||||
element: (
|
||||
<DevWrapper>
|
||||
<Alert severity="info">Optionally omit components</Alert>
|
||||
<InfoCardPlus>
|
||||
<Typography variant="h4">Dev notes</Typography>
|
||||
<Typography>Each components can be omitted</Typography>
|
||||
<Typography>Success callbacks can also be added</Typography>
|
||||
</InfoCardPlus>
|
||||
|
||||
<GitHubReleaseManagerPage
|
||||
project={{
|
||||
@@ -89,8 +104,12 @@ createDevApp()
|
||||
);
|
||||
},
|
||||
},
|
||||
promoteRc: { omit: true },
|
||||
patch: { omit: true },
|
||||
promoteRc: {
|
||||
omit: true,
|
||||
},
|
||||
patch: {
|
||||
omit: true,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</DevWrapper>
|
||||
|
||||
@@ -94,14 +94,14 @@ export function Cards({
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{components?.info?.omit !== true && (
|
||||
{!components?.info?.omit && (
|
||||
<Info
|
||||
latestRelease={gitHubBatchInfo.value.latestRelease}
|
||||
releaseBranch={gitHubBatchInfo.value.releaseBranch}
|
||||
/>
|
||||
)}
|
||||
|
||||
{components?.createRc?.omit !== true && (
|
||||
{!components?.createRc?.omit && (
|
||||
<CreateRc
|
||||
latestRelease={gitHubBatchInfo.value.latestRelease}
|
||||
releaseBranch={gitHubBatchInfo.value.releaseBranch}
|
||||
@@ -110,14 +110,14 @@ export function Cards({
|
||||
/>
|
||||
)}
|
||||
|
||||
{components?.promoteRc?.omit !== true && (
|
||||
{!components?.promoteRc?.omit && (
|
||||
<PromoteRc
|
||||
latestRelease={gitHubBatchInfo.value.latestRelease}
|
||||
successCb={components?.promoteRc?.successCb}
|
||||
/>
|
||||
)}
|
||||
|
||||
{components?.patch?.omit !== true && (
|
||||
{!components?.patch?.omit && (
|
||||
<Patch
|
||||
latestRelease={gitHubBatchInfo.value.latestRelease}
|
||||
releaseBranch={gitHubBatchInfo.value.releaseBranch}
|
||||
|
||||
@@ -14,21 +14,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface ComponentConfig<Args = void> {
|
||||
successCb?: (args: Args) => Promise<void> | void;
|
||||
omit?: boolean;
|
||||
}
|
||||
export type ComponentConfig<Args> =
|
||||
| {
|
||||
omit?: void;
|
||||
successCb?: (args: Args) => Promise<void> | void;
|
||||
}
|
||||
| {
|
||||
omit: boolean;
|
||||
successCb?: void;
|
||||
};
|
||||
|
||||
interface ComponentConfigCreateRcSuccessCbArgs {
|
||||
interface CreateRcSuccessCbArgs {
|
||||
gitHubReleaseUrl: string;
|
||||
gitHubReleaseName: string | null;
|
||||
comparisonUrl: string;
|
||||
previousTag?: string;
|
||||
createdTag: string;
|
||||
}
|
||||
export type ComponentConfigCreateRc = ComponentConfig<ComponentConfigCreateRcSuccessCbArgs>;
|
||||
export type ComponentConfigCreateRc = ComponentConfig<CreateRcSuccessCbArgs>;
|
||||
|
||||
interface ComponentConfigPromoteRcSuccessCbArgs {
|
||||
interface PromoteRcSuccessCbArgs {
|
||||
gitHubReleaseUrl: string;
|
||||
gitHubReleaseName: string | null;
|
||||
previousTagUrl: string;
|
||||
@@ -36,9 +41,9 @@ interface ComponentConfigPromoteRcSuccessCbArgs {
|
||||
updatedTagUrl: string;
|
||||
updatedTag: string;
|
||||
}
|
||||
export type ComponentConfigPromoteRc = ComponentConfig<ComponentConfigPromoteRcSuccessCbArgs>;
|
||||
export type ComponentConfigPromoteRc = ComponentConfig<PromoteRcSuccessCbArgs>;
|
||||
|
||||
interface ComponentConfigPatchSuccessCbArgs {
|
||||
interface PatchSuccessCbArgs {
|
||||
updatedReleaseUrl: string;
|
||||
updatedReleaseName: string | null;
|
||||
previousTag: string;
|
||||
@@ -46,7 +51,7 @@ interface ComponentConfigPatchSuccessCbArgs {
|
||||
patchCommitUrl: string;
|
||||
patchCommitMessage: string;
|
||||
}
|
||||
export type ComponentConfigPatch = ComponentConfig<ComponentConfigPatchSuccessCbArgs>;
|
||||
export type ComponentConfigPatch = ComponentConfig<PatchSuccessCbArgs>;
|
||||
|
||||
export interface ResponseStep {
|
||||
message: string | React.ReactNode;
|
||||
|
||||
Reference in New Issue
Block a user