Create a view-only artifact viewer
Summary: Paired with @dandelionmane. wchargin-branch: create-artifact-viewer
This commit is contained in:
parent
5d042c0008
commit
0c3aa9c7ba
|
@ -0,0 +1,18 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
export type ArtifactNodeID = string;
|
||||||
|
export type ArtifactNodePayload = {|
|
||||||
|
+name: string,
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type NodePayload = ArtifactNodePayload;
|
||||||
|
|
||||||
|
export type ArtifactEdgeID = {|
|
||||||
|
+src: string,
|
||||||
|
+dst: string,
|
||||||
|
|};
|
||||||
|
export type ArtifactEdgePayload = {|
|
||||||
|
+weight: number, // non-negative
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type EdgePayload = ArtifactEdgePayload;
|
|
@ -3,16 +3,35 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {StyleSheet, css} from "aphrodite/no-important";
|
import {StyleSheet, css} from "aphrodite/no-important";
|
||||||
|
|
||||||
|
import {ArtifactList} from "./ArtifactList";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
type State = {};
|
type State = {};
|
||||||
|
|
||||||
export default class App extends React.Component<Props, State> {
|
export default class App extends React.Component<Props, State> {
|
||||||
render() {
|
render() {
|
||||||
|
function createSampleArtifact(name) {
|
||||||
|
const id = name.toLowerCase().replace(/[^a-z]/g, "-");
|
||||||
|
return {
|
||||||
|
address: {
|
||||||
|
repositoryName: "sourcecred/devnull",
|
||||||
|
pluginName: "sourcecred/artifact-beta",
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
payload: {name},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const artifacts = [
|
||||||
|
createSampleArtifact("Root"),
|
||||||
|
createSampleArtifact("Tooling"),
|
||||||
|
createSampleArtifact("Tests"),
|
||||||
|
];
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<header className={css(styles.header)}>
|
<header className={css(styles.header)}>
|
||||||
<h1>Artifact editor</h1>
|
<h1>Artifact editor</h1>
|
||||||
</header>
|
</header>
|
||||||
|
<ArtifactList artifacts={artifacts} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import type {Node} from "../../../core/graph";
|
||||||
|
import type {ArtifactNodePayload} from "../artifactPlugin";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
artifacts: Node<ArtifactNodePayload>[],
|
||||||
|
};
|
||||||
|
type State = {};
|
||||||
|
|
||||||
|
export class ArtifactList extends React.Component<Props, State> {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>Artifacts</h2>
|
||||||
|
<ul>
|
||||||
|
{this.props.artifacts.map((x) => (
|
||||||
|
<li key={x.address.id}>{x.payload.name}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue