mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-29 08:56:52 +00:00
Update Juno endpoints to pass subscriptionId (#339)
Corresponding [server side change](https://msdata.visualstudio.com/CosmosDB/_git/CosmosDB-portal/pullrequest/464443?_a=overview) has been deployed to Prod so now we can go ahead with DE side changes.
This commit is contained in:
parent
bd4d8da065
commit
263262a040
@ -248,7 +248,7 @@ describe("Gallery", () => {
|
|||||||
const authorizationHeader = getAuthorizationHeader();
|
const authorizationHeader = getAuthorizationHeader();
|
||||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||||
expect(window.fetch).toBeCalledWith(
|
expect(window.fetch).toBeCalledWith(
|
||||||
`${configContext.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery/${id}/favorite`,
|
`${configContext.JUNO_ENDPOINT}/api/notebooks/${sampleSubscriptionId}/${sampleDatabaseAccount.name}/gallery/${id}/favorite`,
|
||||||
{
|
{
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -80,7 +80,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getPinnedRepos(scope: string): Promise<IJunoResponse<IPinnedRepo[]>> {
|
public async getPinnedRepos(scope: string): Promise<IJunoResponse<IPinnedRepo[]>> {
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/github/pinnedrepos`, {
|
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github/pinnedrepos`, {
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async updatePinnedRepos(repos: IPinnedRepo[]): Promise<IJunoResponse<undefined>> {
|
public async updatePinnedRepos(repos: IPinnedRepo[]): Promise<IJunoResponse<undefined>> {
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/github/pinnedrepos`, {
|
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github/pinnedrepos`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(repos),
|
body: JSON.stringify(repos),
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
@ -120,7 +120,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async deleteGitHubInfo(): Promise<IJunoResponse<undefined>> {
|
public async deleteGitHubInfo(): Promise<IJunoResponse<undefined>> {
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/github`, {
|
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
});
|
});
|
||||||
@ -135,9 +135,12 @@ export class JunoClient {
|
|||||||
const githubParams = JunoClient.getGitHubClientParams();
|
const githubParams = JunoClient.getGitHubClientParams();
|
||||||
githubParams.append("code", code);
|
githubParams.append("code", code);
|
||||||
|
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/github/token?${githubParams.toString()}`, {
|
const response = await window.fetch(
|
||||||
|
`${this.getNotebooksSubscriptionIdAccountUrl()}/github/token?${githubParams.toString()}`,
|
||||||
|
{
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let data: IGitHubOAuthToken;
|
let data: IGitHubOAuthToken;
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
@ -159,10 +162,13 @@ export class JunoClient {
|
|||||||
const githubParams = JunoClient.getGitHubClientParams();
|
const githubParams = JunoClient.getGitHubClientParams();
|
||||||
githubParams.append("access_token", token);
|
githubParams.append("access_token", token);
|
||||||
|
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/github/token?${githubParams.toString()}`, {
|
const response = await window.fetch(
|
||||||
|
`${this.getNotebooksSubscriptionIdAccountUrl()}/github/token?${githubParams.toString()}`,
|
||||||
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
@ -179,7 +185,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getPublicGalleryData(): Promise<IJunoResponse<IPublicGalleryData>> {
|
public async getPublicGalleryData(): Promise<IJunoResponse<IPublicGalleryData>> {
|
||||||
const url = `${this.getNotebooksAccountUrl()}/gallery/public`;
|
const url = `${this.getNotebooksSubscriptionIdAccountUrl()}/gallery/public`;
|
||||||
const response = await window.fetch(url, {
|
const response = await window.fetch(url, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
@ -197,7 +203,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async acceptCodeOfConduct(): Promise<IJunoResponse<boolean>> {
|
public async acceptCodeOfConduct(): Promise<IJunoResponse<boolean>> {
|
||||||
const url = `${this.getNotebooksAccountUrl()}/gallery/acceptCodeOfConduct`;
|
const url = `${this.getNotebooksSubscriptionIdAccountUrl()}/gallery/acceptCodeOfConduct`;
|
||||||
const response = await window.fetch(url, {
|
const response = await window.fetch(url, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
@ -215,7 +221,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async isCodeOfConductAccepted(): Promise<IJunoResponse<boolean>> {
|
public async isCodeOfConductAccepted(): Promise<IJunoResponse<boolean>> {
|
||||||
const url = `${this.getNotebooksAccountUrl()}/gallery/isCodeOfConductAccepted`;
|
const url = `${this.getNotebooksSubscriptionIdAccountUrl()}/gallery/isCodeOfConductAccepted`;
|
||||||
const response = await window.fetch(url, {
|
const response = await window.fetch(url, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
@ -294,7 +300,7 @@ export class JunoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async favoriteNotebook(id: string): Promise<IJunoResponse<IGalleryItem>> {
|
public async favoriteNotebook(id: string): Promise<IJunoResponse<IGalleryItem>> {
|
||||||
const response = await window.fetch(`${this.getNotebooksAccountUrl()}/gallery/${id}/favorite`, {
|
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/gallery/${id}/favorite`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
});
|
});
|
||||||
@ -365,9 +371,7 @@ export class JunoClient {
|
|||||||
content: string,
|
content: string,
|
||||||
isLinkInjectionEnabled: boolean
|
isLinkInjectionEnabled: boolean
|
||||||
): Promise<IJunoResponse<IGalleryItem>> {
|
): Promise<IJunoResponse<IGalleryItem>> {
|
||||||
const response = await window.fetch(
|
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/gallery`, {
|
||||||
`${this.getNotebooksUrl()}/${this.getSubscriptionId()}/${this.getAccount()}/gallery`,
|
|
||||||
{
|
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: JunoClient.getHeaders(),
|
headers: JunoClient.getHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -379,8 +383,7 @@ export class JunoClient {
|
|||||||
content: JSON.parse(content),
|
content: JSON.parse(content),
|
||||||
addLinkToNotebookViewer: isLinkInjectionEnabled,
|
addLinkToNotebookViewer: isLinkInjectionEnabled,
|
||||||
} as IPublishNotebookRequest),
|
} as IPublishNotebookRequest),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
let data: IGalleryItem;
|
let data: IGalleryItem;
|
||||||
if (response.status === HttpStatusCodes.OK) {
|
if (response.status === HttpStatusCodes.OK) {
|
||||||
@ -502,6 +505,10 @@ export class JunoClient {
|
|||||||
return `${this.getNotebooksUrl()}/${this.getAccount()}`;
|
return `${this.getNotebooksUrl()}/${this.getAccount()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getNotebooksSubscriptionIdAccountUrl(): string {
|
||||||
|
return `${this.getNotebooksUrl()}/${this.getSubscriptionId()}/${this.getAccount()}`;
|
||||||
|
}
|
||||||
|
|
||||||
private getAnalyticsUrl(): string {
|
private getAnalyticsUrl(): string {
|
||||||
return `${configContext.JUNO_ENDPOINT}/api/analytics`;
|
return `${configContext.JUNO_ENDPOINT}/api/analytics`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user