diff options
author | Frédéric Guillot <fred@miniflux.net> | 2019-07-17 21:29:00 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2019-07-17 21:40:03 -0700 |
commit | ac3693562b635aaab4f43ad5d1343aae7ba5b7d2 (patch) | |
tree | db0487e501af59494df550d0ed4b30b4b1bd4327 | |
parent | 99149d9f2a32dd7426c6c2e51762e0895ed8199c (diff) |
Ask for confirmation before flushing history
-rw-r--r-- | template/html/history_entries.html | 8 | ||||
-rw-r--r-- | template/views.go | 10 | ||||
-rw-r--r-- | ui/history_flush.go | 7 | ||||
-rw-r--r-- | ui/ui.go | 2 |
4 files changed, 19 insertions, 8 deletions
diff --git a/template/html/history_entries.html b/template/html/history_entries.html index 0888778..109e1a2 100644 --- a/template/html/history_entries.html +++ b/template/html/history_entries.html @@ -6,7 +6,13 @@ {{ if .entries }} <ul> <li> - <a href="{{ route "flushHistory" }}">{{ t "menu.flush_history" }}</a> + <a href="#" + data-confirm="true" + data-url="{{ route "flushHistory" }}" + data-label-question="{{ t "confirm.question" }}" + data-label-yes="{{ t "confirm.yes" }}" + data-label-no="{{ t "confirm.no" }}" + data-label-loading="{{ t "confirm.loading" }}">{{ t "menu.flush_history" }}</a> </li> </ul> {{ end }} diff --git a/template/views.go b/template/views.go index af283f0..83006fd 100644 --- a/template/views.go +++ b/template/views.go @@ -884,7 +884,13 @@ var templateViewsMap = map[string]string{ {{ if .entries }} <ul> <li> - <a href="{{ route "flushHistory" }}">{{ t "menu.flush_history" }}</a> + <a href="#" + data-confirm="true" + data-url="{{ route "flushHistory" }}" + data-label-question="{{ t "confirm.question" }}" + data-label-yes="{{ t "confirm.yes" }}" + data-label-no="{{ t "confirm.no" }}" + data-label-loading="{{ t "confirm.loading" }}">{{ t "menu.flush_history" }}</a> </li> </ul> {{ end }} @@ -1455,7 +1461,7 @@ var templateViewsMapChecksums = map[string]string{ "entry": "1626bf4dd3223b2f730865676162aa0a9f0a0e009cdea90f705230542922e0f4", "feed_entries": "4bb6b96ba4d13dbaf22dcf6dd95ae36b6e5a0c99175d502865a164dc68fd4bae", "feeds": "31acc253c547a6cce5710d72a6f6b3b396162ecd5e5af295b2cf47c1ff55bd06", - "history_entries": "b65ca1d85615caa7c314a33f1cb997aa3477a79e66b9894b2fd387271ad467d2", + "history_entries": "9763d2120cfaeb78d406fdc029197fed2f7cfa7682970eeedae82ae79be65519", "import": "8349e47a783bb40d8e9248b4771656e5f006185e11079e1c4680dd52633420ed", "integrations": "f85b4a48ab1fc13b8ca94bfbbc44bd5e8784f35b26a63ec32cbe82b96b45e008", "login": "2e72d2d4b9786641b696bedbed5e10b04bdfd68254ddbbdb0a53cca621d200c7", diff --git a/ui/history_flush.go b/ui/history_flush.go index d0b8f62..e74c5b9 100644 --- a/ui/history_flush.go +++ b/ui/history_flush.go @@ -8,16 +8,15 @@ import ( "net/http" "miniflux.app/http/request" - "miniflux.app/http/response/html" - "miniflux.app/http/route" + "miniflux.app/http/response/json" ) func (h *handler) flushHistory(w http.ResponseWriter, r *http.Request) { err := h.store.FlushHistory(request.UserID(r)) if err != nil { - html.ServerError(w, r, err) + json.ServerError(w, r, err) return } - html.Redirect(w, r, route.Path(h.router, "history")) + json.OK(w, r, "OK") } @@ -45,7 +45,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool, feedHa // History pages. uiRouter.HandleFunc("/history", handler.showHistoryPage).Name("history").Methods("GET") uiRouter.HandleFunc("/history/entry/{entryID}", handler.showReadEntryPage).Name("readEntry").Methods("GET") - uiRouter.HandleFunc("/history/flush", handler.flushHistory).Name("flushHistory").Methods("GET") + uiRouter.HandleFunc("/history/flush", handler.flushHistory).Name("flushHistory").Methods("POST") // Bookmark pages. uiRouter.HandleFunc("/starred", handler.showStarredPage).Name("starred").Methods("GET") |