Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioUyaguari committed Nov 2, 2021
1 parent 19c81a0 commit 3469dda
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 259 deletions.
32 changes: 16 additions & 16 deletions packages/legend-server-sdlc/src/SDLCServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export class SDLCServerClient extends AbstractServerClient {
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
): Promise<PlainObject<Workflow>[]> =>
): Promise<PlainObject<Workflow>> =>
this.networkClient.get(this._workflow(projectId, workspace, workflowId));
getWorkflows = (
projectId: string,
Expand All @@ -382,30 +382,30 @@ export class SDLCServerClient extends AbstractServerClient {
undefined,
{ status, revisionIds, limit },
);
getWorkflowJobs = (
getWorkflowsByRevision = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
status: WorkflowStatus | undefined,
revisionIds: string[] | undefined,
limit: number | undefined,
revisionId: string | RevisionAlias,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.get(
this._workflowJobs(projectId, workspace, workflowId),
this._workflows(projectId, workspace),
undefined,
undefined,
{ status, revisionIds, limit },
{ revisionId },
);
getWorkflowsByRevision = (
getWorkflowJobs = (
projectId: string,
workspace: Workspace | undefined,
revisionId: string | RevisionAlias,
): Promise<PlainObject<Workflow>[]> =>
workflowId: string,
status: WorkflowStatus | undefined,
revisionIds: string[] | undefined,
limit: number | undefined,
): Promise<PlainObject<WorkflowJob>[]> =>
this.networkClient.get(
this._workflows(projectId, workspace),
this._workflowJobs(projectId, workspace, workflowId),
undefined,
undefined,
{ revisionId },
{ status, revisionIds, limit },
);
getWorkflowJob = (
projectId: string,
Expand Down Expand Up @@ -439,7 +439,7 @@ export class SDLCServerClient extends AbstractServerClient {
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<void> =>
): Promise<PlainObject<WorkflowJob>> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
Expand All @@ -452,7 +452,7 @@ export class SDLCServerClient extends AbstractServerClient {
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<void> =>
): Promise<PlainObject<WorkflowJob>> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
Expand All @@ -465,7 +465,7 @@ export class SDLCServerClient extends AbstractServerClient {
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<void> =>
): Promise<PlainObject<WorkflowJob>> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ import type {
WorkflowExplorerTreeNodeData,
WorkflowLogState,
WorkspaceWorkflowsState,
WorkspaceWorkflowState,
} from '../../../stores/sidebar-state/WorkspaceWorkflowsState';
import {
WorkflowJobTreeNodeData,
WorkflowTreeNodeData,
} from '../../../stores/sidebar-state/WorkspaceWorkflowsState';
import { guaranteeType, isNonNullable } from '@finos/legend-shared';
import {
guaranteeNonNullable,
guaranteeType,
isNonNullable,
} from '@finos/legend-shared';
import { Dialog } from '@material-ui/core';
import { StudioTextInputEditor } from '../../shared/StudioTextInputEditor';

Expand Down Expand Up @@ -188,21 +193,21 @@ const WorkflowJobLogsViewer = observer(
logState: WorkflowLogState;
}) => {
const { workflowState, logState } = props;
const job = logState.job;
const job = guaranteeNonNullable(logState.job);
const jobIsInProgress = job.status === WorkflowJobStatus.IN_PROGRESS;
const closeLogViewer = (): void => {
workflowState.setWorkflowJobLogState(undefined);
flowResult(workflowState.refreshWorkflows()).catch(
logState.closeModal();
flowResult(workflowState.fetchAllWorkspaceWorkflows()).catch(
workflowState.editorStore.applicationStore.alertIllegalUnhandledError,
);
};
const refreshLogs = (): void => {
logState.refreshJobLogs();
logState.refreshJobLogs(job);
};
const logs = logState.logs;
return (
<Dialog
open={Boolean(workflowState.workflowJobLogState)}
open={Boolean(logState.job)}
onClose={closeLogViewer}
classes={{
root: 'editor-modal__root-container',
Expand All @@ -211,6 +216,9 @@ const WorkflowJobLogsViewer = observer(
}}
>
<div className="modal modal--dark editor-modal">
<PanelLoadingIndicator
isLoading={logState.fetchJobLogState.isInProgress}
/>
<div className="modal__header">
<div className="modal__title">{`Logs for ${job.name} #${job.id}`}</div>
<div className="modal__header__actions">
Expand Down Expand Up @@ -248,13 +256,14 @@ const WorkflowJobLogsViewer = observer(
const WorkflowExplorerContextMenu = observer(
(
props: {
workflowState: WorkspaceWorkflowsState;
workflowsState: WorkspaceWorkflowsState;
workflowState: WorkspaceWorkflowState;
node: WorkflowExplorerTreeNodeData;
treeData: TreeData<WorkflowExplorerTreeNodeData>;
},
ref: React.Ref<HTMLDivElement>,
) => {
const { node, workflowState, treeData } = props;
const { node, workflowsState, workflowState, treeData } = props;
const retryJob = (): void => {
if (node instanceof WorkflowJobTreeNodeData) {
workflowState.retryJob(node.workflowJob, treeData);
Expand All @@ -267,7 +276,7 @@ const WorkflowExplorerContextMenu = observer(
};
const viewLogs = (): void => {
if (node instanceof WorkflowJobTreeNodeData) {
workflowState.viewJobLogs(node.workflowJob);
workflowsState.logState.viewJobLogs(node.workflowJob);
}
};
const visitWeburl = (): void => {
Expand Down Expand Up @@ -311,13 +320,14 @@ const WorkflowTreeNodeContainer: React.FC<
TreeNodeContainerProps<
WorkflowExplorerTreeNodeData,
{
workflowState: WorkspaceWorkflowsState;
workflowsState: WorkspaceWorkflowsState;
workflowState: WorkspaceWorkflowState;
treeData: TreeData<WorkflowExplorerTreeNodeData>;
}
>
> = (props) => {
const { node, level, stepPaddingInRem, onNodeSelect } = props;
const { workflowState, treeData } = props.innerProps;
const { workflowsState, treeData, workflowState } = props.innerProps;
const expandIcon = !(node instanceof WorkflowTreeNodeData) ? (
<div />
) : node.isOpen ? (
Expand All @@ -336,6 +346,7 @@ const WorkflowTreeNodeContainer: React.FC<
<ContextMenu
content={
<WorkflowExplorerContextMenu
workflowsState={workflowsState}
workflowState={workflowState}
treeData={treeData}
node={node}
Expand Down Expand Up @@ -412,38 +423,21 @@ const WorkflowTreeNodeContainer: React.FC<
export const WorkspaceWorkflows = observer(() => {
const editorStore = useEditorStore();
const applicationStore = useApplicationStore();
const workflowState = editorStore.workspaceWorkflowsState;
const workflowTreeData = workflowState.workflowTreeData;
const isDispatchingAction = workflowState.isExecutingWorkflowRequest;
const workflowsState = editorStore.workspaceWorkflowsState;
const logState = workflowsState.logState;
const isDispatchingAction =
workflowsState.fetchWorkflowsState.isInProgress ||
Boolean(
workflowsState.workflowStates.find((e) => e.isExecutingWorkflowRequest),
);
const refresh = applicationStore.guaranteeSafeAction(() =>
flowResult(workflowState.refreshWorkflows()),
flowResult(workflowsState.fetchAllWorkspaceWorkflows()),
);
const onNodeSelect = (node: WorkflowExplorerTreeNodeData): void => {
if (workflowTreeData) {
workflowState.onTreeNodeSelect(node, workflowTreeData);
}
};

const getChildNodes = (
node: WorkflowExplorerTreeNodeData,
): WorkflowExplorerTreeNodeData[] => {
if (
node.childrenIds &&
node instanceof WorkflowTreeNodeData &&
workflowTreeData
) {
return node.childrenIds
.map((id) => workflowTreeData.nodes.get(id))
.filter(isNonNullable);
}
return [];
};

useEffect(() => {
flowResult(workflowState.fetchAllWorkspaceWorkflows()).catch(
flowResult(workflowsState.fetchAllWorkspaceWorkflows()).catch(
applicationStore.alertIllegalUnhandledError,
);
}, [applicationStore, workflowState]);
}, [applicationStore, workflowsState]);

return (
<div className="panel workspace-workflows">
Expand All @@ -462,7 +456,7 @@ export const WorkspaceWorkflows = observer(() => {
isDispatchingAction,
},
)}
disabled={isDispatchingAction || !workflowTreeData}
disabled={isDispatchingAction}
onClick={refresh}
tabIndex={-1}
title="Refresh"
Expand All @@ -482,30 +476,50 @@ export const WorkspaceWorkflows = observer(() => {
className="side-bar__panel__header__changes-count"
data-testid={STUDIO_TEST_ID.SIDEBAR_PANEL_HEADER__CHANGES_COUNT}
>
{workflowState.workflows.length}
{workflowsState.workflowStates.length}
</div>
</div>
<div className="panel__content">
{workflowTreeData && (
<TreeView
components={{
TreeNodeContainer: WorkflowTreeNodeContainer,
}}
treeData={workflowTreeData}
onNodeSelect={onNodeSelect}
getChildNodes={getChildNodes}
innerProps={{
workflowState,
treeData: workflowTreeData,
}}
/>
)}
{workflowsState.workflowStates.map((workflowState) => {
const onNodeSelect = (
node: WorkflowExplorerTreeNodeData,
): void => {
workflowState.onTreeNodeSelect(node, workflowState.treeData);
};
const getChildNodes = (
node: WorkflowExplorerTreeNodeData,
): WorkflowExplorerTreeNodeData[] => {
if (node.childrenIds && node instanceof WorkflowTreeNodeData) {
return node.childrenIds
.map((id) => workflowState.treeData.nodes.get(id))
.filter(isNonNullable);
}
return [];
};

return (
<TreeView
components={{
TreeNodeContainer: WorkflowTreeNodeContainer,
}}
key={workflowState.uuid}
treeData={workflowState.treeData}
onNodeSelect={onNodeSelect}
getChildNodes={getChildNodes}
innerProps={{
workflowsState: workflowsState,
workflowState: workflowState,
treeData: workflowState.treeData,
}}
/>
);
})}
</div>
</div>
{workflowState.workflowJobLogState && (
{logState.job && (
<WorkflowJobLogsViewer
logState={workflowState.workflowJobLogState}
workflowState={workflowState}
logState={logState}
workflowState={workflowsState}
/>
)}
</div>
Expand Down
Loading

0 comments on commit 3469dda

Please sign in to comment.