Skip to content

Commit

Permalink
Rename FSHOutput -> FSHEditor and JSONOutput -> JSONEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
jafeltra committed Aug 9, 2024
1 parent e5972a2 commit 49f3ffd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
28 changes: 14 additions & 14 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { makeStyles } from '@material-ui/core/styles';
import { Grid, ThemeProvider } from '@material-ui/core';
import { expandLink } from './utils/BitlyWorker';
import TopBar from './components/TopBar';
import JSONOutput from './components/JSONOutput';
import FSHOutput from './components/FSHOutput';
import JSONEditor from './components/JSONEditor';
import FSHEditor from './components/FSHEditor';
import Console from './components/Console';
import FSHControls from './components/FSHControls';
import theme from './theme';
Expand Down Expand Up @@ -155,8 +155,8 @@ export default function App(props) {
const [inputFSHText, setInputFSHText] = useState('');
const [inputFHIRText, setInputFHIRText] = useState(['']);
const [initialText, setInitialText] = useState('');
const [isWaitingForFHIROutput, setIsWaitingForFHIROutput] = useState(false);
const [isWaitingForFSHOutput, setIsWaitingForFSHOutput] = useState(false);
const [isWaitingForFHIR, setIsWaitingForFHIR] = useState(false);
const [isWaitingForFSH, setIsWaitingForFSH] = useState(false);
const [expandConsole, setExpandConsole] = useState(false);
const [exampleConfig, setExampleConfig] = useState([]);
const [exampleFilePaths, setExampleFilePaths] = useState({});
Expand Down Expand Up @@ -215,13 +215,13 @@ export default function App(props) {

function handleSUSHIControls(showNewText, sushiOutput, isWaiting) {
setShowNewFHIRText(showNewText);
setInputFHIRText(sushiOutput); // JSONOutput component handles resetting initial text, so don't reset here
setIsWaitingForFHIROutput(isWaiting);
setInputFHIRText(sushiOutput); // JSONEditor component handles resetting initial text, so don't reset here
setIsWaitingForFHIR(isWaiting);
}

function handleGoFSHControls(fshOutput, isWaiting) {
setIsWaitingForFSHOutput(isWaiting);
setInitialText(fshOutput === '' ? null : fshOutput); // Reset initial text to null if empty in order to display placeholder text
function handleGoFSHControls(fshText, isWaiting) {
setIsWaitingForFSH(isWaiting);
setInitialText(fshText === '' ? null : fshText); // Reset initial text to null if empty in order to display placeholder text
}

function updateInputFSHTextValue(text) {
Expand Down Expand Up @@ -360,7 +360,7 @@ export default function App(props) {
resetLogMessages={resetLogMessages}
exampleConfig={exampleConfig}
exampleMetadata={exampleFilePaths}
isWaiting={isWaitingForFSHOutput || isWaitingForFHIROutput}
isWaiting={isWaitingForFSH || isWaitingForFHIR}
saveAll={saveAll}
setIsLineWrapped={setLineWrap}
isLineWrapped={isLineWrapped}
Expand All @@ -381,11 +381,11 @@ export default function App(props) {
className={clsx(classes.fullHeightGrid, classes.editorPane)}
style={{ maxWidth: `calc(${leftWidth}% - 2px)`, flexBasis: `calc(${leftWidth}% - 2px)` }}
>
<FSHOutput
<FSHEditor
text={inputFSHText}
initialText={initialText}
updateTextValue={updateInputFSHTextValue}
isWaiting={isWaitingForFSHOutput}
isWaiting={isWaitingForFSH}
setInitialText={setInitialText}
config={configToShare}
isLineWrapped={isLineWrapped}
Expand All @@ -407,11 +407,11 @@ export default function App(props) {
flexBasis: `calc(${100 - leftWidth}% - 2px)`
}}
>
<JSONOutput
<JSONEditor
text={inputFHIRText}
showNewText={showNewFHIRText}
setShowNewText={setShowNewFHIRText}
isWaiting={isWaitingForFHIROutput}
isWaiting={isWaitingForFHIR}
updateTextValue={updateInputFHIRTextValue}
isLineWrapped={isLineWrapped}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import FileSaver from 'file-saver';
import CodeEditor from './CodeEditor';
import DeleteConfirmationModal from './DeleteConfirmationModal';

export default function FSHOutput(props) {
export default function FSHEditor(props) {
const [openDeleteModal, setOpenDeleteModal] = useState(false);

const handleOpenDeleteModal = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const getIterablePackage = (defsPackage) => {
}));
};

export default function JSONOutput(props) {
export default function JSONEditor(props) {
const classes = useStyles();
const [initialText, setInitialText] = useState('');
const [fhirDefinitions, setFhirDefinitions] = useState([{ resourceType: null, id: 'Untitled', def: null }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { unmountComponentAtNode } from 'react-dom';
import FileSaver from 'file-saver';
import FSHOutput from '../../src/components/FSHOutput';
import FSHEditor from '../../src/components/FSHEditor';

let container = null;
beforeEach(() => {
Expand All @@ -21,7 +21,7 @@ it('should render a delete button in editor header that opens a confirmation and
const fshText = 'Profile: MyImportantProfile';

const { getByRole, queryByText } = render(
<FSHOutput
<FSHEditor
text={fshText}
initialText={fshText}
updateTextValue={vi.fn()}
Expand Down Expand Up @@ -56,7 +56,7 @@ it('should render a save button in the editor header that saves the FSH', () =>
const fshText = 'Profile: MyImportantProfile';

const { getByRole } = render(
<FSHOutput
<FSHEditor
text={fshText}
initialText={fshText}
updateTextValue={vi.fn()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { unmountComponentAtNode } from 'react-dom';
import FileSaver from 'file-saver';
import JSONOutput from '../../src/components/JSONOutput';
import JSONEditor from '../../src/components/JSONEditor';

let container = null;
beforeEach(() => {
Expand All @@ -18,15 +18,15 @@ afterEach(() => {

it('Renders with the placeholder text if showNewText is false and no text', () => {
// Initial case, nothing from SUSHI is displayed
const { getByText } = render(<JSONOutput showNewText={false} text={''} />, container);
const { getByText } = render(<JSONEditor showNewText={false} text={''} />, container);

const placeholderText = getByText(/Paste or edit single FHIR JSON artifact here.../i);

expect(placeholderText).toBeInTheDocument();
});

it('Renders with the proper text and updates with proper text when loading', () => {
const { getByText } = render(<JSONOutput showNewText={false} text={''} isWaiting={true} />, container);
const { getByText } = render(<JSONEditor showNewText={false} text={''} isWaiting={true} />, container);

const loadingPlaceholderText = getByText('Loading...');

Expand All @@ -36,7 +36,7 @@ it('Renders with the proper text and updates with proper text when loading', ()
// TODO: CodeEditor doesn't get the package text properly - not sure why
it.skip('Renders with the first profile when text is an object (SUSHI Package)', async () => {
const { getByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
text={JSON.stringify(
{
Expand Down Expand Up @@ -100,7 +100,7 @@ it('renders a delete button in editor header that opens a confirmation and then
];

const { getByRole, getByText, queryByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -162,7 +162,7 @@ it('renders a save button in editor header that saves the definition', () => {
codeSystems: []
};
const { getByRole, getByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -203,7 +203,7 @@ it('Renders an Add Definition button that adds a blank definition', () => {
codeSystems: []
};
const { getByText, queryByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -299,7 +299,7 @@ describe('file tree display', () => {

it('renders a list of JSON definitions in a file tree', () => {
const { getAllByTestId } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('file tree display', () => {

it('resets currentDef and initialText of editor when a new definition is clicked', () => {
const { getByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -384,7 +384,7 @@ describe('file tree display', () => {
codeSystems: []
};
const { getByText } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down Expand Up @@ -418,7 +418,7 @@ describe('file tree display', () => {
codeSystems: []
};
const { getAllByTestId } = render(
<JSONOutput
<JSONEditor
showNewText={true}
setShowNewText={() => {}}
isWaiting={false}
Expand Down

0 comments on commit 49f3ffd

Please sign in to comment.