Skip to content

Commit

Permalink
CodeEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
githubsaturn committed Oct 16, 2024
1 parent d82a0ad commit 0c6380d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 45 deletions.
24 changes: 6 additions & 18 deletions src/containers/apps/appDetails/AppConfigs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Component, Fragment } from 'react'
import { IHashMapGeneric } from '../../../models/IHashMapGeneric'
import { localize } from '../../../utils/Language'
import Utils from '../../../utils/Utils'
import CodeEdit from '../../global/CodeEdit'
import NewTabLink from '../../global/NewTabLink'
import { IAppEnvVar } from '../AppDefinition'
import { AppDetailsTabProps } from './AppDetails'
Expand Down Expand Up @@ -89,8 +90,7 @@ export default class AppConfigs extends Component<
<div>
<Row style={{ paddingBottom: 12 }}>
<Col span={24}>
<Input.TextArea
className="code-input"
<CodeEdit
placeholder={'key1=value1\nkey2=value2'}
rows={7}
value={
Expand Down Expand Up @@ -145,8 +145,7 @@ export default class AppConfigs extends Component<
/>
</Col>
<Col style={{ paddingLeft: 12 }} span={16}>
<Input.TextArea
className="code-input"
<CodeEdit
placeholder="value"
rows={1}
value={value.value}
Expand Down Expand Up @@ -633,12 +632,7 @@ export default class AppConfigs extends Component<
</NewTabLink>
</h4>

<Input.TextArea
spellCheck={false}
autoCorrect="off"
autoComplete="off"
autoCapitalize="off"
className="code-input"
<CodeEdit
placeholder="var preDeployFunction = function (capRoverAppObj, dockerUpdateObject) ..."
rows={4}
value={
Expand Down Expand Up @@ -669,12 +663,7 @@ export default class AppConfigs extends Component<
</NewTabLink>
</h4>

<Input.TextArea
spellCheck={false}
autoCorrect="off"
autoComplete="off"
autoCapitalize="off"
className="code-input"
<CodeEdit
placeholder={`## JSON / YAML
{
"TaskTemplate": {
Expand Down Expand Up @@ -746,8 +735,7 @@ export default class AppConfigs extends Component<

if (this.state.tagsEditMode) {
return (
<Input.TextArea
className="code-input"
<CodeEdit
placeholder={'tag1,comma,separated,cannot-contain-space'}
rows={1}
defaultValue={(app.tags || [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button, Input, Row } from 'antd'
import { localize } from '../../../../utils/Language'
import Toaster from '../../../../utils/Toaster'
import ApiComponent from '../../../global/ApiComponent'
import CodeEdit from '../../../global/CodeEdit'

export default abstract class UploaderPlainTextBase extends ApiComponent<
{
Expand Down Expand Up @@ -72,8 +73,7 @@ export default abstract class UploaderPlainTextBase extends ApiComponent<
}

return (
<Input.TextArea
className="code-input"
<CodeEdit
placeholder={self.getPlaceHolderValue()}
rows={7}
value={self.state.userEnteredValue}
Expand Down
8 changes: 7 additions & 1 deletion src/containers/global/CodeEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ import React from 'react'
interface CodeEditProps {
rows?: number | undefined
placeholder?: string | undefined
value: string | undefined
defaultValue?: string | undefined
value?: string | undefined
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void
}

const CodeEdit: React.FC<CodeEditProps> = ({
value,
placeholder,
rows,
defaultValue,
onChange,
}) => {
return (
<Input.TextArea
defaultValue={defaultValue}
spellCheck={false}
autoCorrect="off"
autoComplete="off"
autoCapitalize="off"
placeholder={placeholder}
style={{
overflowX: 'auto',
Expand Down
7 changes: 3 additions & 4 deletions src/containers/global/InputJsonifier.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Input } from 'antd'
import React, { Component, Fragment } from 'react'
import { Component, Fragment } from 'react'
import yaml from 'yaml'
import CodeEdit from './CodeEdit'

function ensureStringifiedJson(raw: string) {
raw = (raw || '').trim()
Expand Down Expand Up @@ -38,8 +38,7 @@ export default class InputJsonifier extends Component<
return (
<Fragment>
{' '}
<Input.TextArea
className="code-input"
<CodeEdit
placeholder={self.props.placeholder}
rows={10}
defaultValue={self.props.defaultValue}
Expand Down
28 changes: 15 additions & 13 deletions src/containers/nodes/AddNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button, Card, Col, Collapse, Input, Radio, Row, Tooltip } from 'antd'
import { Component } from 'react'
import { localize } from '../../utils/Language'
import Utils from '../../utils/Utils'
import CodeEdit from '../global/CodeEdit'

export interface INodeToAdd {
remoteNodeIpAddress: string
Expand Down Expand Up @@ -117,19 +118,20 @@ export default class AddNode extends Component<
/>
</Tooltip>
</div>
<Input.TextArea
style={{ marginBottom: 20 }}
className="code-input"
rows={6}
placeholder="-----BEGIN RSA PRIVATE KEY-----&#10;MIICWwIBAAKBgQDArfs81aizq8ckg16e+ewFgJg7J..."
value={nodeToAdd.privateKey}
onChange={(e) =>
self.changeModel(
'privateKey',
e.target.value
)
}
/>

<div style={{ marginBottom: 20 }}>
<CodeEdit
rows={6}
placeholder="-----BEGIN RSA PRIVATE KEY-----&#10;MIICWwIBAAKBgQDArfs81aizq8ckg16e+ewFgJg7J..."
value={nodeToAdd.privateKey}
onChange={(e) =>
self.changeModel(
'privateKey',
e.target.value
)
}
/>
</div>
</Col>
</Row>
<Row justify="end">
Expand Down
12 changes: 5 additions & 7 deletions src/containers/settings/NginxConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { SyncOutlined } from '@ant-design/icons'
import { Button, Input, Row } from 'antd'
import { Button, Row } from 'antd'
import { localize } from '../../utils/Language'
import Toaster from '../../utils/Toaster'
import Utils from '../../utils/Utils'
import ApiComponent from '../global/ApiComponent'
import CenteredSpinner from '../global/CenteredSpinner'
import CodeEdit from '../global/CodeEdit'
import ErrorRetry from '../global/ErrorRetry'

export default class NginxConfig extends ApiComponent<
Expand Down Expand Up @@ -107,9 +108,7 @@ export default class NginxConfig extends ApiComponent<
: 'hide-on-demand'
}
>
<Input.TextArea
className="code-input"
placeholder=""
<CodeEdit
rows={17}
value={nginxConfig.baseConfig.customValue}
onChange={(e) => {
Expand All @@ -118,6 +117,7 @@ export default class NginxConfig extends ApiComponent<
self.setState({ nginxConfig: newApiData })
}}
/>

<div style={{ height: 40 }} />
</div>
<p>
Expand All @@ -138,9 +138,7 @@ export default class NginxConfig extends ApiComponent<
: 'hide-on-demand'
}
>
<Input.TextArea
className="code-input"
placeholder=""
<CodeEdit
rows={17}
value={nginxConfig.captainConfig.customValue}
onChange={(e) => {
Expand Down

0 comments on commit 0c6380d

Please sign in to comment.