Skip to content

Commit

Permalink
Merge pull request #18975 from GordonSmith/HPCC-32418-SOURCEEDITOR_OP…
Browse files Browse the repository at this point in the history
…TIONALTOOLBAR

HPCC-32418 Make toolbar optional for all source editor components

Reviewed-By: Jeremy Clements <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Aug 21, 2024
2 parents 6390524 + 2311d12 commit cf1dccd
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions esp/src/src-react/components/SourceEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,38 +147,44 @@ export const SourceEditor: React.FunctionComponent<SourceEditorProps> = ({
interface TextSourceEditorProps {
text: string;
readonly?: boolean;
toolbar?: boolean;
}

export const TextSourceEditor: React.FunctionComponent<TextSourceEditorProps> = ({
text = "",
readonly = false
readonly,
toolbar
}) => {

return <SourceEditor text={text} readonly={readonly} mode="text"></SourceEditor>;
return <SourceEditor text={text} toolbar={toolbar} readonly={readonly} mode="text"></SourceEditor>;
};

interface XMLSourceEditorProps {
text: string;
readonly?: boolean;
toolbar?: boolean;
}

export const XMLSourceEditor: React.FunctionComponent<XMLSourceEditorProps> = ({
text = "",
readonly = false
readonly,
toolbar
}) => {

return <SourceEditor text={text} readonly={readonly} mode="xml"></SourceEditor>;
return <SourceEditor text={text} toolbar={toolbar} readonly={readonly} mode="xml"></SourceEditor>;
};

interface JSONSourceEditorProps {
json?: object;
readonly?: boolean;
toolbar?: boolean;
onChange?: (obj: object) => void;
}

export const JSONSourceEditor: React.FunctionComponent<JSONSourceEditorProps> = ({
json,
readonly = false,
readonly,
toolbar,
onChange = (obj: object) => { }
}) => {

Expand All @@ -197,7 +203,7 @@ export const JSONSourceEditor: React.FunctionComponent<JSONSourceEditorProps> =
}
}, [onChange]);

return <SourceEditor text={text} readonly={readonly} mode="json" onTextChange={textChanged}></SourceEditor>;
return <SourceEditor text={text} toolbar={toolbar} readonly={readonly} mode="json" onTextChange={textChanged}></SourceEditor>;
};

export interface WUXMLSourceEditorProps {
Expand All @@ -215,10 +221,12 @@ export const WUXMLSourceEditor: React.FunctionComponent<WUXMLSourceEditorProps>

export interface WUResourceEditorProps {
src: string;
toolbar?: boolean;
}

export const WUResourceEditor: React.FunctionComponent<WUResourceEditorProps> = ({
src
src,
toolbar
}) => {

const [text, setText] = React.useState("");
Expand All @@ -231,7 +239,7 @@ export const WUResourceEditor: React.FunctionComponent<WUResourceEditorProps> =
});
}, [src]);

return <SourceEditor text={text} readonly={true} mode="text"></SourceEditor>;
return <SourceEditor text={text} toolbar={toolbar} readonly={true} mode="text"></SourceEditor>;
};

interface ECLSourceEditorProps {
Expand Down Expand Up @@ -266,13 +274,15 @@ interface FetchEditor {
url: string;
wuid?: string;
readonly?: boolean;
toolbar?: boolean;
mode?: "ecl" | "xml" | "text";
}

export const FetchEditor: React.FunctionComponent<FetchEditor> = ({
url,
wuid,
readonly = true,
toolbar,
mode = "text"
}) => {

Expand All @@ -293,11 +303,12 @@ export const FetchEditor: React.FunctionComponent<FetchEditor> = ({
}
}, [url, wuid]);

return <SourceEditor text={text} readonly={readonly} mode={mode}></SourceEditor>;
return <SourceEditor text={text} toolbar={toolbar} readonly={readonly} mode={mode}></SourceEditor>;
};

interface SQLSourceEditorProps {
sql: string;
readonly?: boolean;
toolbar?: boolean;
onSqlChange?: (sql: string) => void;
onFetchHints?: (cm: any, option: any) => Promise<ICompletion>;
Expand All @@ -306,11 +317,12 @@ interface SQLSourceEditorProps {

export const SQLSourceEditor: React.FunctionComponent<SQLSourceEditorProps> = ({
sql,
readonly,
toolbar,
onSqlChange,
onFetchHints,
onSubmit
}) => {
return <SourceEditor text={sql} toolbar={toolbar} onTextChange={onSqlChange} onFetchHints={onFetchHints} onSubmit={onSubmit} mode={"sql"}></SourceEditor>;
return <SourceEditor text={sql} toolbar={toolbar} readonly={readonly} onTextChange={onSqlChange} onFetchHints={onFetchHints} onSubmit={onSubmit} mode={"sql"}></SourceEditor>;
};

0 comments on commit cf1dccd

Please sign in to comment.