Skip to content

Commit

Permalink
Add an option to skip redirect on page rename
Browse files Browse the repository at this point in the history
  • Loading branch information
dvargas92495 authored and tiensonqin committed Aug 30, 2022
1 parent 0275e5a commit 76bab25
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions src/main/frontend/handler/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -559,31 +559,32 @@

(defn rename!
"Accepts unsanitized page names"
[old-name new-name]
(let [repo (state/get-current-repo)
old-name (string/trim old-name)
new-name (string/trim new-name)
old-page-name (util/page-name-sanity-lc old-name)
new-page-name (util/page-name-sanity-lc new-name)
name-changed? (not= old-name new-name)]
(if (and old-name
new-name
(not (string/blank? new-name))
name-changed?)
(do
(cond
(= old-page-name new-page-name)
(rename-page-aux old-name new-name true)

(db/pull [:block/name new-page-name])
(merge-pages! old-page-name new-page-name)

:else
(rename-namespace-pages! repo old-name new-name))
(rename-nested-pages old-name new-name))
(when (string/blank? new-name)
(notification/show! "Please use a valid name, empty name is not allowed!" :error)))
(ui-handler/re-render-root!)))
([old-name new-name] (rename! old-name new-name true))
([old-name new-name redirect?]
(let [repo (state/get-current-repo)
old-name (string/trim old-name)
new-name (string/trim new-name)
old-page-name (util/page-name-sanity-lc old-name)
new-page-name (util/page-name-sanity-lc new-name)
name-changed? (not= old-name new-name)]
(if (and old-name
new-name
(not (string/blank? new-name))
name-changed?)
(do
(cond
(= old-page-name new-page-name)
(rename-page-aux old-name new-name redirect?)

(db/pull [:block/name new-page-name])
(merge-pages! old-page-name new-page-name)

:else
(rename-namespace-pages! repo old-name new-name))
(rename-nested-pages old-name new-name))
(when (string/blank? new-name)
(notification/show! "Please use a valid name, empty name is not allowed!" :error)))
(ui-handler/re-render-root!))))

(defn- split-col-by-element
[col element]
Expand Down

0 comments on commit 76bab25

Please sign in to comment.