Skip to content

Commit

Permalink
Move SimpleDocumentViewer to directory
Browse files Browse the repository at this point in the history
Extract existing components to files.
No functional changes have been introduced.

Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Jun 10, 2024
1 parent f88a813 commit fcc8978
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 263 deletions.
262 changes: 0 additions & 262 deletions client/src/app/components/SimpleDocumentViewer.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from "react";
import { Language } from "@patternfly/react-code-editor";
import { ToggleGroup, ToggleGroupItem } from "@patternfly/react-core";
import { css } from "@patternfly/react-styles";
import editorStyles from "@patternfly/react-styles/css/components/CodeEditor/code-editor";
import CodeIcon from "@patternfly/react-icons/dist/esm/icons/code-icon";
import "./SimpleDocumentViewer.css";

export const LanguageToggle: React.FC<{
currentLanguage: Language.yaml | Language.json;
code?: string;
setCurrentLanguage: (lang: Language.yaml | Language.json) => void;
}> = ({ currentLanguage, code, setCurrentLanguage }) => (
<div
className={css(
editorStyles.codeEditorTab,
"language-toggle-group-container"
)}
key="code-language-toggle"
>
<ToggleGroup
aria-label="code content type selection"
className="language-toggle-group"
>
<ToggleGroupItem
text={
<>
<span className={editorStyles.codeEditorTabIcon}>
<CodeIcon />
</span>
<span className={editorStyles.codeEditorTabText}>JSON</span>
</>
}
buttonId="code-language-select-json"
isSelected={currentLanguage === "json"}
isDisabled={!code && currentLanguage !== "json"}
onChange={() => setCurrentLanguage(Language.json)}
/>
<ToggleGroupItem
text={
<>
<span className={editorStyles.codeEditorTabIcon}>
<CodeIcon />
</span>
<span className={editorStyles.codeEditorTabText}>YAML</span>
</>
}
buttonId="code-language-select-yaml"
isSelected={currentLanguage === "yaml"}
isDisabled={!code && currentLanguage !== "yaml"}
onChange={() => setCurrentLanguage(Language.yaml)}
/>
</ToggleGroup>
</div>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from "react";
import { CodeEditorControl } from "@patternfly/react-code-editor";
import UndoIcon from "@patternfly/react-icons/dist/esm/icons/undo-icon";
import "./SimpleDocumentViewer.css";

export const RefreshControl: React.FC<{
refetch: () => void;
isVisible: boolean;
}> = ({ refetch, isVisible }) => (
<CodeEditorControl
icon={<UndoIcon />}
aria-label="refresh-task"
tooltipProps={{ content: "Refresh" }}
onClick={refetch}
isVisible={isVisible}
/>
);
Loading

0 comments on commit fcc8978

Please sign in to comment.