intial commit

This commit is contained in:
2024-02-25 01:52:08 +01:00
commit d997295848
20 changed files with 6057 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
import { useState } from 'preact/hooks'
export const NewDeployForm = () => {
const [refType, setRefType] = useState('default')
const [deployType, setDeployType] = useState('initial')
return (
<form action="/deploys/new" method="post">
<label for="deploy-name">Name</label>
<input id="deploy-name" name="deploy-name" type="text" placeholder="Project name..." />
<label for="deploy-url">Url</label>
<input id="deploy-url" name="deploy-url" type="text" placeholder="Valid git clone url..." />
<label for="deploy-ref-type">Ref</label>
<div class="compound">
<select id="deploy-ref-type" name="deploy-ref-type" value={refType} onChange={e => setRefType(e.target.value)}>
<option value="default">Default</option>
<option value="branch">Branch</option>
<option value="tag">Tag</option>
<option value="commit">Commit</option>
</select>
<input class="fill" id="deploy-ref-value" name="deploy-ref-value" disabled={refType === 'default'} type="text" placeholder="Ref value..." />
</div>
<label for="deploy-type">Type</label>
<select id="deploy-type" name="deploy-type" value={deployType} onChange={e => setDeployType(e.target.value)}>
<option value="initial" disabled>
Select a deploy type...
</option>
<option value="shell">Shell</option>
<option value="dockerfile">Dockerfile</option>
<option value="docker-compose">Docker Compose</option>
</select>
<DeployOptions type={deployType} />
<div class="row right">
<button type="submit">Create</button>
</div>
</form>
)
}
export const DeployOptions = ({ type }) => {
switch (type) {
case 'shell':
return <ShellDeploy />
case 'dockerfile':
return <DockerDeploy />
case 'docker-compose':
return <DockerComposeDeploy />
default:
return null
}
}
const DockerDeploy = () => {
return (
<>
<label for="deploy-options-path">Path</label>
<input id="deploy-options-path" name="deploy-options-path" type="text" placeholder="Default is ./Dockerfile..." />
<label for="deploy-options-image">Image</label>
<input id="deploy-options-image" name="deploy-options-image" type="text" placeholder="organization/image:latest" />
<label for="deploy-options-ports">Ports</label>
<textarea id="deploy-options-ports" name="deploy-options-ports" rows={2} placeholder="80:8080" />
<label for="deploy-options-env">Environment</label>
<textarea id="deploy-options-env" name="deploy-options-env" rows={2} placeholder="FOO=bar" />
<label for="deploy-options-volumes">Volumes</label>
<textarea id="deploy-options-volumes" name="deploy-options-volumes" rows={2} placeholder="/var/www/example:/data" />
</>
)
}
const ShellDeploy = () => {
return (
<>
<label for="deploy-options-path">Path</label>
<input id="deploy-options-path" name="deploy-options-path" type="text" placeholder="./deploy.sh" />
<label for="deploy-options-env">Environment</label>
<textarea id="deploy-options-env" name="deploy-options-env" rows={2} placeholder="FOO=bar" />
</>
)
}
const DockerComposeDeploy = () => {
return (
<>
<label for="deploy-options-path">Path</label>
<input id="deploy-options-path" name="deploy-options-path" type="text" />
</>
)
}