mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-08-10 08:37:17 +01:00
Remove Phoenix & Notebooks - Phase 4: Remove GitHub integration (#2528)
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,32 +0,0 @@
|
||||
import * as GitHubUtils from "./GitHubUtils";
|
||||
|
||||
const owner = "owner-1";
|
||||
const repo = "repo-1";
|
||||
const branch = "branch/name.1-2";
|
||||
const path = "folder name/file name1:2.ipynb";
|
||||
|
||||
describe("GitHubUtils", () => {
|
||||
it("fromRepoUri parses github repo url correctly", () => {
|
||||
const repoInfo = GitHubUtils.fromRepoUri(`https://github.com/${owner}/${repo}/tree/${branch}`);
|
||||
expect(repoInfo).toEqual({
|
||||
owner,
|
||||
repo,
|
||||
branch,
|
||||
});
|
||||
});
|
||||
|
||||
it("toContentUri generates github uris correctly", () => {
|
||||
const uri = GitHubUtils.toContentUri(owner, repo, branch, path);
|
||||
expect(uri).toBe(`github://${owner}/${repo}/${path}?ref=${branch}`);
|
||||
});
|
||||
|
||||
it("fromContentUri parses the github uris correctly", () => {
|
||||
const contentInfo = GitHubUtils.fromContentUri(`github://${owner}/${repo}/${path}?ref=${branch}`);
|
||||
expect(contentInfo).toEqual({
|
||||
owner,
|
||||
repo,
|
||||
branch,
|
||||
path,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,79 +0,0 @@
|
||||
// https://github.com/<owner>/<repo>/tree/<branch>
|
||||
|
||||
import { JunoEndpoints } from "Common/Constants";
|
||||
import { configContext } from "ConfigContext";
|
||||
import { userContext } from "UserContext";
|
||||
|
||||
// The url when users visit a repo/branch on github.com
|
||||
export const RepoUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/tree\/([^?]*)/;
|
||||
|
||||
// github://<owner>/<repo>/<path>?ref=<branch>
|
||||
// Custom scheme for github content
|
||||
export const ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
|
||||
|
||||
// https://github.com/<owner>/<repo>/blob/<branch>/<path>
|
||||
// We need to support this until we move to newer scheme for quickstarts
|
||||
export const LegacyContentUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/blob\/([^/]*)\/([^?]*)/;
|
||||
|
||||
export function toRepoFullName(owner: string, repo: string): string {
|
||||
return `${owner}/${repo}`;
|
||||
}
|
||||
|
||||
export function fromRepoUri(repoUri: string): undefined | { owner: string; repo: string; branch: string } {
|
||||
const matches = repoUri.match(RepoUriPattern);
|
||||
if (matches && matches.length > 3) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
repo: matches[2],
|
||||
branch: matches[3],
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function fromContentUri(
|
||||
contentUri: string,
|
||||
): undefined | { owner: string; repo: string; branch: string; path: string } {
|
||||
let matches = contentUri.match(ContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
repo: matches[2],
|
||||
branch: matches[4],
|
||||
path: matches[3],
|
||||
};
|
||||
}
|
||||
|
||||
matches = contentUri.match(LegacyContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
repo: matches[2],
|
||||
branch: matches[3],
|
||||
path: matches[4],
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function toContentUri(owner: string, repo: string, branch: string, path: string): string {
|
||||
return `github://${owner}/${repo}/${path}?ref=${branch}`;
|
||||
}
|
||||
|
||||
export function toRawContentUri(owner: string, repo: string, branch: string, path: string): string {
|
||||
return `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${path}`;
|
||||
}
|
||||
|
||||
export function GetGithubClientId(): string {
|
||||
const junoEndpoint = userContext.features.junoEndpoint ?? configContext.JUNO_ENDPOINT;
|
||||
if (
|
||||
junoEndpoint === JunoEndpoints.Test ||
|
||||
junoEndpoint === JunoEndpoints.Test2 ||
|
||||
junoEndpoint === JunoEndpoints.Test3
|
||||
) {
|
||||
return configContext.GITHUB_TEST_ENV_CLIENT_ID;
|
||||
}
|
||||
return configContext.GITHUB_CLIENT_ID;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
|
||||
import { IPinnedRepo } from "../Juno/JunoClient";
|
||||
import * as JunoUtils from "./JunoUtils";
|
||||
import { IGitHubRepo } from "../GitHub/GitHubClient";
|
||||
|
||||
const gitHubRepo: IGitHubRepo = {
|
||||
name: "repo-name",
|
||||
owner: "owner",
|
||||
private: false,
|
||||
};
|
||||
|
||||
const repoListItem: RepoListItem = {
|
||||
key: "key",
|
||||
repo: {
|
||||
name: "repo-name",
|
||||
owner: "owner",
|
||||
private: false,
|
||||
},
|
||||
branches: [
|
||||
{
|
||||
name: "branch-name",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const pinnedRepo: IPinnedRepo = {
|
||||
name: "repo-name",
|
||||
owner: "owner",
|
||||
private: false,
|
||||
branches: [
|
||||
{
|
||||
name: "branch-name",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("JunoUtils", () => {
|
||||
it("toPinnedRepo converts RepoListItem to IPinnedRepo", () => {
|
||||
expect(JunoUtils.toPinnedRepo(repoListItem)).toEqual(pinnedRepo);
|
||||
});
|
||||
|
||||
it("toGitHubRepo converts IPinnedRepo to IGitHubRepo", () => {
|
||||
expect(JunoUtils.toGitHubRepo(pinnedRepo)).toEqual(gitHubRepo);
|
||||
});
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
|
||||
import { IGitHubRepo } from "../GitHub/GitHubClient";
|
||||
import { IPinnedRepo } from "../Juno/JunoClient";
|
||||
|
||||
export function toPinnedRepo(item: RepoListItem): IPinnedRepo {
|
||||
return {
|
||||
owner: item.repo.owner,
|
||||
name: item.repo.name,
|
||||
private: item.repo.private,
|
||||
branches: item.branches.map((element) => ({ name: element.name })),
|
||||
};
|
||||
}
|
||||
|
||||
export function toGitHubRepo(pinnedRepo: IPinnedRepo): IGitHubRepo {
|
||||
return {
|
||||
owner: pinnedRepo.owner,
|
||||
name: pinnedRepo.name,
|
||||
private: pinnedRepo.private,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user