Skip to content

Commit

Permalink
chore: improve lint
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Nov 19, 2024
1 parent 2026a07 commit f5f546f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": false,
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.preferences.importModuleSpecifier": "relative",
}
}
9 changes: 7 additions & 2 deletions packages/react-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,16 @@
"@typescript-eslint/no-explicit-any": [
"off"
],
"@typescript-eslint/indent": "off",
"prettier/prettier": [
"error",
{},
{
"usePrettierrc": true
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"jsxBracketSameLine": false
}
]
}
Expand Down
7 changes: 0 additions & 7 deletions packages/react-ui/.prettierrc

This file was deleted.

27 changes: 20 additions & 7 deletions packages/react-ui/src/app/builder/builder-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,31 @@ export type BuilderInitialState = Pick<

export type BuilderStore = ReturnType<typeof createBuilderStore>;

function determineInitiallySelectedStep(
failedStepInRun: string | null,
flowVersion: FlowVersion,
): string | null {
if (failedStepInRun) {
return failedStepInRun;
}
if (flowVersion.state === FlowVersionState.LOCKED) {
return null;
}
return (
flowStructureUtil.getAllSteps(flowVersion.trigger).find((s) => !s.valid)
?.name ?? 'trigger'
);
}

export const createBuilderStore = (initialState: BuilderInitialState) =>
create<BuilderState>((set) => {
const failedStepInRun = initialState.run?.steps
? flowRunUtils.findFailedStepInOutput(initialState.run.steps)
: null;
const initiallySelectedStep =
failedStepInRun ??
initialState.flowVersion.state === FlowVersionState.LOCKED
? null
: flowStructureUtil
.getAllSteps(initialState.flowVersion.trigger)
.find((s) => !s.valid)?.name ?? 'trigger';
const initiallySelectedStep = determineInitiallySelectedStep(
failedStepInRun,
initialState.flowVersion,
);
return {
loopsIndexes:
initialState.run && initialState.run.steps
Expand Down
55 changes: 25 additions & 30 deletions packages/react-ui/src/app/builder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ const BuilderPage = () => {
const leftSidePanelRef = useRef<HTMLDivElement>(null);
const rightSidePanelRef = useRef<HTMLDivElement>(null);


const { versions, refetch: refetchPiece } =
piecesHooks.useMostRecentAndExactPieceVersion({
name: memorizedSelectedStep?.settings.pieceName,
Expand Down Expand Up @@ -182,35 +181,31 @@ const BuilderPage = () => {
<BuilderHeader />
</div>
<ResizablePanelGroup direction="horizontal">
<>
<ResizablePanel
id="left-sidebar"
defaultSize={0}
minSize={0}
maxSize={39}
order={1}
ref={leftHandleRef}
className={cn('min-w-0 bg-background z-20', {
[minWidthOfSidebar]: leftSidebar !== LeftSideBarType.NONE,
[animateResizeClassName]: !isDraggingHandle,
})}
>
<div ref={leftSidePanelRef} className="w-full h-full">
{leftSidebar === LeftSideBarType.RUNS && <RunsList />}
{leftSidebar === LeftSideBarType.RUN_DETAILS && (
<FlowRunDetails />
)}
{leftSidebar === LeftSideBarType.VERSIONS && <FlowVersionsList />}
{leftSidebar === LeftSideBarType.AI_COPILOT && <CopilotSidebar />}
</div>
</ResizablePanel>
<ResizableHandle
disabled={leftSidebar === LeftSideBarType.NONE}
withHandle={leftSidebar !== LeftSideBarType.NONE}
onDragging={setIsDraggingHandle}
className="z-20"
/>
</>
<ResizablePanel
id="left-sidebar"
defaultSize={0}
minSize={0}
maxSize={39}
order={1}
ref={leftHandleRef}
className={cn('min-w-0 bg-background z-20', {
[minWidthOfSidebar]: leftSidebar !== LeftSideBarType.NONE,
[animateResizeClassName]: !isDraggingHandle,
})}
>
<div ref={leftSidePanelRef} className="w-full h-full">
{leftSidebar === LeftSideBarType.RUNS && <RunsList />}
{leftSidebar === LeftSideBarType.RUN_DETAILS && <FlowRunDetails />}
{leftSidebar === LeftSideBarType.VERSIONS && <FlowVersionsList />}
{leftSidebar === LeftSideBarType.AI_COPILOT && <CopilotSidebar />}
</div>
</ResizablePanel>
<ResizableHandle
disabled={leftSidebar === LeftSideBarType.NONE}
withHandle={leftSidebar !== LeftSideBarType.NONE}
onDragging={setIsDraggingHandle}
className="z-20"
/>

<ResizablePanel defaultSize={100} order={2} id="flow-canvas">
<div ref={middlePanelRef} className="relative h-full w-full">
Expand Down
1 change: 0 additions & 1 deletion packages/react-ui/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const formatUtils = {
remainingSeconds > 0 ? ` ${remainingSeconds} seconds` : ''
}`;
}

return short ? `${seconds} s` : `${seconds} seconds`;
},
};
Expand Down

0 comments on commit f5f546f

Please sign in to comment.