implemented the community admin menu and necessary tweaks to the menu system
This commit is contained in:
@@ -52,3 +52,35 @@ menudefs:
|
||||
- text: "Import User Accounts"
|
||||
link: "/TODO/sysadmin/import"
|
||||
permission: "Global.SysAdminAccess"
|
||||
- id: "communityadmin"
|
||||
title: "Community Administration"
|
||||
subtitle: "[CNAME]"
|
||||
permSet: "community"
|
||||
warning: >
|
||||
<strong>Note:</strong> These tools provide access to sensitive administrative features for the
|
||||
community. Use with care and review all changes before applying them to the community.
|
||||
items:
|
||||
- text: "Community Profile"
|
||||
link: "/TODO/comm/[CID]/admin/profile"
|
||||
permission: "Community.ShowAdmin"
|
||||
- text: "Set Community Category"
|
||||
link: "/TODO/comm/[CID]/admin/category"
|
||||
permission: "Community.ShowAdmin"
|
||||
ifdef: "USECAT"
|
||||
- text: "Set Community Services"
|
||||
link: "/TODO/comm/[CID]/admin/services"
|
||||
permission: "Community.ShowAdmin"
|
||||
disabled: true
|
||||
- text: "Membership Control"
|
||||
link: "/TODO/comm/[CID]/admin/members"
|
||||
permission: "Community.ShowAdmin"
|
||||
- text: "E-Mail to All Members"
|
||||
link: "/TODO/comm/[CID]/admin/massmail"
|
||||
permission: "Community.MassMail"
|
||||
- text: "Display Audit Records"
|
||||
link: "/TODO/comm/[CID]/admin/audit"
|
||||
permission: "Community.ShowAdmin"
|
||||
- text: "Delete Community"
|
||||
link: "/TODO/comm/[CID]/admin/delete"
|
||||
permission: "Community.Destroy"
|
||||
hazard: true
|
||||
|
||||
+32
-6
@@ -28,7 +28,9 @@ type MenuItem struct {
|
||||
Text string `yaml:"text"`
|
||||
Link string `yaml:"link"`
|
||||
Disabled bool `yaml:"disabled"`
|
||||
Hazard bool `yaml:"hazard"`
|
||||
Permission string `yaml:"permission"`
|
||||
Ifdef string `yaml:"ifdef"`
|
||||
P *MenuDefinition
|
||||
}
|
||||
|
||||
@@ -63,12 +65,36 @@ func (mi *MenuItem) Show(ctxt AmContext) bool {
|
||||
|
||||
// MenuDefinition represents a full menu definition.
|
||||
type MenuDefinition struct {
|
||||
ID string `yaml:"id"`
|
||||
Title string `yaml:"title"`
|
||||
PermSet string `yaml:"permSet"`
|
||||
Warning string `yaml:"warning"`
|
||||
Items []MenuItem `yaml:"items"`
|
||||
Tag string
|
||||
ID string `yaml:"id"`
|
||||
Title string `yaml:"title"`
|
||||
Subtitle string `yaml:"subtitle"`
|
||||
PermSet string `yaml:"permSet"`
|
||||
Warning string `yaml:"warning"`
|
||||
Items []MenuItem `yaml:"items"`
|
||||
Tag string
|
||||
}
|
||||
|
||||
// FilterCommunity creates a copy of this menu filtered to the specified community.
|
||||
func (mdef *MenuDefinition) FilterCommunity(comm *database.Community) *MenuDefinition {
|
||||
newmd := MenuDefinition{
|
||||
ID: mdef.ID,
|
||||
Title: mdef.Title,
|
||||
Subtitle: strings.ReplaceAll(mdef.Subtitle, "[CNAME]", comm.Name),
|
||||
PermSet: mdef.PermSet,
|
||||
Warning: mdef.Warning,
|
||||
Items: make([]MenuItem, len(mdef.Items)),
|
||||
Tag: mdef.Tag,
|
||||
}
|
||||
for i, it := range mdef.Items {
|
||||
newmd.Items[i].Text = it.Text
|
||||
newmd.Items[i].Link = strings.ReplaceAll(it.Link, "[CID]", comm.Alias)
|
||||
newmd.Items[i].Disabled = it.Disabled
|
||||
newmd.Items[i].Hazard = it.Hazard
|
||||
newmd.Items[i].Permission = it.Permission
|
||||
newmd.Items[i].Ifdef = it.Ifdef
|
||||
newmd.Items[i].P = &newmd
|
||||
}
|
||||
return &newmd
|
||||
}
|
||||
|
||||
// MenuDefs represents the set of all menu definitions.
|
||||
|
||||
+11
-2
@@ -10,6 +10,9 @@
|
||||
<!-- Page Title -->
|
||||
<div class="mb-6">
|
||||
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ menu.Title }}</h1>
|
||||
{{ if menu.Subtitle != "" }}
|
||||
<span class="text-blue-800 text-2xl font-bold ml-2">{{ menu.Subtitle }}</span>
|
||||
{{ end }}
|
||||
<hr class="border-2 border-gray-400 w-4/5 mb-4">
|
||||
</div>
|
||||
|
||||
@@ -19,13 +22,19 @@
|
||||
<nav class="space-y-3">
|
||||
{{ ctxt := . }}
|
||||
{{ range menu.Items }}
|
||||
{{ if .Show(ctxt) }}
|
||||
{{ vis := true }}
|
||||
{{ if .Ifdef != "" && !defs[.Ifdef] }}{{ vis = false }}{{ end }}
|
||||
{{ if vis && .Show(ctxt) }}
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="text-lg pt-0.5">🟣</span>
|
||||
{{ if .Disabled }}
|
||||
<span class="text-gray-500 font-medium">{{ .Text }}</span>
|
||||
{{ else }}
|
||||
<a href="{{ .Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ .Text }}</a>
|
||||
{{ if .Hazard }}
|
||||
<a href="{{ .Link }}" class="text-red-700 hover:text-red-900 font-medium">⚠️ {{ .Text }}</a>
|
||||
{{ else }}
|
||||
<a href="{{ .Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ .Text }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .IsMember() && !.IsMemberLocked() }}
|
||||
<div class="mb-1"> </div>
|
||||
<div class="mb-1"><a href="/TODO/comm/{{ comm.Alias }}/unjoin" class="text-blue-700 hover:text-blue-900">Unjoin</a></div>
|
||||
<div class="mb-1"><a href="/TODO/comm/{{ comm.Alias }}/unjoin" class="text-red-700 hover:text-red-900">⚠️ Unjoin</a></div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user