changed to use code editor (#1161)
* changed to use code editor * Update src/components/json-file-upload/JsonFileUpload.tsx Co-authored-by: Jon Koops <jonkoops@gmail.com> * fixed tests Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
34e9d7a3ca
commit
809247a686
3 changed files with 23 additions and 8 deletions
|
@ -40,7 +40,7 @@ describe("Partial import test", () => {
|
|||
|
||||
it("Import button only enabled if JSON has something to import", () => {
|
||||
modal.open();
|
||||
cy.get("#partial-import-file").type("{}");
|
||||
cy.get(".pf-c-code-editor__code textarea").type("{}");
|
||||
modal.importButton().should("be.disabled");
|
||||
});
|
||||
|
||||
|
|
|
@ -11,10 +11,13 @@ export default class GroupModal {
|
|||
(myJSON) => {
|
||||
const text = JSON.stringify(myJSON);
|
||||
|
||||
cy.get("#partial-import-file").type(text, {
|
||||
parseSpecialCharSequences: false,
|
||||
cy.get(".pf-c-code-editor__code textarea")
|
||||
.type(text, {
|
||||
delay: 0,
|
||||
});
|
||||
parseSpecialCharSequences: false,
|
||||
})
|
||||
.type("{shift}{end}")
|
||||
.type("{del}");
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
@ -8,9 +8,10 @@ import {
|
|||
FileUploadProps,
|
||||
} from "@patternfly/react-core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CodeEditor, Language } from "@patternfly/react-code-editor";
|
||||
|
||||
type FileUpload = {
|
||||
value: string | File;
|
||||
value: string;
|
||||
filename: string;
|
||||
isLoading: boolean;
|
||||
modal: boolean;
|
||||
|
@ -60,7 +61,7 @@ export const JsonFileUpload = ({
|
|||
} else {
|
||||
setFileUpload({
|
||||
...fileUpload,
|
||||
value,
|
||||
value: value as string,
|
||||
filename,
|
||||
});
|
||||
|
||||
|
@ -147,7 +148,18 @@ export const JsonFileUpload = ({
|
|||
dropzoneProps={{
|
||||
accept: ".json",
|
||||
}}
|
||||
hideDefaultPreview
|
||||
>
|
||||
<CodeEditor
|
||||
isLineNumbersVisible
|
||||
code={fileUpload.value}
|
||||
language={Language.json}
|
||||
height="128px"
|
||||
onChange={(value, event) =>
|
||||
handleChange(value ?? "", fileUpload.filename, event)
|
||||
}
|
||||
/>
|
||||
</FileUpload>
|
||||
</FormGroup>
|
||||
)}
|
||||
</>
|
||||
|
|
Loading…
Reference in a new issue