Skip to content

Commit

Permalink
Merge pull request #162 from hjmodi/hosted-edit
Browse files Browse the repository at this point in the history
changes on events to hosted edit UI
  • Loading branch information
ligangty authored Jan 30, 2024
2 parents 5f32eb9 + b461751 commit 8b55d61
Showing 1 changed file with 49 additions and 28 deletions.
77 changes: 49 additions & 28 deletions src/main/webui/src/app/components/content/hosted/HostedEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,54 @@ import {Filters} from '#utils/Filters.js';
const {storeRes, disableRes} = IndyRest;


const EditCapabilities = ({allowReleases, allowSnapshots, register}) => {
const [canSnapshot, setSnapshot] = useState(allowSnapshots);
const [canRelease, setRelease] = useState(allowReleases);

if (canRelease === undefined && allowReleases !== undefined) {
setRelease(allowReleases);
}

if (canSnapshot === undefined && allowSnapshots !== undefined) {
setSnapshot(allowSnapshots);
}

return <div className="fieldset">
<div className="detail-field">
<span>{Filters.checkmark(canRelease || canSnapshot)}</span>
<label>Allow Uploads</label>
</div>
<div className="detail-field">
<span>
<input type="checkbox" onClick={e => setRelease(e.target.checked)} defaultChecked={canRelease} {...register("allow_releases")} />
</span>{' '}
<label>Allow Releases</label>
</div>
<div className="detail-field">
<span>
<input type="checkbox" onClick={e => setSnapshot(e.target.checked)} defaultChecked={canSnapshot} {...register("allow_snapshots")} />
</span>{' '}
<label>Allow Snapshots</label>
</div>
{
canSnapshot &&
<div className="sub-fields">
<div className="detail-field">
<label>Snapshot Timeout:</label>
<span><input type="text" defaultChecked={canSnapshot} {...register("snapshotTimeoutSeconds")} /></span>
<DurationHint />
</div>
</div>
}
</div>;
};

EditCapabilities.propTypes = {
allowReleases: PropTypes.bool,
allowSnapshots: PropTypes.bool,
register: PropTypes.function,
};

export default function HostedEdit() {
const [state, setState] = useState({
store: {},
Expand Down Expand Up @@ -163,34 +211,7 @@ export default function HostedEdit() {
</div>

<div className="fieldset-caption">Capabilities</div>
<div className="fieldset">
<div className="detail-field">
<span>{Filters.checkmark(store.allow_releases || store.allow_snapshots)}</span>
<label>Allow Uploads</label>
</div>
<div className="detail-field">
<span>
<input type="checkbox" defaultChecked={store.allow_releases} {...register("allow_releases")}/>
</span>{' '}
<label>Allow Releases</label>
</div>
<div className="detail-field">
<span>
<input type="checkbox" defaultChecked={store.allow_snapshots} {...register("allow_snapshots")}/>
</span>{' '}
<label>Allow Snapshots</label>
</div>
{
store.allow_snapshots &&
<div className="sub-fields">
<div className="detail-field">
<label>Snapshot Timeout:</label>
<span><input type="text"defaultChecked={store.allow_snapshots} {...register("snapshotTimeoutSeconds")}/></span>
<DurationHint />
</div>
</div>
}
</div>
<EditCapabilities allowSnapshots={store.allow_snapshots} allowReleases={store.allow_releases} register={register} />

</div>
{
Expand Down

0 comments on commit 8b55d61

Please sign in to comment.