Implement basic flavor support

This commit is contained in:
Tom Wiesing 2023-11-02 20:06:09 +01:00
parent 9a3e508ce8
commit d6c0c465e4
No known key found for this signature in database
24 changed files with 246 additions and 82 deletions

View file

@ -69,11 +69,10 @@ var (
menuProvision = component.MenuItem{Title: "Provision", Path: "/admin/instances/provision/"}
menuInstances = component.MenuItem{Title: "Instances", Path: "/admin/instances/"}
menuInstance = component.DummyMenuItem()
menuRebuild = component.DummyMenuItem()
menuGrants = component.DummyMenuItem()
menuIngredients = component.DummyMenuItem()
menuInstances = component.MenuItem{Title: "Instances", Path: "/admin/instances/"}
menuInstance = component.DummyMenuItem()
menuRebuild = component.DummyMenuItem()
menuGrants = component.DummyMenuItem()
)
func (admin *Admin) HandleRoute(ctx context.Context, route string) (handler http.Handler, err error) {

View file

@ -91,14 +91,6 @@
</tr>
</thead>
<tbody>
<tr>
<td>
PHP Version
</td>
<td>
<code>{{ .Instance.System.PHP }}</code>
</td>
</tr>
<tr>
<td>
Docker Base Image
@ -107,6 +99,14 @@
<code>{{ .Instance.System.GetDockerBaseImage }}</code>
</td>
</tr>
<tr>
<td>
PHP Version
</td>
<td>
<code>{{ .Instance.System.PHP }}</code>
</td>
</tr>
<tr>
<td>
OPCache Development Config
@ -143,36 +143,20 @@
<tbody>
<tr>
<td>
Theme
Drupal Version
</td>
<td>
<code>{{ .Info.DrupalVersion }}</code>
</td>
</tr>
<tr>
<td>
Default Theme
</td>
<td>
<code>{{ .Info.Theme }}</code>
</td>
</tr>
<tr>
<td>
Docker Base Image
</td>
<td>
<code>{{ .Instance.System.GetDockerBaseImage }}</code>
</td>
</tr>
<tr>
<td>
OPCache Development Config
</td>
<td>
<code>{{ .Instance.System.OpCacheDevelopment }}</code>
</td>
</tr>
<tr>
<td>
Content Security Policy
</td>
<td>
<code>{{ .Instance.System.ContentSecurityPolicy }}</code>
</td>
</tr>
</tbody>
</table>
</div>

View file

@ -67,12 +67,23 @@
{{ if not $rebuild }}
<div class="pure-controls">
<h5>Profile</h5>
<h5>Flavor</h5>
</div>
<div class="pure-control-group">
In the future, it will be possible to configure the Drupal, WissKI and Module versions here.
But this is not yet implemented.
<div class="pure-controls">
<span class="pure-form-message-inline">
Determine the set of module(s) to install for this WissKI. <br />
Changing this after installation may not be possible and in any case requires manual intervention.
</span>
{{ $defaultProfile := .DefaultProfile }}
{{ range $name, $description := .Profiles }}
<label for="flavor-{{ $name }}" class="pure-radio">
<input type="radio" id="flavor-{{ $name }}" name="flavor" value="{{ $name }}" {{ if eq $name $defaultProfile }}checked{{ end }} />
<b>{{ $name }}</b>
{{ $description }}
</label>
{{ end }}
</div>
{{ end }}

View file

@ -43,7 +43,6 @@ func (admin *Admin) instance(ctx context.Context) http.Handler {
templating.Actions(
menuRebuild,
menuGrants,
menuIngredients,
),
)

View file

@ -6,6 +6,8 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel/manager"
"github.com/tkw1536/pkglib/collection"
_ "embed"
)
@ -26,6 +28,8 @@ func (admin *Admin) instanceProvision(ctx context.Context) http.Handler {
return tpl.HTMLHandler(func(r *http.Request) (ipc instanceSystemContext, err error) {
ipc.prepare(false)
ipc.DefaultProfile = manager.DefaultProfile()
ipc.Profiles = collection.MapValues(manager.Profiles(), func(_ string, profile manager.Profile) string { return profile.Description })
return ipc, nil
})
}

View file

@ -36,6 +36,10 @@ type instanceSystemContext struct {
Rebuild bool
Slug string
System models.System
// list of known profiles and their descriptions
DefaultProfile string
Profiles map[string]string
}
// prepare prares the given instanceSystemContent