export function urlToTree(repo: string, rev: ?string, path: string | string[]): string { rev = rev || ""; // Fast-path: we redirect the tree root to the repo route anyway, so just construct // the repo route URL directly. if (!path || path === "/" || path.length === 0) return urlToRepoRev(repo, rev); const pathStr = typeof path === "string" ? path : path.join("/"); return urlTo("tree", {splat: [makeRepoRev(repo, rev), pathStr]}); }
(path, component, i, isLast) => ( isLast && !this.props.disabledLink ? <Link to={this.props.rev ? urlToRepoRev(this.props.repo, this.props.rev) : urlToRepo(this.props.repo)} title={trimmedPath} key={i} styleName={isLast ? "active" : "inactive"} onClick={() => this.context.eventLogger.logEvent("RepoClicked", {repoName: trimmedPath})}> {component} </Link> : <span key={i}>{component}</span> ),
render() { const datum = this.props.data[this.state.idx]; let srclibVersions = {}; datum.Sources.forEach((source) => { if (source.SrclibVersion) srclibVersions[source.SrclibVersion] = true; }); const prevDatum = this.state.idx === 0 ? null : this.props.data[this.state.idx - 1]; let prevSummaryIndex = {}; if (prevDatum) { prevDatum.Sources.forEach((source) => { prevSummaryIndex[source.Repo] = source.Summary; }); } return ( <div styleName="drilldown"> <h2 styleName="drilldown-header"> {this.props.language} {Object.keys(srclibVersions).map((ver, i) => <span key={i} styleName="srclib-version">{ver}</span> )} </h2> <div> <Button styleName="day-chooser" size="small" outline={true} onClick={this.prevDay.bind(this)}><TriangleLeftIcon /></Button> <span styleName="day">{datum.Day}</span> <Button styleName="day-chooser" size="small" outline={true} onClick={this.nextDay.bind(this)}><TriangleRightIcon /></Button> <Button styleName="drilldown-dismiss" size="small" outline={true} onClick={this.props.onDismiss}><CloseIcon /></Button> </div> <table styleName="table"> <thead> <tr> <th styleName="repo">Repo</th> <th styleName="idents">Idents</th> <th styleName="refs">Refs (%)</th> <th styleName="defs">Defs (%)</th> </tr> </thead> <tbody> {datum.Sources.map((source, i) => { const summary = source.Summary; const builds = this.state.buildLists.get(source.Repo, this.buildsQuery); const prevSummary = prevSummaryIndex[source.Repo]; const refDelta = prevSummary && summary ? this.refDelta(prevSummary, summary) : ""; const defDelta = prevSummary && summary ? this.defDelta(prevSummary, summary) : ""; return ( <tr key={i}> <td styleName="data"> {builds && builds.length > 0 && <Link to={urlToBuilds(source.Repo)}> <Label color={buildClass(builds[0])} styleName="build-label">{buildStatus(builds[0])}</Label> </Link> } {source.Repo} {this.state.idx === this.props.data.length - 1 && <div styleName="repo-drilldown-icon" size="small" outline={true} onClick={() => this._drilldown(source)}><MagnifyingGlassIcon /></div> } </td> <td styleName="data">{summary ? summary.Idents : "---"}</td> <td styleName="data"> {summary ? this.formatScore(this.refScore(summary)) : "---"} <span styleName={this.deltaStyle(refDelta)}>{refDelta}</span> </td> <td styleName="data"> {summary ? this.formatScore(this.defScore(summary)) : "---"} <span styleName={this.deltaStyle(defDelta)}>{defDelta}</span> </td> </tr> ); })} </tbody> </table> {this.state.drilldown && <Modal onDismiss={() => this._drilldown(null)}> <div styleName="repo-drilldown-modal"> <h3> <Link to={urlToRepoRev(this.state.drilldown.Repo, this.state.drilldown.Rev)}> {this.state.drilldown.Repo}@{this.state.drilldown.Rev} </Link> </h3> {this.getRepoDrilldown()} </div> </Modal>} </div> ); }