mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Add Report Abuse dialog for public gallery notebooks (#265)

This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import ko from "knockout";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { HttpHeaders, HttpStatusCodes } from "../Common/Constants";
|
||||
import { IPinnedRepo, JunoClient, IGalleryItem } from "./JunoClient";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
@@ -237,7 +236,7 @@ describe("Gallery", () => {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -260,7 +259,7 @@ describe("Gallery", () => {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -281,7 +280,7 @@ describe("Gallery", () => {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -299,7 +298,7 @@ describe("Gallery", () => {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/favorites`, {
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -317,7 +316,7 @@ describe("Gallery", () => {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/published`, {
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -337,7 +336,7 @@ describe("Gallery", () => {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -364,7 +363,7 @@ describe("Gallery", () => {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ko from "knockout";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { HttpHeaders, HttpStatusCodes } from "../Common/Constants";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeAccessComponent";
|
||||
@@ -404,6 +404,30 @@ export class JunoClient {
|
||||
return `${this.getNotebooksUrl()}/gallery/${id}`;
|
||||
}
|
||||
|
||||
public async reportAbuse(notebookId: string, abuseCategory: string, notes: string): Promise<IJunoResponse<boolean>> {
|
||||
const response = await window.fetch(`${this.getNotebooksUrl()}/avert/reportAbuse`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
notebookId,
|
||||
abuseCategory,
|
||||
notes
|
||||
}),
|
||||
headers: {
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
}
|
||||
});
|
||||
|
||||
let data: boolean;
|
||||
if (response.status === HttpStatusCodes.OK) {
|
||||
data = await response.json();
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data
|
||||
};
|
||||
}
|
||||
|
||||
private async getNotebooks(input: RequestInfo, init?: RequestInit): Promise<IJunoResponse<IGalleryItem[]>> {
|
||||
const response = await window.fetch(input, init);
|
||||
|
||||
@@ -430,7 +454,7 @@ export class JunoClient {
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
return {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user