mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
refactor(ui): migrate env var field to react [EE-4853] (#8451)
This commit is contained in:
parent
6b5940e00e
commit
2d05103fed
40 changed files with 721 additions and 442 deletions
|
@ -0,0 +1,50 @@
|
|||
import { List } from 'lucide-react';
|
||||
|
||||
import { CodeEditor } from '@@/CodeEditor';
|
||||
import { TextTip } from '@@/Tip/TextTip';
|
||||
import { Button } from '@@/buttons';
|
||||
|
||||
import { convertToArrayOfStrings, parseDotEnvFile } from './utils';
|
||||
import { type Value } from './types';
|
||||
|
||||
export function AdvancedMode({
|
||||
value,
|
||||
onChange,
|
||||
onSimpleModeClick,
|
||||
}: {
|
||||
value: Value;
|
||||
onChange: (value: Value) => void;
|
||||
onSimpleModeClick: () => void;
|
||||
}) {
|
||||
const editorValue = convertToArrayOfStrings(value).join('\n');
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="small"
|
||||
color="link"
|
||||
icon={List}
|
||||
className="!ml-0 p-0 hover:no-underline"
|
||||
onClick={onSimpleModeClick}
|
||||
>
|
||||
Simple mode
|
||||
</Button>
|
||||
|
||||
<TextTip color="blue" inline={false}>
|
||||
Switch to simple mode to define variables line by line, or load from
|
||||
.env file
|
||||
</TextTip>
|
||||
|
||||
<CodeEditor
|
||||
id="environment-variables-editor"
|
||||
value={editorValue}
|
||||
onChange={handleEditorChange}
|
||||
placeholder="e.g. key=value"
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
function handleEditorChange(value: string) {
|
||||
onChange(parseDotEnvFile(value));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue