mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-28 05:15:27 +00:00
Make PagerankTable props non-nullable (#605)
Historically, `credExplorer/App.js` instantiated a PagerankTable regardless of its state, and would pass null props when the App didn't have data needed to load the table. As of #583, we just don't create the PagerankTable before its data is available, which is a simpler/better contract. As such, the type signature of PagerankTable's props can be simplified, and some logic for handling the null case may be removed. Test plan: `yarn test` passes, which is sufficient.
This commit is contained in:
parent
10f704ebd2
commit
59ac10b612
@ -77,8 +77,8 @@ type SharedProps = {|
|
|||||||
|};
|
|};
|
||||||
|
|
||||||
type PagerankTableProps = {|
|
type PagerankTableProps = {|
|
||||||
+pnd: ?PagerankNodeDecomposition,
|
+pnd: PagerankNodeDecomposition,
|
||||||
+adapters: ?$ReadOnlyArray<DynamicPluginAdapter>,
|
+adapters: $ReadOnlyArray<DynamicPluginAdapter>,
|
||||||
+maxEntriesPerList: number,
|
+maxEntriesPerList: number,
|
||||||
|};
|
|};
|
||||||
type PagerankTableState = {|topLevelFilter: NodeAddressT|};
|
type PagerankTableState = {|topLevelFilter: NodeAddressT|};
|
||||||
@ -92,15 +92,6 @@ export class PagerankTable extends React.PureComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.adapters == null) {
|
|
||||||
return <p>You must load a graph before seeing PageRank analysis.</p>;
|
|
||||||
}
|
|
||||||
if (this.props.pnd == null) {
|
|
||||||
return <p>Please run PageRank to see analysis.</p>;
|
|
||||||
}
|
|
||||||
if (this.props.maxEntriesPerList == null) {
|
|
||||||
throw new Error("maxEntriesPerList not set");
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div style={{marginTop: 10}}>
|
<div style={{marginTop: 10}}>
|
||||||
{this.renderFilterSelect()}
|
{this.renderFilterSelect()}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {shallow} from "enzyme";
|
import {shallow} from "enzyme";
|
||||||
import enzymeToJSON from "enzyme-to-json";
|
|
||||||
|
|
||||||
import type {DynamicPluginAdapter} from "../pluginAdapter";
|
import type {DynamicPluginAdapter} from "../pluginAdapter";
|
||||||
|
|
||||||
@ -175,32 +174,6 @@ describe("app/credExplorer/PagerankTable", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("PagerankTable", () => {
|
describe("PagerankTable", () => {
|
||||||
it("renders expected message with null props", () => {
|
|
||||||
const element = shallow(
|
|
||||||
<PagerankTable pnd={null} adapters={null} maxEntriesPerList={1} />
|
|
||||||
);
|
|
||||||
expect(enzymeToJSON(element)).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
it("renders expected message with just adapters", async () => {
|
|
||||||
const {adapters} = await example();
|
|
||||||
const element = shallow(
|
|
||||||
<PagerankTable pnd={null} adapters={adapters} maxEntriesPerList={1} />
|
|
||||||
);
|
|
||||||
expect(enzymeToJSON(element)).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
it("throws an error if maxEntriesPerList not set", async () => {
|
|
||||||
const {pnd, adapters} = await example();
|
|
||||||
expect(() =>
|
|
||||||
shallow(
|
|
||||||
<PagerankTable
|
|
||||||
pnd={pnd}
|
|
||||||
adapters={adapters}
|
|
||||||
// $ExpectFlowError
|
|
||||||
maxEntriesPerList={null}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
).toThrowError("maxEntriesPerList");
|
|
||||||
});
|
|
||||||
it("renders thead column order properly", async () => {
|
it("renders thead column order properly", async () => {
|
||||||
const {pnd, adapters} = await example();
|
const {pnd, adapters} = await example();
|
||||||
const element = shallow(
|
const element = shallow(
|
||||||
|
@ -66,15 +66,3 @@ Array [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`app/credExplorer/PagerankTable PagerankTable renders expected message with just adapters 1`] = `
|
|
||||||
<p>
|
|
||||||
Please run PageRank to see analysis.
|
|
||||||
</p>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`app/credExplorer/PagerankTable PagerankTable renders expected message with null props 1`] = `
|
|
||||||
<p>
|
|
||||||
You must load a graph before seeing PageRank analysis.
|
|
||||||
</p>
|
|
||||||
`;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user