Skip to content

Commit

Permalink
admin-web: Add linenumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta committed Aug 25, 2022
1 parent 5e00e5e commit 4aa5aa4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 5 additions & 2 deletions admin/src/assets/js/prism.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions admin/src/components/molecules/DAGDefinition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@ import Prism from '../../assets/js/prism';

type Props = {
value: string;
lineNumbers?: boolean;
startLine?: number;
};

function DAGDefinition({ value }: Props) {
const language = 'yaml';

function DAGDefinition({ value, lineNumbers, startLine }: Props) {
React.useEffect(() => {
Prism.highlightAll();
}, [value]);
const className = React.useMemo(() => {
if (lineNumbers) {
return `language-${language} line-numbers`;
}
return `language-${language}`;
}, [lineNumbers]);
return (
<pre
style={{
fontSize: '0.9rem',
}}
data-start={startLine || 1}
>
<code className="language-yaml">{value}</code>
<code className={className}>{value}</code>
</pre>
);
}
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/organizations/DAGSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function DAGSpec({ data }: Props) {
></DAGEditor>
</Box>
) : (
<DAGDefinition value={data.Definition} />
<DAGDefinition value={data.Definition} lineNumbers />
)}
</BorderedBox>
</Box>
Expand Down
Loading

0 comments on commit 4aa5aa4

Please sign in to comment.