Skip to content

Commit

Permalink
use query param instead of path param
Browse files Browse the repository at this point in the history
  • Loading branch information
rouk1 committed Oct 3, 2024
1 parent 4fb8903 commit 6c7193f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions frontend/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function fetchProject(): Promise<Project | null> {

export async function putView(view: string, layout: Layout): Promise<Project | null> {
try {
const r = await fetch(`${BASE_URL}/project/views/${view}`, {
const r = await fetch(`${BASE_URL}/project/views?key=${view}`, {
method: "PUT",
body: JSON.stringify(layout),
headers: {
Expand All @@ -53,7 +53,7 @@ export async function putView(view: string, layout: Layout): Promise<Project | n

export async function deleteView(view: string) {
try {
const r = await fetch(`${BASE_URL}/project/views/${view}`, {
const r = await fetch(`${BASE_URL}/project/views?key=${view}`, {
method: "DELETE",
});
checkResponseStatus(r, 202);
Expand All @@ -64,7 +64,7 @@ export async function deleteView(view: string) {

export async function fetchShareableBlob(view: string) {
try {
const r = await fetch(`${BASE_URL}/project/views/share/${view}`, {
const r = await fetch(`${BASE_URL}/project/views/share?key=${view}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
6 changes: 3 additions & 3 deletions src/skore/ui/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def get_items(request: Request):
return __serialize_project(project)


@router.post("/views/share/{key:path}")
@router.post("/views/share")
async def share_store(
request: Request,
key: str,
Expand Down Expand Up @@ -131,7 +131,7 @@ def read_asset_content(filename: str):
)


@router.put("/views/{key:path}", status_code=status.HTTP_201_CREATED)
@router.put("/views", status_code=status.HTTP_201_CREATED)
async def put_view(request: Request, key: str, layout: Layout):
"""Set the layout of the view corresponding to `key`.
Expand All @@ -145,7 +145,7 @@ async def put_view(request: Request, key: str, layout: Layout):
return __serialize_project(project)


@router.delete("/views/{key:path}", status_code=status.HTTP_202_ACCEPTED)
@router.delete("/views", status_code=status.HTTP_202_ACCEPTED)
async def delete_view(request: Request, key: str):
"""Delete the view corresponding to `key`."""
project: Project = request.app.state.project
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/ui/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ def test_get_items(client, project):
def test_share_view(client, project):
project.put_view("hello", View(layout=[]))

response = client.post("/api/project/views/share/hello")
response = client.post("/api/project/views/share?key=hello")
assert response.status_code == 200
assert b"<!DOCTYPE html>" in response.content


def test_share_view_not_found(client, project):
response = client.post("/api/project/views/share/hello")
def test_share_view_not_found(client):
response = client.post("/api/project/views/share?key=hello")
assert response.status_code == 404


def test_put_view_layout(client):
response = client.put("/api/project/views/hello", json=["test"])
response = client.put("/api/project/views?key=hello", json=["test"])
assert response.status_code == 201


def test_delete_view(client, project):
project.put_view("hello", View(layout=[]))
response = client.delete("/api/project/views/hello")
response = client.delete("/api/project/views?key=hello")
assert response.status_code == 202


def test_delete_view_missing(client):
response = client.delete("/api/project/views/hello")
response = client.delete("/api/project/views?key=hello")
assert response.status_code == 404

0 comments on commit 6c7193f

Please sign in to comment.