diff --git a/src/app/App.js b/src/app/App.js index 520d320..8bf062d 100644 --- a/src/app/App.js +++ b/src/app/App.js @@ -3,12 +3,10 @@ import React from "react"; import {BrowserRouter as Router, Route, NavLink} from "react-router-dom"; -import ArtifactEditor from "../plugins/artifact/editor/App"; import CredExplorer from "./credExplorer/App"; export default class App extends React.Component<{}> { render() { - const ARTIFACT_EDITOR_ROUTE = "/plugins/artifact/editor"; const CRED_EXPLORER_ROUTE = "/explorer"; return ( @@ -21,16 +19,12 @@ export default class App extends React.Component<{}> {
  • Cred Explorer
  • -
  • - Artifact Editor -

  • -
    ); diff --git a/src/plugins/artifact/artifactPlugin.js b/src/plugins/artifact/artifactPlugin.js deleted file mode 100644 index 2893fad..0000000 --- a/src/plugins/artifact/artifactPlugin.js +++ /dev/null @@ -1,45 +0,0 @@ -// @flow - -import type {Address} from "../../core/address"; -import type {Graph} from "../../core/graph"; - -export const ARTIFACT_PLUGIN_NAME = "sourcecred/artifact-beta"; - -export const ARTIFACT_NODE_TYPE = "ARTIFACT"; -export type ArtifactNodePayload = {| - +name: string, - +description: string, -|}; - -export type NodePayload = ArtifactNodePayload; - -export const INCLUDES_EDGE_TYPE = "INCLUDES"; -export type IncludesEdgePayload = {| - +weight: number, // non-negative -|}; - -export type EdgePayload = IncludesEdgePayload; - -const NON_SLUG_CHARACTER: RegExp = /[^a-z]/g; - -export function artifactAddress( - graph: Graph, - repoOwner: string, - repoName: string, - artifactName: string -): Address { - const baseName = artifactName.toLowerCase().replace(NON_SLUG_CHARACTER, "-"); - const baseId = `${repoOwner}/${repoName}/${baseName}`; - function address(id) { - return { - pluginName: ARTIFACT_PLUGIN_NAME, - id, - type: ARTIFACT_NODE_TYPE, - }; - } - let id = baseId; - for (let i = 0; graph.node(address(id)) != null; i++) { - id = baseId + "-" + i; - } - return address(id); -} diff --git a/src/plugins/artifact/artifactPlugin.test.js b/src/plugins/artifact/artifactPlugin.test.js deleted file mode 100644 index ec39461..0000000 --- a/src/plugins/artifact/artifactPlugin.test.js +++ /dev/null @@ -1,53 +0,0 @@ -// @flow - -import {Graph} from "../../core/graph"; -import {artifactAddress} from "./artifactPlugin"; - -describe("artifactPlugin", () => { - describe("artifactAddress", () => { - it("repositoryName included in id", () => { - const a = artifactAddress( - new Graph(), - "not-sourcecred", - "not-artifact-plugin", - "Sample artifact!" - ); - expect(a.id.startsWith("not-sourcecred/not-artifact-plugin")).toBe(true); - }); - - it("slugifies the artifact name", () => { - const a = artifactAddress( - new Graph(), - "not-sourcecred", - "not-artifact-plugin", - "Sample artifact!" - ); - expect(a.id).toEqual( - "not-sourcecred/not-artifact-plugin/sample-artifact-" - ); - }); - - it("resolves collisions", () => { - const g = new Graph(); - const ids = []; - for (let i = 0; i < 3; i++) { - const a = artifactAddress( - g, - "not-sourcecred", - "not-artifact-plugin", - "Sample artifact!" - ); - ids.push(a.id); - g.addNode({ - address: a, - payload: {name: "Sample artifact!", description: ""}, - }); - } - expect(ids).toEqual([ - "not-sourcecred/not-artifact-plugin/sample-artifact-", - "not-sourcecred/not-artifact-plugin/sample-artifact--0", - "not-sourcecred/not-artifact-plugin/sample-artifact--1", - ]); - }); - }); -}); diff --git a/src/plugins/artifact/editor/App.js b/src/plugins/artifact/editor/App.js deleted file mode 100644 index f98b83b..0000000 --- a/src/plugins/artifact/editor/App.js +++ /dev/null @@ -1,72 +0,0 @@ -// @flow - -import React from "react"; -import {StyleSheet, css} from "aphrodite/no-important"; - -import "./pluginAdapter"; - -import type {Graph, Node} from "../../../core/graph"; -import type {NodePayload as ArtifactNodePayload} from "../artifactPlugin"; -import type {Settings} from "./SettingsConfig"; -import {ArtifactGraphEditor} from "./ArtifactGraphEditor"; -import {ContributionList} from "./ContributionList"; -import {GithubGraphFetcher} from "./GithubGraphFetcher"; -import {SettingsConfig, defaultSettings} from "./SettingsConfig"; -import standardAdapterSet from "./standardAdapterSet"; - -type Props = {}; -type State = { - artifacts: Node[], - githubGraph: ?Graph, - artifactGraph: ?Graph, - settings: Settings, -}; - -export default class App extends React.Component { - constructor() { - super(); - this.state = { - artifacts: [], - githubGraph: null, - artifactGraph: null, - settings: defaultSettings(), - }; - } - - render() { - return ( -
    -
    -

    Artifact editor

    -
    - { - this.setState({settings}); - }} - /> - { - this.setState({githubGraph}); - }} - /> - { - this.setState({artifactGraph}); - }} - /> - -
    - ); - } -} - -const styles = StyleSheet.create({ - header: { - color: "#f0f", - }, -}); diff --git a/src/plugins/artifact/editor/App.test.js b/src/plugins/artifact/editor/App.test.js deleted file mode 100644 index 2cae219..0000000 --- a/src/plugins/artifact/editor/App.test.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; - -require("../../../app/testUtil").configureAphrodite(); - -// Check that PropTypes check out. -it("renders without crashing", () => { - const div = document.createElement("div"); - ReactDOM.render(, div); - ReactDOM.unmountComponentAtNode(div); -}); diff --git a/src/plugins/artifact/editor/ArtifactGraphEditor.js b/src/plugins/artifact/editor/ArtifactGraphEditor.js deleted file mode 100644 index 4034653..0000000 --- a/src/plugins/artifact/editor/ArtifactGraphEditor.js +++ /dev/null @@ -1,124 +0,0 @@ -// @flow - -import React from "react"; - -import type {Node} from "../../../core/graph"; -import type {Settings} from "./SettingsConfig"; -import type {NodePayload} from "../artifactPlugin"; -import {Graph} from "../../../core/graph"; -import {artifactAddress} from "../artifactPlugin"; - -type Props = { - settings: Settings, - onChange: (Graph) => void, -}; -type State = { - graph: Graph, - artifactInProgressName: string, -}; - -export class ArtifactGraphEditor extends React.Component { - constructor() { - super(); - this.state = { - graph: new Graph(), - artifactInProgressName: "", - }; - } - - componentDidMount() { - this.props.onChange(this.state.graph); - } - - addArtifact(name: string): void { - this.setState( - (state) => { - const node: Node = { - address: artifactAddress( - state.graph, - this.props.settings.repoOwner, - this.props.settings.repoName, - name - ), - payload: {name, description: ""}, - }; - return {graph: state.graph.copy().addNode(node)}; - }, - () => { - this.props.onChange(this.state.graph); - } - ); - } - - updateArtifactDescription( - oldArtifactNode: Node, - newDescription: string - ): void { - this.setState( - (state) => ({ - graph: state.graph - .copy() - .removeNode(oldArtifactNode.address) - .addNode({ - address: oldArtifactNode.address, - payload: { - name: oldArtifactNode.payload.name, - description: newDescription, - }, - }), - }), - () => { - this.props.onChange(this.state.graph); - } - ); - } - - render() { - return ( -
    -

    Artifacts

    - - - - - - - - - {this.state.graph.nodes().map((x) => ( - - -
    ArtifactDescription
    {x.payload.name} -