Implement mailbox deletion
This commit is contained in:
parent
62e7cf8933
commit
e4daf0778d
|
@ -34,6 +34,9 @@ func registerRoutes(p *alps.GoPlugin) {
|
||||||
p.GET("/new-mailbox", handleNewMailbox)
|
p.GET("/new-mailbox", handleNewMailbox)
|
||||||
p.POST("/new-mailbox", handleNewMailbox)
|
p.POST("/new-mailbox", handleNewMailbox)
|
||||||
|
|
||||||
|
p.GET("/delete-mailbox/:mbox", handleDeleteMailbox)
|
||||||
|
p.POST("/delete-mailbox/:mbox", handleDeleteMailbox)
|
||||||
|
|
||||||
p.GET("/message/:mbox/:uid", func(ctx *alps.Context) error {
|
p.GET("/message/:mbox/:uid", func(ctx *alps.Context) error {
|
||||||
return handleGetPart(ctx, false)
|
return handleGetPart(ctx, false)
|
||||||
})
|
})
|
||||||
|
@ -303,6 +306,25 @@ func handleNewMailbox(ctx *alps.Context) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleDeleteMailbox(ctx *alps.Context) error {
|
||||||
|
ibase, err := newIMAPBaseRenderData(ctx, alps.NewBaseRenderData(ctx))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mbox := ibase.Mailbox
|
||||||
|
ibase.BaseRenderData.WithTitle("Delete folder '" + mbox.Name + "'")
|
||||||
|
|
||||||
|
if ctx.Request().Method == http.MethodPost {
|
||||||
|
ctx.Session.DoIMAP(func(c *imapclient.Client) error {
|
||||||
|
return c.Delete(mbox.Name)
|
||||||
|
})
|
||||||
|
return ctx.Redirect(http.StatusFound, "/mailbox/INBOX")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Render(http.StatusOK, "delete-mailbox.html", ibase)
|
||||||
|
}
|
||||||
|
|
||||||
func handleLogin(ctx *alps.Context) error {
|
func handleLogin(ctx *alps.Context) error {
|
||||||
username := ctx.FormValue("username")
|
username := ctx.FormValue("username")
|
||||||
password := ctx.FormValue("password")
|
password := ctx.FormValue("password")
|
||||||
|
|
|
@ -766,3 +766,13 @@ button:active,
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
background-color: #f8f8f8;
|
background-color: #f8f8f8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
padding: 0.5rem;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
margin: 1rem 0;
|
||||||
|
background: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
border-color: #f5c6cb;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
|
24
themes/alps/delete-mailbox.html
Normal file
24
themes/alps/delete-mailbox.html
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{{template "head.html" .}}
|
||||||
|
{{template "nav.html" .}}
|
||||||
|
{{template "util.html" .}}
|
||||||
|
|
||||||
|
<div class="page-wrap">
|
||||||
|
{{ template "aside" . }}
|
||||||
|
<div class="container">
|
||||||
|
<main class="create-update">
|
||||||
|
<form method="POST">
|
||||||
|
<h2>Delete "{{ .Mailbox.Name }}"?</h2>
|
||||||
|
<div class="alert">
|
||||||
|
<strong>Warning!</strong> This will permanently delete all messages
|
||||||
|
in "{{.Mailbox.Name}}".
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">Delete "{{.Mailbox.Name}}"</button>
|
||||||
|
<a class="button-link" href="/">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{template "foot.html"}}
|
|
@ -26,6 +26,12 @@
|
||||||
<div class="action-group">
|
<div class="action-group">
|
||||||
<a href="{{ .GlobalData.URL.String }}" class="button-link">Refresh</a>
|
<a href="{{ .GlobalData.URL.String }}" class="button-link">Refresh</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="action-group">
|
||||||
|
{{ if not (eq .Mailbox.Name "INBOX") }}
|
||||||
|
<a class="button-link" href="/delete-mailbox/{{.Mailbox.Name | pathescape}}">Delete folder</a>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="get" class="actions-search">
|
<form method="get" class="actions-search">
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
{{ if eq $.GlobalData.URL.Path "/compose" }}active{{ end }}
|
{{ if eq $.GlobalData.URL.Path "/compose" }}active{{ end }}
|
||||||
">Compose mail</a>
|
">Compose mail</a>
|
||||||
{{ with .CategorizedMailboxes }}
|
{{ with .CategorizedMailboxes }}
|
||||||
{{ with .Common.Inbox }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Inbox }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Drafts }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Drafts }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Outbox }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Outbox }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Sent }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Sent }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Junk }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Junk }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Trash }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Trash }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ with .Common.Archive }}{{ template "mbox-link" . }}{{ end}}
|
{{ with .Common.Archive }}{{ template "mbox-link" . }}{{ end }}
|
||||||
{{ if .Additional }}
|
{{ if .Additional }}
|
||||||
<hr />
|
<hr />
|
||||||
{{ range .Additional }}
|
{{ range .Additional }}
|
||||||
|
|
Loading…
Reference in a new issue