8034c7725f
Reorganizes `twenty-ui`'s component organization to follow how the best
UI libraries (MUI, Mantine, Base UI, Polaris) structure their source,
now that the package has stabilized.
**Taxonomy** — dissolves the meaningless `components/` junk-drawer and
the 107-file `display/` mega-category. New domains/subpaths:
`data-display`, `typography`, `icon`, `surfaces`; `feedback` and
`layout` absorb the rest (banners/callout/info + placeholders →
feedback; modal/card → surfaces; motion + separators → layout).
**Per-component layout** — every component is now
`<domain>/<ComponentName>/<ComponentName>.tsx` with colocated
styles/stories/types, `internal/` for private helpers and `parts/` for
re-exported compound sub-parts. The redundant inner `/components/` is
gone. `icon` and `json-visualizer` are kept as cohesive subsystems.
**Also:** adds a tree-shakeable root barrel (`import { Button } from
'twenty-ui'`), the generator now owns `individual-entry.ts`, and a real
barrel-leak bug is fixed (private `internals/` parts were leaking into
the public API).
Consumer imports (~1.2k files) and the `twenty-sdk` UI aggregator were
updated by codemod. The change is **export-neutral** except 16
intentionally-removed private internals symbols (all verified
unconsumed). Gates green: typecheck, lint, build, size-limit, storybook.
<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21745?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
148 lines
3.7 KiB
TypeScript
148 lines
3.7 KiB
TypeScript
import { LightCopyIconButton } from '@/object-record/record-field/ui/components/LightCopyIconButton';
|
|
import { styled } from '@linaria/react';
|
|
import { t } from '@lingui/core/macro';
|
|
import {
|
|
IconLoader,
|
|
IconSquareRoundedCheck,
|
|
IconSquareRoundedX,
|
|
} from 'twenty-ui/icon';
|
|
import { CodeEditor, CoreEditorHeader } from 'twenty-ui/input';
|
|
import { AnimatedCircleLoading } from 'twenty-ui/layout';
|
|
import { themeCssVariables, ThemeContext } from 'twenty-ui/theme-constants';
|
|
import { useContext } from 'react';
|
|
const StyledContainer = styled.div`
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
`;
|
|
|
|
const StyledCodeEditorWrapper = styled.div`
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
`;
|
|
|
|
type OutputAccent = 'default' | 'success' | 'error';
|
|
|
|
const StyledInfoContainer = styled.div`
|
|
display: flex;
|
|
font-size: ${themeCssVariables.font.size.md};
|
|
`;
|
|
|
|
const StyledOutput = styled.div<{ accent?: OutputAccent }>`
|
|
align-items: center;
|
|
color: ${({ accent }) =>
|
|
accent === 'success'
|
|
? themeCssVariables.color.turquoise
|
|
: accent === 'error'
|
|
? themeCssVariables.color.red
|
|
: themeCssVariables.font.color.secondary};
|
|
display: flex;
|
|
gap: ${themeCssVariables.spacing[1]};
|
|
`;
|
|
|
|
const StyledStatusInfo = styled.div`
|
|
color: ${themeCssVariables.font.color.tertiary};
|
|
display: flex;
|
|
font-size: ${themeCssVariables.font.size.sm};
|
|
gap: ${themeCssVariables.spacing[2]};
|
|
`;
|
|
|
|
export type ExecutionStatus = {
|
|
isSuccess: boolean;
|
|
isError: boolean;
|
|
successMessage?: string;
|
|
errorMessage?: string;
|
|
additionalInfo?: string;
|
|
};
|
|
|
|
type WorkflowStepExecutionResultProps = {
|
|
result: string;
|
|
language: 'plaintext' | 'json';
|
|
height?: string | number;
|
|
status: ExecutionStatus;
|
|
isTesting?: boolean;
|
|
loadingMessage?: string;
|
|
idleMessage?: string;
|
|
};
|
|
|
|
export const WorkflowStepExecutionResult = ({
|
|
result,
|
|
language,
|
|
height = '100%',
|
|
status,
|
|
isTesting = false,
|
|
loadingMessage = t`Processing...`,
|
|
idleMessage = t`Output`,
|
|
}: WorkflowStepExecutionResultProps) => {
|
|
const { theme } = useContext(ThemeContext);
|
|
|
|
const SuccessLeftNode = (
|
|
<StyledOutput accent="success">
|
|
<IconSquareRoundedCheck size={theme.icon.size.md} />
|
|
<div>
|
|
<div>{status.successMessage}</div>
|
|
{status.additionalInfo && (
|
|
<StyledStatusInfo>{status.additionalInfo}</StyledStatusInfo>
|
|
)}
|
|
</div>
|
|
</StyledOutput>
|
|
);
|
|
|
|
const ErrorLeftNode = (
|
|
<StyledOutput accent="error">
|
|
<IconSquareRoundedX size={theme.icon.size.md} />
|
|
<div>
|
|
<div>{status.errorMessage}</div>
|
|
{status.additionalInfo && (
|
|
<StyledStatusInfo>{status.additionalInfo}</StyledStatusInfo>
|
|
)}
|
|
</div>
|
|
</StyledOutput>
|
|
);
|
|
|
|
const IdleLeftNode = idleMessage;
|
|
|
|
const PendingLeftNode = isTesting && (
|
|
<StyledOutput>
|
|
<AnimatedCircleLoading>
|
|
<IconLoader size={theme.icon.size.md} />
|
|
</AnimatedCircleLoading>
|
|
<StyledInfoContainer>{loadingMessage}</StyledInfoContainer>
|
|
</StyledOutput>
|
|
);
|
|
|
|
const computeLeftNode = () => {
|
|
if (isTesting) {
|
|
return PendingLeftNode;
|
|
}
|
|
if (status.isError) {
|
|
return ErrorLeftNode;
|
|
}
|
|
if (status.isSuccess) {
|
|
return SuccessLeftNode;
|
|
}
|
|
return IdleLeftNode;
|
|
};
|
|
|
|
return (
|
|
<StyledContainer>
|
|
<CoreEditorHeader
|
|
leftNodes={[computeLeftNode()]}
|
|
rightNodes={[<LightCopyIconButton copyText={result} />]}
|
|
/>
|
|
<StyledCodeEditorWrapper>
|
|
<CodeEditor
|
|
resizable={true}
|
|
value={result}
|
|
language={language}
|
|
height={height}
|
|
options={{ readOnly: true, domReadOnly: true }}
|
|
isLoading={isTesting}
|
|
variant="with-header"
|
|
/>
|
|
</StyledCodeEditorWrapper>
|
|
</StyledContainer>
|
|
);
|
|
};
|