Skip to content

Commit

Permalink
#1275 Properties forms
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jun 2, 2024
1 parent 1d471d0 commit 320d705
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Form, Switch} from "antd";
import {prefixedFormName} from "@components/form/formUtils";

export default function PropertyForm({prefix}) {

return (
<>
<Form.Item
label="Auto create"
extra="If checked, creates validations from predefined ones"
name={prefixedFormName(prefix, 'autoCreate')}
>
<Switch/>
</Form.Item>
<Form.Item
label="Auto create if not predefined"
extra="If checked, creates validations even if not predefined"
name={prefixedFormName(prefix, 'autoCreateIfNotPredefined')}
>
<Switch/>
</Form.Item>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Form, Switch} from "antd";
import {prefixedFormName} from "@components/form/formUtils";

export default function PropertyForm({prefix}) {

return (
<>
<Form.Item
label="Use label"
extra={`Configuration at project label to specify that a
build link decoration should use the release/label
of a build when available. By default, it displays
the release name if available, and then the build name as a default.
`}
name={prefixedFormName(prefix, 'useLabel')}
>
<Switch/>
</Form.Item>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Form, Input} from "antd";
import {prefixedFormName} from "@components/form/formUtils";
import SelectMessageType from "@components/common/SelectMessageType";

export default function PropertyForm({prefix}) {

return (
<>
<Form.Item
label="Type"
extra="Type of message"
name={prefixedFormName(prefix, 'type')}
>
<SelectMessageType/>
</Form.Item>
<Form.Item
label="Text"
extra="Content of the message"
name={prefixedFormName(prefix, 'text')}
>
<Input/>
</Form.Item>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {Button, Form, Input, Space, Typography} from "antd";
import {prefixedFormName} from "@components/form/formUtils";
import {FaPlus, FaTrash} from "react-icons/fa";

export default function PropertyForm({prefix}) {

return (
<>
<Form.List name={prefixedFormName(prefix, 'items')}>
{(fields, {add, remove}) => (
<>
<div
style={{
display: 'flex',
rowGap: 16,
flexDirection: 'column',
}}
>
{fields.map(({key, name, ...restField}) => (
<>
<Space
key={key}
>
<Form.Item
{...restField}
name={[name, 'name']}
label={<FaTrash onClick={() => remove(name)}/>}
rules={[{required: true, message: 'Meta info name is required.',},]}
>
<Input placeholder="Name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
>
<Input placeholder="Value"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'link']}
>
<Input placeholder="Link"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'category']}
>
<Input placeholder="Category"/>
</Form.Item>
</Space>
</>
))}
<Button type="dashed" onClick={() => add()} block>
<Space>
<FaPlus/>
<Typography.Text>Add meta info</Typography.Text>
</Space>
</Button>
</div>
</>
)}
</Form.List>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {Button, Form, Input, Space, Typography} from "antd";
import {prefixedFormName} from "@components/form/formUtils";
import {FaPlus, FaTrash} from "react-icons/fa";

export default function PropertyForm({prefix}) {

return (
<>
<Form.List name={prefixedFormName(prefix, 'patterns')}>
{(fields, {add, remove}) => (
<>
<div
style={{
display: 'flex',
rowGap: 16,
flexDirection: 'column',
}}
>
{fields.map(({key, name, ...restField}) => (
<>
<Space
key={key}
>
<Form.Item
{...restField}
name={[name, 'name']}
label={<FaTrash onClick={() => remove(name)}/>}
rules={[{required: true, message: 'Pattern name is required.',},]}
>
<Input placeholder="Name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
label="Regex"
rules={[{required: true, message: 'Pattern value is required.',},]}
>
<Input placeholder="Value"/>
</Form.Item>
</Space>
</>
))}
<Button type="dashed" onClick={() => add()} block>
<Space>
<FaPlus/>
<Typography.Text>Add pattern</Typography.Text>
</Space>
</Button>
</div>
</>
)}
</Form.List>
</>
)
}

0 comments on commit 320d705

Please sign in to comment.