mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-30 02:28:44 +01:00
Remove Phoenix & Notebooks - Phase 4: Remove GitHub integration
Removes the GitHub notebook-repo integration that only existed to pin/browse notebook repositories. Deletes src/GitHub/, the GitHub controls/panes, GitHubUtils, JunoUtils, and the connectToGitHub webpack entry. Decouples NotebookManager, useNotebook, the resource tree, and Explorer from GitHub wiring. Trims JunoClient's GitHub-only methods while keeping the Schema and gallery methods. Removes GitHub config fields from ConfigContext and strips the dead github:// branches from NotebookUtil. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
import { allowedJunoOrigins, validateEndpoint } from "Utils/EndpointUtils";
|
||||
import { GetGithubClientId } from "Utils/GitHubUtils";
|
||||
import ko from "knockout";
|
||||
import { HttpHeaders, HttpStatusCodes } from "../Common/Constants";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeAccessComponent";
|
||||
import { IGitHubResponse } from "../GitHub/GitHubClient";
|
||||
import { IGitHubOAuthToken } from "../GitHub/GitHubOAuthService";
|
||||
import { userContext } from "../UserContext";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
|
||||
@@ -15,17 +10,6 @@ export interface IJunoResponse<T> {
|
||||
data: T;
|
||||
}
|
||||
|
||||
export interface IPinnedRepo {
|
||||
owner: string;
|
||||
name: string;
|
||||
private: boolean;
|
||||
branches: IPinnedBranch[];
|
||||
}
|
||||
|
||||
export interface IPinnedBranch {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface IGalleryItem {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -45,113 +29,6 @@ export interface IGalleryItem {
|
||||
}
|
||||
|
||||
export class JunoClient {
|
||||
private cachedPinnedRepos: ko.Observable<IPinnedRepo[]>;
|
||||
|
||||
constructor() {
|
||||
this.cachedPinnedRepos = ko.observable<IPinnedRepo[]>([]);
|
||||
}
|
||||
|
||||
public subscribeToPinnedRepos(callback: ko.SubscriptionCallback<IPinnedRepo[], void>): ko.Subscription {
|
||||
return this.cachedPinnedRepos.subscribe(callback);
|
||||
}
|
||||
|
||||
public async getPinnedRepos(scope: string): Promise<IJunoResponse<IPinnedRepo[]>> {
|
||||
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github/pinnedrepos`, {
|
||||
headers: JunoClient.getHeaders(),
|
||||
});
|
||||
|
||||
let pinnedRepos: IPinnedRepo[];
|
||||
if (response.status === HttpStatusCodes.OK) {
|
||||
pinnedRepos = JSON.parse(await response.text());
|
||||
|
||||
// In case we're restricted to public only scope, we return only public repos
|
||||
if (scope === AuthorizeAccessComponent.Scopes.Public.key) {
|
||||
pinnedRepos = pinnedRepos.filter((repo) => !repo.private);
|
||||
}
|
||||
|
||||
this.cachedPinnedRepos(pinnedRepos);
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data: pinnedRepos,
|
||||
};
|
||||
}
|
||||
|
||||
public async updatePinnedRepos(repos: IPinnedRepo[]): Promise<IJunoResponse<undefined>> {
|
||||
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github/pinnedrepos`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(repos),
|
||||
headers: JunoClient.getHeaders(),
|
||||
});
|
||||
|
||||
if (response.status === HttpStatusCodes.OK) {
|
||||
this.cachedPinnedRepos(repos);
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
public async deleteGitHubInfo(): Promise<IJunoResponse<undefined>> {
|
||||
const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/github`, {
|
||||
method: "DELETE",
|
||||
headers: JunoClient.getHeaders(),
|
||||
});
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
public async getGitHubToken(code: string): Promise<IGitHubResponse<IGitHubOAuthToken>> {
|
||||
const githubParams = JunoClient.getGitHubClientParams();
|
||||
githubParams.append("code", code);
|
||||
|
||||
const response = await window.fetch(
|
||||
`${this.getNotebooksSubscriptionIdAccountUrl()}/github/token?${githubParams.toString()}`,
|
||||
{
|
||||
headers: JunoClient.getHeaders(),
|
||||
},
|
||||
);
|
||||
|
||||
let data: IGitHubOAuthToken;
|
||||
const body = await response.text();
|
||||
if (body) {
|
||||
data = JSON.parse(body);
|
||||
} else {
|
||||
data = {
|
||||
error: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
public async deleteAppAuthorization(token: string): Promise<IJunoResponse<string>> {
|
||||
const githubParams = JunoClient.getGitHubClientParams();
|
||||
githubParams.append("access_token", token);
|
||||
|
||||
const response = await window.fetch(
|
||||
`${this.getNotebooksSubscriptionIdAccountUrl()}/github/token?${githubParams.toString()}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: JunoClient.getHeaders(),
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data: await response.text(),
|
||||
};
|
||||
}
|
||||
|
||||
public async increaseNotebookViews(id: string): Promise<IJunoResponse<IGalleryItem>> {
|
||||
const response = await window.fetch(`${this.getNotebooksUrl()}/gallery/${id}/views`, {
|
||||
method: "PATCH",
|
||||
@@ -245,18 +122,6 @@ export class JunoClient {
|
||||
return `${JunoClient.getJunoEndpoint()}/api/notebooks`;
|
||||
}
|
||||
|
||||
private getAccount(): string {
|
||||
return userContext?.databaseAccount?.name;
|
||||
}
|
||||
|
||||
private getSubscriptionId(): string {
|
||||
return userContext.subscriptionId;
|
||||
}
|
||||
|
||||
private getNotebooksSubscriptionIdAccountUrl(): string {
|
||||
return `${this.getNotebooksUrl()}/subscriptions/${this.getSubscriptionId()}/databaseAccounts/${this.getAccount()}`;
|
||||
}
|
||||
|
||||
private getAnalyticsUrl(): string {
|
||||
return `${JunoClient.getJunoEndpoint()}/api/analytics`;
|
||||
}
|
||||
@@ -268,16 +133,4 @@ export class JunoClient {
|
||||
[HttpHeaders.contentType]: "application/json",
|
||||
};
|
||||
}
|
||||
|
||||
private static getGitHubClientParams(): URLSearchParams {
|
||||
const githubParams = new URLSearchParams({
|
||||
client_id: GetGithubClientId(),
|
||||
});
|
||||
|
||||
if (configContext.GITHUB_CLIENT_SECRET) {
|
||||
githubParams.append("client_secret", configContext.GITHUB_CLIENT_SECRET);
|
||||
}
|
||||
|
||||
return githubParams;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user