move useEventStream into scaffolder-react
Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
@@ -66,11 +66,13 @@
|
||||
"@rjsf/validator-ajv8": "5.1.0",
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"classnames": "^2.2.6",
|
||||
"immer": "^9.0.1",
|
||||
"json-schema": "^0.4.0",
|
||||
"json-schema-library": "^7.3.9",
|
||||
"lodash": "^4.17.21",
|
||||
"qs": "^6.9.4",
|
||||
"react-use": "^17.2.4",
|
||||
"use-immer": "^0.8.0",
|
||||
"zen-observable": "^0.10.0",
|
||||
"zod": "~3.18.0",
|
||||
"zod-to-json-schema": "~3.18.0"
|
||||
|
||||
@@ -16,3 +16,8 @@
|
||||
|
||||
export { useCustomFieldExtensions } from './useCustomFieldExtensions';
|
||||
export { useCustomLayouts } from './useCustomLayouts';
|
||||
export {
|
||||
useTaskEventStream,
|
||||
type TaskStream,
|
||||
type Step,
|
||||
} from './useEventStream';
|
||||
|
||||
+15
@@ -25,6 +25,11 @@ import {
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { Subscription } from '@backstage/types';
|
||||
|
||||
/**
|
||||
* The status of the step being processed
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type Step = {
|
||||
id: string;
|
||||
status: ScaffolderTaskStatus;
|
||||
@@ -32,6 +37,11 @@ export type Step = {
|
||||
startedAt?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A task event from the event stream
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskStream = {
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
@@ -132,6 +142,11 @@ function reducer(draft: TaskStream, action: ReducerAction) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to stream the logs of a task being processed
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const useTaskEventStream = (taskId: string): TaskStream => {
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
const [state, dispatch] = useImmerReducer(reducer, {
|
||||
@@ -82,7 +82,6 @@
|
||||
"luxon": "^3.0.0",
|
||||
"qs": "^6.9.4",
|
||||
"react-use": "^17.2.4",
|
||||
"use-immer": "^0.8.0",
|
||||
"yaml": "^2.0.0",
|
||||
"zen-observable": "^0.10.0",
|
||||
"zod": "~3.18.0",
|
||||
|
||||
@@ -50,8 +50,8 @@ import useInterval from 'react-use/lib/useInterval';
|
||||
import {
|
||||
ScaffolderTaskStatus,
|
||||
ScaffolderTaskOutput,
|
||||
useTaskEventStream,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { useTaskEventStream } from '../hooks/useEventStream';
|
||||
import { TaskErrors } from './TaskErrors';
|
||||
import { TaskPageLinks } from './TaskPageLinks';
|
||||
import {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState, useCallback } from 'react';
|
||||
import { Page, Header, Content, ErrorPanel } from '@backstage/core-components';
|
||||
import { useTaskEventStream } from '../../components/hooks/useEventStream';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, makeStyles, Paper } from '@material-ui/core';
|
||||
import { TaskSteps } from './TaskSteps';
|
||||
@@ -25,7 +24,10 @@ import { nextSelectedTemplateRouteRef } from '../routes';
|
||||
import { useRouteRef } from '@backstage/core-plugin-api';
|
||||
import qs from 'qs';
|
||||
import { ContextMenu } from './ContextMenu';
|
||||
import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react';
|
||||
import {
|
||||
ScaffolderTaskOutput,
|
||||
useTaskEventStream,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { DefaultTemplateOutputs } from '@backstage/plugin-scaffolder-react/alpha';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
Box,
|
||||
} from '@material-ui/core';
|
||||
import { TaskStep } from '@backstage/plugin-scaffolder-common';
|
||||
import { Step } from '../../../components/hooks/useEventStream';
|
||||
import { type Step } from '@backstage/plugin-scaffolder-react';
|
||||
import { StepIcon } from './StepIcon';
|
||||
import { StepTime } from './StepTime';
|
||||
|
||||
|
||||
@@ -7777,11 +7777,13 @@ __metadata:
|
||||
"@testing-library/user-event": ^14.0.0
|
||||
"@types/json-schema": ^7.0.9
|
||||
classnames: ^2.2.6
|
||||
immer: ^9.0.1
|
||||
json-schema: ^0.4.0
|
||||
json-schema-library: ^7.3.9
|
||||
lodash: ^4.17.21
|
||||
qs: ^6.9.4
|
||||
react-use: ^17.2.4
|
||||
use-immer: ^0.8.0
|
||||
zen-observable: ^0.10.0
|
||||
zod: ~3.18.0
|
||||
zod-to-json-schema: ~3.18.0
|
||||
@@ -7848,7 +7850,6 @@ __metadata:
|
||||
msw: ^1.0.0
|
||||
qs: ^6.9.4
|
||||
react-use: ^17.2.4
|
||||
use-immer: ^0.8.0
|
||||
yaml: ^2.0.0
|
||||
zen-observable: ^0.10.0
|
||||
zod: ~3.18.0
|
||||
|
||||
Reference in New Issue
Block a user