Use graphql in GitHubClient and misc fixes (#8)

* Use graphql in GitHubClient

* Replace usage of Array.find with _.find
This commit is contained in:
Tanuj Mittal
2020-06-05 12:22:41 -07:00
committed by GitHub
parent e9d3160b57
commit aa8236666e
24 changed files with 761 additions and 657 deletions

View File

@@ -54,7 +54,8 @@ export class DialogComponent extends React.Component<DialogProps, {}> {
styles: {
title: { fontSize: DIALOG_TITLE_FONT_SIZE, fontWeight: DIALOG_TITLE_FONT_WEIGHT },
subText: { fontSize: DIALOG_SUBTEXT_FONT_SIZE }
}
},
showCloseButton: false
},
modalProps: { isBlocking: this.props.isModal },
minWidth: DIALOG_MIN_WIDTH,

View File

@@ -2,6 +2,7 @@
* React component for Switch Directory
*/
import _ from "underscore";
import * as React from "react";
import { Dropdown, IDropdownOption, IDropdownProps } from "office-ui-fabric-react/lib/Dropdown";
import { Tenant } from "../../../Contracts/DataModels";
@@ -60,7 +61,7 @@ export class DefaultDirectoryDropdownComponent extends React.Component<DefaultDi
return;
}
const selectedDirectory = this.props.directories.find(d => d.tenantId === option.key);
const selectedDirectory = _.find(this.props.directories, d => d.tenantId === option.key);
if (!selectedDirectory) {
return;
}

View File

@@ -1,3 +1,4 @@
import _ from "underscore";
import * as React from "react";
import { DefaultButton, IButtonProps } from "office-ui-fabric-react/lib/Button";
@@ -114,7 +115,7 @@ export class DirectoryListComponent extends React.Component<DirectoryListProps,
}
const buttonElement = e.currentTarget;
const selectedDirectoryId = buttonElement.getElementsByClassName("directoryListItemId")[0].textContent;
const selectedDirectory = this.props.directories.find(d => d.tenantId === selectedDirectoryId);
const selectedDirectory = _.find(this.props.directories, d => d.tenantId === selectedDirectoryId);
this.props.onNewDirectorySelected(selectedDirectory);
};

View File

@@ -93,7 +93,7 @@ export class AddRepoComponent extends React.Component<AddRepoComponentProps, Add
const repo = await this.props.getRepo(repoInfo.owner, repoInfo.repo);
if (repo) {
const item: RepoListItem = {
key: GitHubUtils.toRepoFullName(repo.owner.login, repo.name),
key: GitHubUtils.toRepoFullName(repo.owner, repo.name),
repo,
branches: [
{

View File

@@ -18,7 +18,7 @@ import {
Text
} from "office-ui-fabric-react";
import * as React from "react";
import { IGitHubBranch } from "../../../GitHub/GitHubClient";
import { IGitHubBranch, IGitHubPageInfo } from "../../../GitHub/GitHubClient";
import { GitHubUtils } from "../../../Utils/GitHubUtils";
import { RepoListItem } from "./GitHubReposComponent";
import {
@@ -41,6 +41,7 @@ export interface ReposListComponentProps {
export interface BranchesProps {
branches: IGitHubBranch[];
lastPageInfo?: IGitHubPageInfo;
hasMore: boolean;
isLoading: boolean;
loadMore: () => void;
@@ -139,7 +140,7 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
}
const checkboxProps: ICheckboxProps = {
...ReposListComponent.getCheckboxPropsForLabel(GitHubUtils.toRepoFullName(item.repo.owner.login, item.repo.name)),
...ReposListComponent.getCheckboxPropsForLabel(GitHubUtils.toRepoFullName(item.repo.owner, item.repo.name)),
styles: ReposListCheckboxStyles,
defaultChecked: true,
onChange: () => this.props.unpinRepo(item)
@@ -153,7 +154,7 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
return <></>;
}
const branchesProps = this.props.branchesProps[GitHubUtils.toRepoFullName(item.repo.owner.login, item.repo.name)];
const branchesProps = this.props.branchesProps[GitHubUtils.toRepoFullName(item.repo.owner, item.repo.name)];
const options: IDropdownOption[] = branchesProps.branches.map(branch => ({
key: branch.name,
text: branch.name,
@@ -222,7 +223,7 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
private onRenderPinnedReposBranchesDropdownOption(option: IDropdownOption): JSX.Element {
const item: RepoListItem = option.data;
const branchesProps = this.props.branchesProps[GitHubUtils.toRepoFullName(item.repo.owner.login, item.repo.name)];
const branchesProps = this.props.branchesProps[GitHubUtils.toRepoFullName(item.repo.owner, item.repo.name)];
if (option.index === ReposListComponent.FooterIndex) {
const linkProps: ILinkProps = {
@@ -267,7 +268,7 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
}
const checkboxProps: ICheckboxProps = {
...ReposListComponent.getCheckboxPropsForLabel(GitHubUtils.toRepoFullName(item.repo.owner.login, item.repo.name)),
...ReposListComponent.getCheckboxPropsForLabel(GitHubUtils.toRepoFullName(item.repo.owner, item.repo.name)),
styles: ReposListCheckboxStyles,
onChange: () => {
const repoListItem = { ...item };