Fix GitHub repos panel issues (#875)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com> Co-authored-by: Tanuj Mittal <tamitta@microsoft.com>
This commit is contained in:
parent
397231dca2
commit
b115bb34ca
|
@ -56,7 +56,7 @@ export class GitHubReposComponent extends React.Component<GitHubReposComponentPr
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={"paneMainContent"}>{content}</div>
|
<div>{content}</div>
|
||||||
{!this.props.showAuthorizeAccess && (
|
{!this.props.showAuthorizeAccess && (
|
||||||
<>
|
<>
|
||||||
<div className={"paneFooter"} style={ContentFooterStyle}>
|
<div className={"paneFooter"} style={ContentFooterStyle}>
|
||||||
|
|
|
@ -42,6 +42,15 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
"gitHubOAuthService": GitHubOAuthService {
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
|
"token": [Function],
|
||||||
|
},
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
||||||
|
@ -113,6 +122,15 @@ exports[`SettingsComponent renders 1`] = `
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
"gitHubOAuthService": GitHubOAuthService {
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
|
"token": [Function],
|
||||||
|
},
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import * as Constants from "../../../Common/Constants";
|
||||||
import { configContext, Platform } from "../../../ConfigContext";
|
import { configContext, Platform } from "../../../ConfigContext";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
|
import { JunoClient } from "../../../Juno/JunoClient";
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import { getCollectionName, getDatabaseName } from "../../../Utils/APITypeUtils";
|
import { getCollectionName, getDatabaseName } from "../../../Utils/APITypeUtils";
|
||||||
import { isServerlessAccount } from "../../../Utils/CapabilityUtils";
|
import { isServerlessAccount } from "../../../Utils/CapabilityUtils";
|
||||||
|
@ -560,6 +561,7 @@ function createNotebookWorkspaceResetButton(container: Explorer): CommandButtonC
|
||||||
function createManageGitHubAccountButton(container: Explorer): CommandButtonComponentProps {
|
function createManageGitHubAccountButton(container: Explorer): CommandButtonComponentProps {
|
||||||
const connectedToGitHub: boolean = container.notebookManager?.gitHubOAuthService.isLoggedIn();
|
const connectedToGitHub: boolean = container.notebookManager?.gitHubOAuthService.isLoggedIn();
|
||||||
const label = connectedToGitHub ? "Manage GitHub settings" : "Connect to GitHub";
|
const label = connectedToGitHub ? "Manage GitHub settings" : "Connect to GitHub";
|
||||||
|
const junoClient = new JunoClient();
|
||||||
return {
|
return {
|
||||||
iconSrc: GitHubIcon,
|
iconSrc: GitHubIcon,
|
||||||
iconAlt: label,
|
iconAlt: label,
|
||||||
|
@ -568,7 +570,11 @@ function createManageGitHubAccountButton(container: Explorer): CommandButtonComp
|
||||||
.getState()
|
.getState()
|
||||||
.openSidePanel(
|
.openSidePanel(
|
||||||
label,
|
label,
|
||||||
<GitHubReposPanel explorer={container} gitHubClientProp={container.notebookManager.gitHubClient} />
|
<GitHubReposPanel
|
||||||
|
explorer={container}
|
||||||
|
gitHubClientProp={container.notebookManager.gitHubClient}
|
||||||
|
junoClientProp={junoClient}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
commandButtonLabel: label,
|
commandButtonLabel: label,
|
||||||
hasPopup: false,
|
hasPopup: false,
|
||||||
|
|
|
@ -89,16 +89,18 @@ export default class NotebookManager {
|
||||||
this.gitHubClient.setToken(token?.access_token);
|
this.gitHubClient.setToken(token?.access_token);
|
||||||
if (this?.gitHubOAuthService.isLoggedIn()) {
|
if (this?.gitHubOAuthService.isLoggedIn()) {
|
||||||
useSidePanel.getState().closeSidePanel();
|
useSidePanel.getState().closeSidePanel();
|
||||||
useSidePanel
|
setTimeout(() => {
|
||||||
.getState()
|
useSidePanel
|
||||||
.openSidePanel(
|
.getState()
|
||||||
"Manage GitHub settings",
|
.openSidePanel(
|
||||||
<GitHubReposPanel
|
"Manage GitHub settings",
|
||||||
explorer={this.params.container}
|
<GitHubReposPanel
|
||||||
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
explorer={this.params.container}
|
||||||
junoClientProp={this.junoClient}
|
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
||||||
/>
|
junoClientProp={this.junoClient}
|
||||||
);
|
/>
|
||||||
|
);
|
||||||
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.params.refreshCommandBarButtons();
|
this.params.refreshCommandBarButtons();
|
||||||
|
@ -179,6 +181,7 @@ export default class NotebookManager {
|
||||||
<GitHubReposPanel
|
<GitHubReposPanel
|
||||||
explorer={this.params.container}
|
explorer={this.params.container}
|
||||||
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
||||||
|
junoClientProp={this.junoClient}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
"Cancel",
|
"Cancel",
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { PanelLoadingScreen } from "../PanelLoadingScreen";
|
||||||
interface IGitHubReposPanelProps {
|
interface IGitHubReposPanelProps {
|
||||||
explorer: Explorer;
|
explorer: Explorer;
|
||||||
gitHubClientProp: GitHubClient;
|
gitHubClientProp: GitHubClient;
|
||||||
junoClientProp?: JunoClient;
|
junoClientProp: JunoClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IGitHubReposPanelState {
|
interface IGitHubReposPanelState {
|
||||||
|
@ -120,6 +120,7 @@ export class GitHubReposPanel extends React.Component<IGitHubReposPanelProps, IG
|
||||||
handleError(error, "GitHubReposPane/submit", "Failed to save pinned repos");
|
handleError(error, "GitHubReposPane/submit", "Failed to save pinned repos");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
useSidePanel.getState().closeSidePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetData(): void {
|
public resetData(): void {
|
||||||
|
@ -144,11 +145,18 @@ export class GitHubReposPanel extends React.Component<IGitHubReposPanelProps, IG
|
||||||
|
|
||||||
private setup(forceShowConnectToGitHub = false): void {
|
private setup(forceShowConnectToGitHub = false): void {
|
||||||
forceShowConnectToGitHub || !this.props.explorer.notebookManager?.gitHubOAuthService.isLoggedIn()
|
forceShowConnectToGitHub || !this.props.explorer.notebookManager?.gitHubOAuthService.isLoggedIn()
|
||||||
? this.setupForConnectToGitHub()
|
? this.setupForConnectToGitHub(forceShowConnectToGitHub)
|
||||||
: this.setupForManageRepos();
|
: this.setupForManageRepos();
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupForConnectToGitHub(): void {
|
private setupForConnectToGitHub(forceShowConnectToGitHub: boolean): void {
|
||||||
|
if (forceShowConnectToGitHub) {
|
||||||
|
const newState = { ...this.state.gitHubReposState };
|
||||||
|
newState.showAuthorizeAccess = forceShowConnectToGitHub;
|
||||||
|
this.setState({
|
||||||
|
gitHubReposState: newState,
|
||||||
|
});
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isExecuting: false,
|
isExecuting: false,
|
||||||
});
|
});
|
||||||
|
@ -368,46 +376,28 @@ export class GitHubReposPanel extends React.Component<IGitHubReposPanelProps, IG
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
loadMore: (): Promise<void> => this.loadMoreBranches(item.repo),
|
loadMore: (): Promise<void> => this.loadMoreBranches(item.repo),
|
||||||
};
|
};
|
||||||
this.setState({
|
|
||||||
gitHubReposState: {
|
|
||||||
...this.state.gitHubReposState,
|
|
||||||
reposListProps: {
|
|
||||||
...this.state.gitHubReposState.reposListProps,
|
|
||||||
branchesProps: {
|
|
||||||
...this.state.gitHubReposState.reposListProps.branchesProps,
|
|
||||||
[GitHubUtils.toRepoFullName(item.repo.owner, item.repo.name)]: this.branchesProps[item.key],
|
|
||||||
},
|
|
||||||
pinnedReposProps: {
|
|
||||||
repos: this.pinnedReposProps.repos,
|
|
||||||
},
|
|
||||||
unpinnedReposProps: {
|
|
||||||
...this.state.gitHubReposState.reposListProps.unpinnedReposProps,
|
|
||||||
repos: this.unpinnedReposProps.repos,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
this.loadMoreBranches(item.repo);
|
this.loadMoreBranches(item.repo);
|
||||||
} else {
|
|
||||||
if (this.isAddedRepo === false) {
|
|
||||||
this.setState({
|
|
||||||
gitHubReposState: {
|
|
||||||
...this.state.gitHubReposState,
|
|
||||||
reposListProps: {
|
|
||||||
...this.state.gitHubReposState.reposListProps,
|
|
||||||
pinnedReposProps: {
|
|
||||||
repos: this.pinnedReposProps.repos,
|
|
||||||
},
|
|
||||||
unpinnedReposProps: {
|
|
||||||
...this.state.gitHubReposState.reposListProps.unpinnedReposProps,
|
|
||||||
repos: this.unpinnedReposProps.repos,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
gitHubReposState: {
|
||||||
|
...this.state.gitHubReposState,
|
||||||
|
reposListProps: {
|
||||||
|
...this.state.gitHubReposState.reposListProps,
|
||||||
|
branchesProps: {
|
||||||
|
...this.branchesProps,
|
||||||
|
},
|
||||||
|
pinnedReposProps: {
|
||||||
|
repos: this.pinnedReposProps.repos,
|
||||||
|
},
|
||||||
|
unpinnedReposProps: {
|
||||||
|
...this.state.gitHubReposState.reposListProps.unpinnedReposProps,
|
||||||
|
repos: this.unpinnedReposProps.repos,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
this.isAddedRepo = false;
|
this.isAddedRepo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,15 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
"gitHubOAuthService": GitHubOAuthService {
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
|
"token": [Function],
|
||||||
|
},
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
||||||
|
|
|
@ -21,6 +21,15 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||||
"resourceTree": ResourceTreeAdapter {
|
"resourceTree": ResourceTreeAdapter {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
"copyNotebook": [Function],
|
"copyNotebook": [Function],
|
||||||
|
"gitHubOAuthService": GitHubOAuthService {
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
|
"token": [Function],
|
||||||
|
},
|
||||||
|
"junoClient": JunoClient {
|
||||||
|
"cachedPinnedRepos": [Function],
|
||||||
|
},
|
||||||
"parameters": [Function],
|
"parameters": [Function],
|
||||||
},
|
},
|
||||||
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
"resourceTreeForResourceToken": ResourceTreeAdapterForResourceToken {
|
||||||
|
|
|
@ -16,9 +16,10 @@ import { Areas } from "../../Common/Constants";
|
||||||
import { isPublicInternetAccessAllowed } from "../../Common/DatabaseAccountUtility";
|
import { isPublicInternetAccessAllowed } from "../../Common/DatabaseAccountUtility";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
|
import { GitHubOAuthService } from "../../GitHub/GitHubOAuthService";
|
||||||
import { useSidePanel } from "../../hooks/useSidePanel";
|
import { useSidePanel } from "../../hooks/useSidePanel";
|
||||||
import { useTabs } from "../../hooks/useTabs";
|
import { useTabs } from "../../hooks/useTabs";
|
||||||
import { IPinnedRepo } from "../../Juno/JunoClient";
|
import { IPinnedRepo, JunoClient } from "../../Juno/JunoClient";
|
||||||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
||||||
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
@ -55,6 +56,8 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
||||||
public galleryContentRoot: NotebookContentItem;
|
public galleryContentRoot: NotebookContentItem;
|
||||||
public myNotebooksContentRoot: NotebookContentItem;
|
public myNotebooksContentRoot: NotebookContentItem;
|
||||||
public gitHubNotebooksContentRoot: NotebookContentItem;
|
public gitHubNotebooksContentRoot: NotebookContentItem;
|
||||||
|
public junoClient: JunoClient;
|
||||||
|
public gitHubOAuthService: GitHubOAuthService;
|
||||||
|
|
||||||
public constructor(private container: Explorer) {
|
public constructor(private container: Explorer) {
|
||||||
this.parameters = ko.observable(Date.now());
|
this.parameters = ko.observable(Date.now());
|
||||||
|
@ -71,6 +74,8 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
||||||
|
|
||||||
useDatabases.subscribe(() => this.triggerRender());
|
useDatabases.subscribe(() => this.triggerRender());
|
||||||
this.triggerRender();
|
this.triggerRender();
|
||||||
|
this.junoClient = new JunoClient();
|
||||||
|
this.gitHubOAuthService = new GitHubOAuthService(this.junoClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
private traceMyNotebookTreeInfo() {
|
private traceMyNotebookTreeInfo() {
|
||||||
|
@ -634,6 +639,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
||||||
<GitHubReposPanel
|
<GitHubReposPanel
|
||||||
explorer={this.container}
|
explorer={this.container}
|
||||||
gitHubClientProp={this.container.notebookManager.gitHubClient}
|
gitHubClientProp={this.container.notebookManager.gitHubClient}
|
||||||
|
junoClientProp={this.junoClient}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue