Skip to content

Commit

Permalink
Merge pull request #2272 from tvdeyen/fix-sitemap-response
Browse files Browse the repository at this point in the history
fix(Sitemap): Use response data
  • Loading branch information
tvdeyen authored Mar 24, 2022
2 parents 2854944 + 671ce46 commit e88a3a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package/src/page_sorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function onFinishDragging(evt) {

patch(url, data)
.then(async (response) => {
const pageData = await response.json()
const pageData = await response.data
const pageEl = document.getElementById(`page_${pageId}`)
const urlPathEl = pageEl.querySelector(".sitemap_url")

Expand Down
8 changes: 4 additions & 4 deletions package/src/sitemap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The admin sitemap Alchemy class
import PageSorter from "./page_sorter"
import { on } from "./utils/events"
import { patch } from "./utils/ajax"
import { get, patch } from "./utils/ajax"
import { createSortables, displayPageFolders } from "./page_sorter"

export default class Sitemap {
Expand Down Expand Up @@ -31,9 +31,9 @@ export default class Sitemap {
const spinTarget = this.sitemap_wrapper
spinTarget.innerHTML = ""
spinner.spin(spinTarget)
fetch(`${this.options.url}?id=${pageId}`)
get(this.options.url, { id: pageId })
.then(async (response) => {
this.render(await response.json())
this.render(await response.data)
this.handlePageFolders()
spinner.stop()
})
Expand All @@ -55,7 +55,7 @@ export default class Sitemap {

patch(Alchemy.routes.fold_admin_page_path(pageId))
.then(async (response) => {
this.reRender(pageId, await response.json())
this.reRender(pageId, await response.data)
spinner.stop()
})
.catch(this.errorHandler)
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_controller.allow_forgery_protection = true

config.action_mailer.perform_caching = false

Expand Down
3 changes: 2 additions & 1 deletion spec/features/admin/legacy_page_url_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

def open_page_properties
visit admin_pages_path
page.find("a[href='#{configure_admin_page_path(a_page)}']").click
expect(page).to have_no_css(".spinner")
page.find("a[href='#{configure_admin_page_path(a_page)}']", wait: 10).click
end

it "lets a user add a page link" do
Expand Down

0 comments on commit e88a3a5

Please sign in to comment.