diff --git a/package.json b/package.json
index e51572a01d..dbd458eb53 100644
--- a/package.json
+++ b/package.json
@@ -81,6 +81,7 @@
"serve-favicon": "^2.4.3",
"superagent": "^3.8.2",
"superagent-bluebird-promise": "^4.1.0",
+ "uuid": "^3.3.2",
"validator": "^9.1.2"
},
"devDependencies": {
diff --git a/scripts/build-client-js.sh b/scripts/build-client-js.sh
index afcbf26811..fce55f6506 100755
--- a/scripts/build-client-js.sh
+++ b/scripts/build-client-js.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
+pushd static/js
+mkdir -p editor entity import-entity
+popd
pushd src/client/controllers
cross-env BABEL_ENV="browser" browserify -t [babelify] \
../entity-editor/controller.js \
@@ -7,23 +10,29 @@ cross-env BABEL_ENV="browser" browserify -t [babelify] \
editor/achievement.js \
editor/editor.js \
entity/entity.js \
+ import-entity/import-entity.js \
deletion.js \
index.js \
registrationDetails.js \
revision.js \
search.js \
statistics.js \
+ import-entity/recent-imports.js \
+ import-entity/discard-import-entity.js \
-p [ factor-bundle \
-o ../../../static/js/entity-editor.js \
-o ../../../static/js/editor/edit.js \
-o ../../../static/js/editor/achievement.js \
-o ../../../static/js/editor/editor.js \
-o ../../../static/js/entity/entity.js \
+ -o ../../../static/js/import-entity/import-entity.js \
-o ../../../static/js/deletion.js \
-o ../../../static/js/index.js \
-o ../../../static/js/registrationDetails.js \
-o ../../../static/js/revision.js \
-o ../../../static/js/search.js \
-o ../../../static/js/statistics.js \
+ -o ../../../static/js/import-entity/recent-imports.js \
+ -o ../../../static/js/import-entity/discard-import-entity.js \
] > ../../../static/js/bundle.js
popd
diff --git a/scripts/watch-client-js.sh b/scripts/watch-client-js.sh
index e985025705..562a1a24fc 100755
--- a/scripts/watch-client-js.sh
+++ b/scripts/watch-client-js.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
+pushd static/js
+mkdir -p editor entity import-entity
+popd
pushd src/client/controllers
cross-env BABEL_ENV="browser" watchify -t [babelify] \
../entity-editor/controller.js \
@@ -7,23 +10,29 @@ cross-env BABEL_ENV="browser" watchify -t [babelify] \
editor/achievement.js \
editor/editor.js \
entity/entity.js \
+ import-entity/import-entity.js \
deletion.js \
index.js \
registrationDetails.js \
revision.js \
search.js \
statistics.js \
+ import-entity/recent-imports.js \
+ import-entity/discard-import-entity.js \
-p [ factor-bundle \
-o ../../../static/js/entity-editor.js \
-o ../../../static/js/editor/edit.js \
-o ../../../static/js/editor/achievement.js \
-o ../../../static/js/editor/editor.js \
-o ../../../static/js/entity/entity.js \
+ -o ../../../static/js/import-entity/import-entity.js \
-o ../../../static/js/deletion.js \
-o ../../../static/js/index.js \
-o ../../../static/js/registrationDetails.js \
-o ../../../static/js/revision.js \
-o ../../../static/js/search.js \
-o ../../../static/js/statistics.js \
+ -o ../../../static/js/import-entity/recent-imports.js \
+ -o ../../../static/js/import-entity/discard-import-entity.js \
] -o ../../../static/js/bundle.js -dv
popd
diff --git a/src/client/components/pages/entities/creator.js b/src/client/components/pages/entities/creator.js
index e59d3aa6f4..2f51797480 100644
--- a/src/client/components/pages/entities/creator.js
+++ b/src/client/components/pages/entities/creator.js
@@ -31,7 +31,7 @@ const {extractAttribute, getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;
-function CreatorAttributes({creator}) {
+export function CreatorAttributes({creator}) {
const type = getTypeAttribute(creator.creatorType).data;
const gender = extractAttribute(creator.gender, 'name');
const beginArea = extractAttribute(creator.beginArea, 'name');
diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js
index 37588e03ea..e61e9e1002 100644
--- a/src/client/components/pages/entities/edition.js
+++ b/src/client/components/pages/entities/edition.js
@@ -34,7 +34,7 @@ const {
} = entityHelper;
const {Col, Row} = bootstrap;
-function EditionAttributes({edition}) {
+export function EditionAttributes({edition}) {
const status = extractAttribute(edition.editionStatus, 'label');
const format = extractAttribute(edition.editionFormat, 'label');
const pageCount = extractAttribute(edition.pages);
diff --git a/src/client/components/pages/entities/image.js b/src/client/components/pages/entities/image.js
index 8024a1bc6f..7db045efe9 100644
--- a/src/client/components/pages/entities/image.js
+++ b/src/client/components/pages/entities/image.js
@@ -46,8 +46,12 @@ function EntityImage({backupIcon, imageUrl}) {
}
EntityImage.displayName = 'EntityImage';
EntityImage.propTypes = {
- backupIcon: PropTypes.string.isRequired,
- imageUrl: PropTypes.string.isRequired
+ backupIcon: PropTypes.string,
+ imageUrl: PropTypes.string
+};
+EntityImage.defaultProps = {
+ backupIcon: '',
+ imageUrl: ''
};
export default EntityImage;
diff --git a/src/client/components/pages/entities/publication.js b/src/client/components/pages/entities/publication.js
index 455a177e64..e46a5f9d35 100644
--- a/src/client/components/pages/entities/publication.js
+++ b/src/client/components/pages/entities/publication.js
@@ -31,7 +31,7 @@ import React from 'react';
const {getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;
-function PublicationAttributes({publication}) {
+export function PublicationAttributes({publication}) {
const type = getTypeAttribute(publication.publicationType).data;
return (
diff --git a/src/client/components/pages/entities/publisher.js b/src/client/components/pages/entities/publisher.js
index 799a23f8d9..4ea209a1da 100644
--- a/src/client/components/pages/entities/publisher.js
+++ b/src/client/components/pages/entities/publisher.js
@@ -33,7 +33,7 @@ import React from 'react';
const {extractAttribute, getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;
-function PublisherAttributes({publisher}) {
+export function PublisherAttributes({publisher}) {
const type = getTypeAttribute(publisher.publisherType).data;
const area = extractAttribute(publisher.area, 'name');
const beginDate = extractAttribute(publisher.beginDate);
diff --git a/src/client/components/pages/entities/relationships.js b/src/client/components/pages/entities/relationships.js
index 7d76ef4667..1d1432fc0c 100644
--- a/src/client/components/pages/entities/relationships.js
+++ b/src/client/components/pages/entities/relationships.js
@@ -41,7 +41,10 @@ function EntityRelationships({relationships}) {
}
EntityRelationships.displayName = 'EntityRelationships';
EntityRelationships.propTypes = {
- relationships: PropTypes.array.isRequired
+ relationships: PropTypes.array
+};
+EntityRelationships.defaultProps = {
+ relationships: []
};
export default EntityRelationships;
diff --git a/src/client/components/pages/entities/work.js b/src/client/components/pages/entities/work.js
index 08a8e9842b..d84cac81e1 100644
--- a/src/client/components/pages/entities/work.js
+++ b/src/client/components/pages/entities/work.js
@@ -33,7 +33,7 @@ const {getLanguageAttribute, getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;
-function WorkAttributes({work}) {
+export function WorkAttributes({work}) {
const type = getTypeAttribute(work.workType).data;
const languages = getLanguageAttribute(work).data;
diff --git a/src/client/components/pages/import-entities/creator.js b/src/client/components/pages/import-entities/creator.js
new file mode 100644
index 0000000000..fbc110c072
--- /dev/null
+++ b/src/client/components/pages/import-entities/creator.js
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+
+import {CreatorAttributes} from '../entities/creator';
+import EntityImage from '../entities/image';
+import EntityLinks from '../entities/links';
+import ImportFooter from './footer';
+import ImportTitle from './title';
+import PropTypes from 'prop-types';
+import React from 'react';
+import _ from 'lodash';
+
+
+const {getImportUrl} = importHelper;
+const {Alert, Col, Row} = bootstrap;
+
+
+function ImportCreatorDisplayPage({importEntity, identifierTypes}) {
+ const urlPrefix = getImportUrl(importEntity);
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {`This ${_.startCase(importEntity.type.toLowerCase())} `}
+ {'has been automatically added. Kindly approve/discard it '}
+ {'to help us improve our data.'}
+
+
+
+
+ );
+}
+ImportCreatorDisplayPage.displayName = 'ImportCreatorDisplayPage';
+ImportCreatorDisplayPage.propTypes = {
+ identifierTypes: PropTypes.array,
+ importEntity: PropTypes.object.isRequired
+};
+ImportCreatorDisplayPage.defaultProps = {
+ identifierTypes: []
+};
+
+export default ImportCreatorDisplayPage;
diff --git a/src/client/components/pages/import-entities/discard-import-entity.js b/src/client/components/pages/import-entities/discard-import-entity.js
new file mode 100644
index 0000000000..f7e8700b90
--- /dev/null
+++ b/src/client/components/pages/import-entities/discard-import-entity.js
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import {
+ getImportDiscardUrl, getImportUrl
+} from '../../../helpers/import-entity';
+import LoadingSpinner from '../../loading-spinner';
+import PropTypes from 'prop-types';
+import React from 'react';
+import request from 'superagent-bluebird-promise';
+
+
+const {Alert, Button, ButtonGroup, Col, Panel, Row} = bootstrap;
+
+class DiscardImportEntity extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ error: null,
+ waiting: false
+ };
+
+ this.handleClick = this.handleClick.bind(this);
+ }
+
+ handleClick() {
+ event.preventDefault();
+
+ this.setState({
+ error: null,
+ waiting: true
+ });
+
+ const discardUrl = getImportDiscardUrl(this.props.importEntity);
+ const importUrl = getImportUrl(this.props.importEntity);
+
+ request.post(discardUrl)
+ .then(() => {
+ window.location.href = importUrl;
+ })
+ .catch((res) => {
+ const {error} = res.body;
+
+ this.setState({
+ error,
+ waiting: false
+ });
+ });
+ }
+
+ render() {
+ const {importEntity} = this.props;
+
+ let errorComponent = null;
+ if (this.state.error) {
+ errorComponent =
+ {this.state.error};
+ }
+
+ const loadingComponent = this.state.waiting ? : null;
+
+ const headerComponent =
+ {errorComponent}
+
+ We really appreciate your efforts in helping us
+ improve our database. The {importEntity.type}
+ {entityName}
+ has been automatically added to
+ our records and will be permanently deleted in
+ case multiple editors find it to be corrupt.
+ If you’re sure that the {importEntity.type}
+ {entityName}
+ should be discarded, please press the confirm
+ button below. Other wise click cancel to get back
+ to the imported entity page.
+
+
+
+
+
+
+
+
+ );
+ }
+}
+
+DiscardImportEntity.displayName = 'DiscardImportEntity';
+DiscardImportEntity.propTypes = {
+ importEntity: PropTypes.object.isRequired
+};
+
+export default DiscardImportEntity;
diff --git a/src/client/components/pages/import-entities/edition.js b/src/client/components/pages/import-entities/edition.js
new file mode 100644
index 0000000000..e2f6dd696d
--- /dev/null
+++ b/src/client/components/pages/import-entities/edition.js
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+
+import {EditionAttributes} from '../entities/edition';
+import EntityImage from '../entities/image';
+import EntityLinks from '../entities/links';
+import ImportFooter from './footer';
+import ImportTitle from './title';
+import PropTypes from 'prop-types';
+import React from 'react';
+import _ from 'lodash';
+
+
+const {getImportUrl} = importHelper;
+
+const {Alert, Col, Row} = bootstrap;
+
+
+function ImportEditionDisplayPage({importEntity, identifierTypes}) {
+ const urlPrefix = getImportUrl(importEntity);
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {`This ${_.startCase(importEntity.type.toLowerCase())} `}
+ {'has been automatically added. Kindly approve/discard it '}
+ {'to help us improve our data.'}
+
+
+
+
+ );
+}
+ImportEditionDisplayPage.displayName = 'ImportEditionDisplayPage';
+ImportEditionDisplayPage.propTypes = {
+ identifierTypes: PropTypes.array,
+ importEntity: PropTypes.object.isRequired
+};
+ImportEditionDisplayPage.defaultProps = {
+ identifierTypes: []
+};
+
+export default ImportEditionDisplayPage;
diff --git a/src/client/components/pages/import-entities/footer.js b/src/client/components/pages/import-entities/footer.js
new file mode 100644
index 0000000000..20e9baa446
--- /dev/null
+++ b/src/client/components/pages/import-entities/footer.js
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as utilsHelper from '../../../helpers/utils';
+
+import Icon from 'react-fontawesome';
+import PropTypes from 'prop-types';
+import React from 'react';
+
+
+const {formatDate} = utilsHelper;
+const {
+ Button, ButtonGroup, Col, Row, Tooltip
+} = bootstrap;
+
+function ImportFooter({importUrl, importedAt, source, hasVoted}) {
+ const tooltip = (
+
+ You can only vote once to discard an import.
+
+ );
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
Imported at
+
{formatDate(new Date(importedAt))}
+
+
+
Source
+
{source}
+
+
+
+ );
+}
+ImportFooter.displayName = 'ImportFooter';
+ImportFooter.propTypes = {
+ hasVoted: PropTypes.bool.isRequired,
+ importUrl: PropTypes.string.isRequired,
+ importedAt: PropTypes.string.isRequired,
+ source: PropTypes.string.isRequired
+};
+
+export default ImportFooter;
diff --git a/src/client/components/pages/import-entities/index.js b/src/client/components/pages/import-entities/index.js
new file mode 100644
index 0000000000..448b67b3ba
--- /dev/null
+++ b/src/client/components/pages/import-entities/index.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import Creator from './creator';
+import DiscardImportEntityPage from './discard-import-entity';
+import Edition from './edition';
+import Publication from './publication';
+import Publisher from './publisher';
+import Work from './work';
+
+
+const importEntityPages = {
+ Creator,
+ DiscardImportEntityPage,
+ Edition,
+ Publication,
+ Publisher,
+ Work
+};
+
+export default importEntityPages;
diff --git a/src/client/components/pages/import-entities/publication.js b/src/client/components/pages/import-entities/publication.js
new file mode 100644
index 0000000000..ca3b5c5f76
--- /dev/null
+++ b/src/client/components/pages/import-entities/publication.js
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+
+import EntityImage from '../entities/image';
+import EntityLinks from '../entities/links';
+import ImportFooter from './footer';
+import ImportTitle from './title';
+import PropTypes from 'prop-types';
+import {PublicationAttributes} from '../entities/publication';
+import React from 'react';
+import _ from 'lodash';
+
+
+const {getImportUrl} = importHelper;
+const {Alert, Col, Row} = bootstrap;
+
+
+function ImportPublicationDisplayPage({importEntity, identifierTypes}) {
+ const urlPrefix = getImportUrl(importEntity);
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {`This ${_.startCase(importEntity.type.toLowerCase())} `}
+ {'has been automatically added. Kindly approve/discard it '}
+ {'to help us improve our data.'}
+
+
+
+
+ );
+}
+ImportPublicationDisplayPage.displayName = 'ImportPublicationDisplayPage';
+ImportPublicationDisplayPage.propTypes = {
+ identifierTypes: PropTypes.array,
+ importEntity: PropTypes.object.isRequired
+};
+ImportPublicationDisplayPage.defaultProps = {
+ identifierTypes: []
+};
+
+export default ImportPublicationDisplayPage;
diff --git a/src/client/components/pages/import-entities/publisher.js b/src/client/components/pages/import-entities/publisher.js
new file mode 100644
index 0000000000..4b7369e2b5
--- /dev/null
+++ b/src/client/components/pages/import-entities/publisher.js
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+
+import EntityImage from '../entities/image';
+import EntityLinks from '../entities/links';
+import ImportFooter from './footer';
+import ImportTitle from './title';
+import PropTypes from 'prop-types';
+import {PublisherAttributes} from '../entities/publisher';
+import React from 'react';
+import _ from 'lodash';
+
+
+const {getImportUrl} = importHelper;
+
+const {Alert, Col, Row} = bootstrap;
+
+
+function ImportPublisherDisplayPage({importEntity, identifierTypes}) {
+ const urlPrefix = getImportUrl(importEntity);
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {`This ${_.startCase(importEntity.type.toLowerCase())} `}
+ {'has been automatically added. Kindly approve/discard it '}
+ {'to help us improve our data.'}
+
+
+
+
+ );
+}
+ImportPublisherDisplayPage.displayName = 'ImportPublisherDisplayPage';
+ImportPublisherDisplayPage.propTypes = {
+ identifierTypes: PropTypes.array,
+ importEntity: PropTypes.object.isRequired
+};
+ImportPublisherDisplayPage.defaultProps = {
+ identifierTypes: []
+};
+
+export default ImportPublisherDisplayPage;
diff --git a/src/client/components/pages/import-entities/recent-imports.js b/src/client/components/pages/import-entities/recent-imports.js
new file mode 100644
index 0000000000..8951994c8f
--- /dev/null
+++ b/src/client/components/pages/import-entities/recent-imports.js
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import PaginationProps from '../../../helpers/pagination-props';
+import PropTypes from 'prop-types';
+import React from 'react';
+import RecentImportsTable from '../parts/recent-import-results';
+import request from 'superagent-bluebird-promise';
+
+
+const {PageHeader, Pagination} = bootstrap;
+
+class RecentImports extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.paginationPropsGenerator = PaginationProps({
+ displayedPagesRange: 10,
+ itemsPerPage: props.limit
+ });
+
+ this.state = {
+ currentPage: props.currentPage,
+ offset: 0,
+ paginationProps: {
+ hasBeginningPage: false,
+ hasEndPage: false,
+ hasNextPage: false,
+ hasPreviousPage: false,
+ totalPages: 0
+ },
+ recentImports: []
+ };
+
+ this.handleClick = this.handleClick.bind(this);
+ }
+
+ componentDidMount() {
+ this.handleClick(this.state.currentPage);
+ }
+
+ componentDidUpdate() {
+ window.history.replaceState(
+ null, null, `?page=${this.state.currentPage}`
+ );
+ }
+
+ async handleClick(pageNumber) {
+ const {currentPage, limit, offset, totalResults, recentImports} =
+ await request.get(`/imports/recent/raw?page=${pageNumber}`)
+ .then((res) => JSON.parse(res.text));
+
+ const paginationProps = this.paginationPropsGenerator(
+ totalResults, currentPage
+ );
+
+ this.setState({
+ currentPage, limit, offset, paginationProps, recentImports,
+ totalResults
+ });
+ }
+
+ render() {
+ const {currentPage, limit, totalResults, paginationProps} = this.state;
+ return (
+
+ Recent Imports
+
The following data has been imported recently.
+
+
{`Displaying ${limit} of ${totalResults} results`}
+
+
+ );
+ }
+}
+
+RecentImports.displayName = 'RecentImports';
+RecentImports.propTypes = {
+ currentPage: PropTypes.number,
+ limit: PropTypes.number
+};
+RecentImports.defaultProps = {
+ currentPage: 1,
+ limit: 10
+};
+
+export default RecentImports;
+
diff --git a/src/client/components/pages/import-entities/title.js b/src/client/components/pages/import-entities/title.js
new file mode 100644
index 0000000000..f6a967feb1
--- /dev/null
+++ b/src/client/components/pages/import-entities/title.js
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as entityHelper from '../../../helpers/entity';
+import * as importHelper from '../../../helpers/import-entity';
+
+import PropTypes from 'prop-types';
+import React from 'react';
+
+
+const {getEntityDisambiguation} = entityHelper;
+const {getImportLabel} = importHelper;
+
+
+function ImportTitle({importEntity}) {
+ const label = getImportLabel(importEntity);
+ const disambiguation = getEntityDisambiguation(importEntity);
+ return (
+
+
{label}{disambiguation}
+
+
+ );
+}
+ImportTitle.displayName = 'ImportTitle';
+ImportTitle.propTypes = {
+ importEntity: PropTypes.object.isRequired
+};
+
+export default ImportTitle;
diff --git a/src/client/components/pages/import-entities/work.js b/src/client/components/pages/import-entities/work.js
new file mode 100644
index 0000000000..cea74c62c5
--- /dev/null
+++ b/src/client/components/pages/import-entities/work.js
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+
+import EntityImage from '../entities/image';
+import EntityLinks from '../entities/links';
+import ImportFooter from './footer';
+import ImportTitle from './title';
+import PropTypes from 'prop-types';
+import React from 'react';
+import {WorkAttributes} from '../entities/work';
+import _ from 'lodash';
+
+
+const {getImportUrl} = importHelper;
+const {Alert, Col, Row} = bootstrap;
+
+
+function ImportWorkDisplayPage({importEntity, identifierTypes}) {
+ const urlPrefix = getImportUrl(importEntity);
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {`This ${_.startCase(importEntity.type.toLowerCase())} `}
+ {'has been automatically added. Kindly approve/discard it '}
+ {'to help us improve our data.'}
+
+
+
+
+ );
+}
+ImportWorkDisplayPage.displayName = 'ImportWorkDisplayPage';
+ImportWorkDisplayPage.propTypes = {
+ identifierTypes: PropTypes.array,
+ importEntity: PropTypes.object.isRequired
+};
+ImportWorkDisplayPage.defaultProps = {
+ identifierTypes: []
+};
+
+export default ImportWorkDisplayPage;
diff --git a/src/client/components/pages/parts/recent-import-results.js b/src/client/components/pages/parts/recent-import-results.js
new file mode 100644
index 0000000000..184a1c003e
--- /dev/null
+++ b/src/client/components/pages/parts/recent-import-results.js
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018 Shivam Tripathi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import * as bootstrap from 'react-bootstrap';
+import * as importHelper from '../../../helpers/import-entity';
+import * as utilsHelper from '../../../helpers/utils';
+import PropTypes from 'prop-types';
+import React from 'react';
+
+
+const {formatDate} = utilsHelper;
+const {getImportUrl} = importHelper;
+const {Table} = bootstrap;
+
+/**
+ * Renders the document and displays the recentImports table.
+ * @returns {ReactElement} a HTML document which displays the recentImports
+ */
+
+function RecentImportsTable(props) {
+ const {offset, recentImports} = props;
+ return (
+
);
diff --git a/src/client/components/pages/search.js b/src/client/components/pages/search.js
index 1031aac9a5..aad7b0ba81 100644
--- a/src/client/components/pages/search.js
+++ b/src/client/components/pages/search.js
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Ohm Patel
* 2016 Sean Burke
+ * 2018 Shivam Tripathi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -68,6 +69,12 @@ class SearchPage extends React.Component {
+
+
+ Entries marked in red have been automatically imported.
+ Kindly review them to make them a part of our BookBrainz
+ database.
+