Skip to content

Commit

Permalink
Use version_updates.v2.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Sep 13, 2024
1 parent 92a8bda commit eabfd87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
31 changes: 15 additions & 16 deletions src/components/StatusDashboard/version_updates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import React, { useEffect, useState } from "react";
import styles from "./styles.module.css";

export default function VersionUpdates({ onLoad }) {
const [{ collapsed, errored, expanded, errors, queued }, setState] =
const [{ collapsed, expanded, errors, queued }, setState] =
useState({
collapsed: { queued: false, errored: true },
expanded: {},
errored: [],
errors: {},
queued: []
queued: {}
});
const toggleItem = item => () => setState(prev => (
{ ...prev, expanded: { ...prev.expanded, [item]: !prev.expanded[item] } }
Expand All @@ -35,9 +34,9 @@ export default function VersionUpdates({ onLoad }) {
<h3>
Version Updates
{" "}
<span className="badge badge--secondary">{queued.length}</span>
<span className="badge badge--secondary">{Object.keys(queued).length}</span>
{" "}
<span className="badge badge--warning">{errored.length}</span>
<span className="badge badge--warning">{Object.keys(errors).length}</span>
</h3>
</div>
<div className="card__body">
Expand All @@ -47,19 +46,19 @@ export default function VersionUpdates({ onLoad }) {
(collapsed.queued ? styles.collapsed : styles.expanded)
}>
Queued Version Updates{" "}
<span className="badge badge--secondary">{queued.length}</span>
<span className="badge badge--secondary">{Object.keys(queued).length}</span>
</div>
<div className={styles.version_updates_content}
style={collapsed.queued ?
{ display: "none" } :
{ display: "flex", flexDirection: "row" }
}>
{queued.map((item, index) => (
{Object.entries(queued).map(([name, version], index) => (
<div key={index}
style={{ margin: 2 }}
className={`${styles.badge} badge badge--secondary`}>
<Link href={urls.versions.pr.replace("<NAME>", item)}>
{item}
<Link href={urls.versions.pr.replace("<NAME>", name)}>
{`${name} ${version}`}
</Link>
</div>
))}
Expand All @@ -70,29 +69,29 @@ export default function VersionUpdates({ onLoad }) {
(collapsed.errored ? styles.collapsed : styles.expanded)
}>
Errored Version Updates{" "}
<span className="badge badge--warning">{errored.length}</span>
<span className="badge badge--warning">{Object.keys(errors).length}</span>
</div>
<div className={styles.version_updates_content}
style={collapsed.errored ?
{ display: "none" } :
{ display: "flex", flexDirection: "column" }}>
{errored.map((item, index) => (
{Object.entries(errors).map(([name, message], index) => (
<React.Fragment key={index}>
<div className={
styles.errored_item + " " +
(expanded[item] ? styles.expanded : styles.collapsed)}
onClick={toggleItem(item)}>
(expanded[name] ? styles.expanded : styles.collapsed)}
onClick={toggleItem(name)}>
<HoverEllipsis />
<div className={`${styles.badge} badge badge--secondary`}>
{/* Prevent link clicks from expanding/collapsing. */}
<Link onClick={event => event.stopPropagation()}
href={urls.versions.pr.replace("<NAME>", item)}>{item}
href={urls.versions.pr.replace("<NAME>", name)}>{name}
</Link>
</div>
</div>
<div className={styles.errored_item_content}
style={{ display: !expanded[item] && "none" }}>
<pre dangerouslySetInnerHTML={{ __html: errors[item]}} />
style={{ display: !expanded[name] && "none" }}>
<pre dangerouslySetInnerHTML={{ __html: message}} />
</div>
</React.Fragment>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export const urls = {
usage: "https://conda-forge.herokuapp.com/status-monitor/report/travis-ci",
},
versions: {
api: "https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/version_status.json",
pr: "https://github.com/conda-forge/<NAME>-feedstock/blob/main/recipe/meta.yaml",
api: "https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/version_status.v2.json",
pr: "https://github.com/conda-forge/<NAME>-feedstock/tree/main/recipe",
},
schemas: {
"conda-forge.yml":
Expand Down

0 comments on commit eabfd87

Please sign in to comment.