Skip to content

Commit

Permalink
Fix for base_url bug, refs #18 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Aug 18, 2023
1 parent 0c0b72b commit 252808a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions datasette_write_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ def extra_template_vars(datasette, database, table):
async def permission_allowed(actor, permission):
return await datasette.permission_allowed(actor, permission, (database, table))

return {
"permission_allowed": permission_allowed,
"base_url": datasette.urls.instance()[:-1],
}
return {"permission_allowed": permission_allowed}


def affinity_from_type(type):
Expand Down
4 changes: 2 additions & 2 deletions datasette_write_ui/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function editRowDetails(
primaryKeys: string
): Promise<EditRowDetailsResponse> {
return fetch(
`${BASE_URL}/-/datasette-write-ui/edit-row-details?${new URLSearchParams({
`${BASE_URL}-/datasette-write-ui/edit-row-details?${new URLSearchParams({
db,
table,
primaryKeys,
Expand All @@ -36,7 +36,7 @@ export async function insertRowDetails(
table: string
): Promise<InsertRowDetailsResponse> {
return fetch(
`${BASE_URL}/-/datasette-write-ui/insert-row-details?${new URLSearchParams({
`${BASE_URL}-/datasette-write-ui/insert-row-details?${new URLSearchParams({
db,
table,
})}`
Expand Down
2 changes: 1 addition & 1 deletion datasette_write_ui/static/table.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions datasette_write_ui/write-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function deleteRow(
table: string,
primaryKeys: string
) {
return fetch(`${BASE_URL}/${db}/${table}/${primaryKeys}/-/delete`, {
return fetch(`${BASE_URL}${db}/${table}/${primaryKeys}/-/delete`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
Expand All @@ -29,7 +29,7 @@ export async function updateRow(
primaryKeys: string,
body: {}
) {
return fetch(`${BASE_URL}/${db}/${table}/${primaryKeys}/-/update`, {
return fetch(`${BASE_URL}${db}/${table}/${primaryKeys}/-/update`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
Expand All @@ -43,7 +43,7 @@ export async function insertRow(
table: string,
row: { [key: string]: any }
) {
return fetch(`${BASE_URL}/${db}/${table}/-/insert`, {
return fetch(`${BASE_URL}${db}/${table}/-/insert`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
Expand Down

0 comments on commit 252808a

Please sign in to comment.