Skip to content

Commit

Permalink
Fix white screen on Diff viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasstjerne committed Nov 23, 2021
1 parent a7483e0 commit 719a192
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 51 deletions.
8 changes: 8 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import MetaDataValidator from "./pages/tools/MetaDataValidator";
import NameMatch from "./pages/tools/NameMatch";
import GBIFTaxonomyReview from "./pages/tools/GBIFTaxonomyReview";
import DiffViewer from "./pages/tools/DiffViewer";
import NameUsageSearch from "./pages/NameSearch/Search";

const theme = {
colorPrimary: "deepskyblue",
Expand Down Expand Up @@ -228,6 +229,13 @@ class App extends Component {
path="/dataset"
render={(props) => <DatasetList location={props.location} />}
/>
<Route
exact
key="nameUsageSearch"
path={`/nameusage/search`}
component={NameUsageSearch}
/>

<Route
exact
key="metadatavalidator"
Expand Down
19 changes: 9 additions & 10 deletions src/api/gitVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import axios from "axios";
import config from "../config";

export const getGitVersion = () => {
return axios(`/gitVersion.json`).then(res => res.data)
return axios(`/gitVersion.json`).then((res) => res.data);
};

export const getBackendGitVersion = () => {
return axios(`${config.dataApi}version`).then(res => {
const splitted = res.data.split(' ');
return {
short: splitted[0].trim(),
created: splitted[1].trim()
}
})
};

return axios(`${config.dataApi}version`).then((res) => {
const splitted = res.data.split(" ");
return {
short: splitted[0].trim(),
created: splitted[1].trim(),
};
});
};
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (
) {
env = environments.prod;
} else if (domain.endsWith("localhost")) {
env = environments.dev;
env = environments.prod;
} else {
env = environments.dev;
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/DatasetList/ColumnFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ColumnFilter extends React.Component {
defaultValue={excludeColumns}
onChange={this.handleHideColumnChange}
showSearch
maxTagCount={4}
>
{columns.map((f) => {
return (
Expand Down
98 changes: 98 additions & 0 deletions src/pages/DatasetList/ColumnFilter2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React from "react";

import { Select } from "antd";
const Option = Select.Option;

class ColumnFilter extends React.Component {
constructor(props) {
super(props);
this.state = {
showColumns: [],
};
}

componentDidMount = () => {
this.setColumns(this.props.columns);
};

componentDidUpdate = (nextProps) => {
if (!this.props.columns || this.props.columns.length === 0) {
this.setColumns(nextProps.columns);
}
};
setColumns = (columns) => {
let excludeColumns = JSON.parse(
localStorage.getItem("colplus_datasetlist_hide_columns")
) || [
"creator",
"version",
"confidence",
"editor",
"geographicScope",
"private",
"modified",
"created",
"completeness",
];
// Handle metadata update
if (excludeColumns.includes("organisations")) {
excludeColumns = [
"creator",
"version",
"confidence",
"editor",
"geographicScope",
"private",
"modified",
"created",
"completeness",
];
}

this.setState({
showColumns: columns
.filter((c) => !excludeColumns.includes(c.key))
.map((c) => c.key),
});
};

handleHideColumnChange = (showColumns) => {
const { columns } = this.props;
const excludeColumns = columns
.filter((c) => !showColumns.includes(c.key))
.map((c) => c.key);
localStorage.setItem(
"colplus_datasetlist_hide_columns",
JSON.stringify(excludeColumns)
);
this.setState({ showColumns }, () => {
this.props.onChange(excludeColumns);
});
};

render = () => {
const { showColumns } = this.state;
const { columns } = this.props;
return (
<Select
style={{ width: "100%" }}
mode="multiple"
placeholder="Please select"
value={showColumns}
onChange={this.handleHideColumnChange}
showSearch
maxTagCount={4}
>
{columns.map((f) => {
return (
<Option key={f.key} value={f.key}>
{f.title}
</Option>
);
})}
</Select>
);
};
}

export default ColumnFilter;
90 changes: 60 additions & 30 deletions src/pages/DatasetList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from "react";
import axios from "axios";
import { NavLink } from "react-router-dom";
import { LockOutlined, UnlockOutlined, PlusOutlined } from "@ant-design/icons";
import { Table, Alert, Row, Col, Form, Button } from "antd";
import { Table, Alert, Row, Col, Form, Button, Tooltip } from "antd";
import config from "../../config";
import qs from "query-string";
import Layout from "../../components/LayoutNew";
import moment from "moment";
import history from "../../history";
import Auth from "../../components/Auth";
import SearchBox from "./SearchBox";
import ColumnFilter from "./ColumnFilter";
import ColumnFilter from "./ColumnFilter2";
import DatasetLogo from "./DatasetLogo";
import ImportButton from "../../pages/Imports/importTabs/ImportButton";
import withContext from "../../components/hoc/withContext";
Expand Down Expand Up @@ -92,32 +92,62 @@ class DatasetList extends React.Component {
dataIndex: "creator",
key: "creator",
sorter: true,
ellipsis: {
showTitle: false,
},
render: (text, record) => {
return text && _.isArray(text)
? text.map((t) => t.name).join(", ")
: "";
return text && _.isArray(text) ? (
<Tooltip
placement="topLeft"
title={text.map((t) => t.name).join(", ")}
>
{text.map((t) => t.name).join(", ")}
</Tooltip>
) : (
""
);
},
},
{
title: "Editor",
dataIndex: "editor",
key: "editor",
sorter: true,
ellipsis: {
showTitle: false,
},
render: (text, record) => {
return text && _.isArray(text)
? text.map((t) => t.name).join(", ")
: "";
return text && _.isArray(text) ? (
<Tooltip
placement="topLeft"
title={text.map((t) => t.name).join(", ")}
>
{text.map((t) => t.name).join(", ")}
</Tooltip>
) : (
""
);
},
},
{
title: "Contributor",
dataIndex: "contributor",
key: "contributor",
sorter: true,
ellipsis: {
showTitle: false,
},
render: (text, record) => {
return text && _.isArray(text)
? text.map((t) => t.name).join(", ")
: "";
return text && _.isArray(text) ? (
<Tooltip
placement="topLeft"
title={text.map((t) => t.name).join(", ")}
>
{text.map((t) => t.name).join(", ")}
</Tooltip>
) : (
""
);
},
},
{
Expand Down Expand Up @@ -378,24 +408,24 @@ class DatasetList extends React.Component {
} */
const filteredColumns = isEditorOrAdmin(this.props.user)
? [
...defaultColumns,
{
title: "Action",
dataIndex: "",
width: 60,
key: "__actions__",
render: (text, record) =>
record.origin === "external" &&
...defaultColumns,
{
title: "Action",
dataIndex: "",
width: 60,
key: "__actions__",
render: (text, record) =>
record.origin === "external" &&
canEditDataset(record, this.props.user) ? (
<ImportButton
key={record.key}
record={{ datasetKey: record.key }}
/>
) : (
""
),
},
]
<ImportButton
key={record.key}
record={{ datasetKey: record.key }}
/>
) : (
""
),
},
]
: defaultColumns;

const columns = _.filter(
Expand Down Expand Up @@ -450,10 +480,10 @@ class DatasetList extends React.Component {
<FormItem
style={{ width: "100%" }}
{...formItemLayout}
label="Hidden columns"
label="Show columns"
>
<ColumnFilter
columns={columns}
columns={defaultColumns}
onChange={this.handleColumns}
/>
</FormItem>
Expand Down
13 changes: 13 additions & 0 deletions src/pages/NameSearch/Search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import Layout from "../../components/LayoutNew";
import { withRouter } from "react-router";
import NameSearch from "./index";
const NameUsageSearch = ({ location }) => {
return (
<Layout selectedKeys={"NameUsageSearch"}>
<NameSearch location={location} />
</Layout>
);
};

export default withRouter(NameUsageSearch);
2 changes: 1 addition & 1 deletion src/pages/NameSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class NameSearchPage extends React.Component {
});
const url = datasetKey
? `${config.dataApi}dataset/${datasetKey}/nameusage/search`
: `${config.dataApi}name/search`;
: `${config.dataApi}nameusage/search`;
axios(`${url}?${qs.stringify(newParamsWithPaging)}`)
.then((res) => {
this.setState({
Expand Down
9 changes: 0 additions & 9 deletions src/pages/tools/DiffViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,6 @@ const DiffViewer = ({ location, addError, rank }) => {
<Col flex="auto"></Col>
</Row>
)}
{_.get(this.state, "data") === "" && (
<Row style={{ marginTop: "40px" }}>
<Col flex="auto"></Col>
<Col>
<Empty description="No diff between import attempts" />
</Col>
<Col flex="auto"></Col>
</Row>
)}
</PageContent>
</Layout>
);
Expand Down

0 comments on commit 719a192

Please sign in to comment.