2023-01-16 09:34:12 +00:00
|
|
|
import React from 'react';
|
2023-08-17 09:20:31 +00:00
|
|
|
import Input from '../Input';
|
2023-01-16 09:34:12 +00:00
|
|
|
|
2023-08-17 09:20:31 +00:00
|
|
|
export default ({ options, addNewKeyValuePair, removeKeyValuePair, keyValuePairValueChanged, workspaceConstants }) => {
|
2023-01-16 09:34:12 +00:00
|
|
|
return (
|
|
|
|
|
<div className="table-responsive table-no-divider">
|
|
|
|
|
<table className="table table-vcenter">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Key</th>
|
|
|
|
|
<th>Value</th>
|
|
|
|
|
<th></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{options.map((option, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<tr key={index}>
|
|
|
|
|
<td>
|
2023-08-17 09:20:31 +00:00
|
|
|
<Input
|
2023-01-16 09:34:12 +00:00
|
|
|
type="text"
|
2023-08-17 09:20:31 +00:00
|
|
|
className="form-control no-border"
|
|
|
|
|
onChange={(e) => keyValuePairValueChanged(e.target.value, 0, index)}
|
2023-01-16 09:34:12 +00:00
|
|
|
value={option[0]}
|
2023-08-17 09:20:31 +00:00
|
|
|
workspaceConstants={workspaceConstants}
|
2023-01-16 09:34:12 +00:00
|
|
|
placeholder="key"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
/>
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
2023-08-17 09:20:31 +00:00
|
|
|
<Input
|
2023-01-16 09:34:12 +00:00
|
|
|
type="text"
|
|
|
|
|
value={option[1]}
|
|
|
|
|
placeholder="value"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
className="form-control no-border"
|
|
|
|
|
onChange={(e) => keyValuePairValueChanged(e.target.value, 1, index)}
|
2023-08-17 09:20:31 +00:00
|
|
|
workspaceConstants={workspaceConstants}
|
2023-01-16 09:34:12 +00:00
|
|
|
/>
|
|
|
|
|
</td>
|
|
|
|
|
{index > 0 && (
|
|
|
|
|
<td>
|
|
|
|
|
<span
|
|
|
|
|
role="button"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
removeKeyValuePair(index);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
x
|
|
|
|
|
</span>
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
{index === 0 && (
|
|
|
|
|
<td>
|
2023-12-22 11:46:10 +00:00
|
|
|
<button className="btn btn-sm btn-primary" onClick={() => addNewKeyValuePair(options)}>
|
2023-01-16 09:34:12 +00:00
|
|
|
Add
|
|
|
|
|
</button>
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|