more api cleanup

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-18 14:11:45 +02:00
parent e195112c5c
commit 3f739be9d9
88 changed files with 358 additions and 594 deletions
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { readGitHubIntegrationConfigs } from '@backstage/integration';
import { useEntity } from '@backstage/plugin-catalog-react';
import {
@@ -27,7 +28,6 @@ import { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunsTable } from '../WorkflowRunsTable';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
import { configApiRef, errorApiRef, useApi } from '@backstage/core-plugin-api';
import {
InfoCard,
@@ -43,20 +43,18 @@ const useStyles = makeStyles<Theme>({
},
});
const WidgetContent = ({
error,
loading,
lastRun,
branch,
}: {
const WidgetContent = (props: {
error?: Error;
loading?: boolean;
lastRun: WorkflowRun;
branch: string;
}) => {
const { error, loading, lastRun, branch } = props;
const classes = useStyles();
if (error) return <Typography>Couldn't fetch latest {branch} run</Typography>;
if (loading) return <LinearProgress />;
return (
<StructuredMetadataTable
metadata={{
@@ -80,11 +78,11 @@ const WidgetContent = ({
);
};
export const LatestWorkflowRunCard = ({
branch = 'master',
// Display the card full height suitable for
variant,
}: Props) => {
export const LatestWorkflowRunCard = (props: {
branch: string;
variant?: InfoCardVariants;
}) => {
const { branch = 'master', variant } = props;
const { entity } = useEntity();
const config = useApi(configApiRef);
const errorApi = useApi(errorApiRef);
@@ -120,15 +118,11 @@ export const LatestWorkflowRunCard = ({
);
};
type Props = {
export const LatestWorkflowsForBranchCard = (props: {
branch: string;
variant?: InfoCardVariants;
};
export const LatestWorkflowsForBranchCard = ({
branch = 'master',
variant,
}: Props) => {
}) => {
const { branch = 'master', variant } = props;
const { entity } = useEntity();
return (
+5
View File
@@ -25,6 +25,7 @@ import {
createComponentExtension,
} from '@backstage/core-plugin-api';
/** @public */
export const githubActionsPlugin = createPlugin({
id: 'github-actions',
apis: [
@@ -40,6 +41,7 @@ export const githubActionsPlugin = createPlugin({
},
});
/** @public */
export const EntityGithubActionsContent = githubActionsPlugin.provide(
createRoutableExtension({
name: 'EntityGithubActionsContent',
@@ -48,6 +50,7 @@ export const EntityGithubActionsContent = githubActionsPlugin.provide(
}),
);
/** @public */
export const EntityLatestGithubActionRunCard = githubActionsPlugin.provide(
createComponentExtension({
name: 'EntityLatestGithubActionRunCard',
@@ -58,6 +61,7 @@ export const EntityLatestGithubActionRunCard = githubActionsPlugin.provide(
}),
);
/** @public */
export const EntityLatestGithubActionsForBranchCard =
githubActionsPlugin.provide(
createComponentExtension({
@@ -71,6 +75,7 @@ export const EntityLatestGithubActionsForBranchCard =
}),
);
/** @public */
export const EntityRecentGithubActionsRunsCard = githubActionsPlugin.provide(
createComponentExtension({
name: 'EntityRecentGithubActionsRunsCard',