Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Sitemap): Use response data #2272

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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