Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give pending entities BBIDs and treat them the same way as regular entities #1136

Open
wants to merge 32 commits into
base: import-entities
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ac090fa
refactor(sql): Merge `import` table into `entity` table
kellnerd Jul 29, 2024
2c5b3ef
refactor(sql): Give import tables and columns more descriptive names
kellnerd Jul 29, 2024
b9fa9fb
chore(sql): Drop pointless foreign key referencing its own column
kellnerd Jul 29, 2024
4953027
refactor(sql): Give the two `import_metadata` BBID columns verbose names
kellnerd Jul 29, 2024
35979ec
chore(sql): Port import schema changes to the migration files
kellnerd Jul 29, 2024
8210c10
refactor(imports): Adapt to the latest schema/ORM changes
kellnerd Aug 19, 2024
13d2ad4
chore(sql): Consistently indent using tabs
kellnerd Aug 22, 2024
66aae22
feat(sql): Combine import views with regular entity views
kellnerd Aug 22, 2024
169704b
fix(sql): Reorder dependent view definitions
kellnerd Aug 22, 2024
e107640
fix: Display pending imports via the regular entity pages
kellnerd Aug 22, 2024
cb6f32e
fix: Hide "Add Edition/Work" buttons and CB modal for imported entities
kellnerd Aug 22, 2024
36a2acb
feat(server): Handle pending imports with standard entity loader
kellnerd Aug 22, 2024
b33b4bc
fix: Show the proper footer for imported entities
kellnerd Aug 22, 2024
be3563d
refactor: Rename `entity.import` prop to `importMetadata`
kellnerd Sep 12, 2024
56aa9d5
feat(server): Load all import metadata
kellnerd Sep 12, 2024
7691a9d
feat(server): Add `/approve` route to regular author router
kellnerd Sep 12, 2024
3541746
refactor(imports): Use rewritten approval function to preserve BBID
kellnerd Oct 28, 2024
1c1376c
refactor(server): Adapt import discard routes for regular entity router
kellnerd Nov 1, 2024
6c4d2b2
feat(server): Error when attempting to approve/discard a regular entity
kellnerd Nov 1, 2024
34c39a5
fix(imports): Also update property name in the client-side controller
kellnerd Nov 1, 2024
ac0212c
fix: Address React property type warning
kellnerd Nov 1, 2024
c7fede4
feat(imports): Link to unified entity routes for recent imports
kellnerd Nov 1, 2024
a9751a5
chore: Make linter happy
kellnerd Nov 1, 2024
9dacdfd
feat(server): Add approve and discard routes to all other entity routers
kellnerd Nov 1, 2024
614e8d4
fix(server): Catch and handle entity editor form submission errors
kellnerd Nov 1, 2024
baf462e
fix: Address more React property type warnings
kellnerd Nov 1, 2024
b2c0577
feat(imports): Allow editing of pending entities ("Edit & Approve")
kellnerd Nov 1, 2024
9dd8b51
fix: Only create a new revision if there are actual changes
kellnerd Nov 2, 2024
b206930
chore(ts): Add a few more ORM types where it is trivially possible
kellnerd Nov 2, 2024
d9830e5
chore: Delete now unused import pages/routes/controllers and utils
kellnerd Nov 2, 2024
163cbfd
Merge branch 'import-entities' into pr/1136
MonkeyDo Nov 19, 2024
f0dbc76
Update yarn lockfile
MonkeyDo Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sql/migrations/import/down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ DROP VIEW IF EXISTS bookbrainz.publisher_import;
DROP VIEW IF EXISTS bookbrainz.series_import;
DROP VIEW IF EXISTS bookbrainz.work_import;

-- Only drop these tables if the database contains no pending imports!
DROP TABLE IF EXISTS bookbrainz.author_import_header;
DROP TABLE IF EXISTS bookbrainz.edition_import_header;
DROP TABLE IF EXISTS bookbrainz.edition_group_import_header;
DROP TABLE IF EXISTS bookbrainz.publisher_import_header;
DROP TABLE IF EXISTS bookbrainz.series_import_header;
DROP TABLE IF EXISTS bookbrainz.work_import_header;
DROP TABLE IF EXISTS bookbrainz.discard_votes;
DROP TABLE IF EXISTS bookbrainz.import_metadata;
DROP TABLE IF EXISTS bookbrainz.external_source;

-- Only drop this column if the database contains no pending imports!
ALTER TABLE entity DROP COLUMN IF EXISTS is_import;

-- Legacy tables from an earlier version of the import schema.
DROP TABLE IF EXISTS bookbrainz.link_import;
DROP TABLE IF EXISTS bookbrainz.origin_source;
DROP TABLE IF EXISTS bookbrainz.import;
Expand Down
327 changes: 249 additions & 78 deletions sql/migrations/import/up.sql

Large diffs are not rendered by default.

508 changes: 273 additions & 235 deletions sql/schemas/bookbrainz.sql

Large diffs are not rendered by default.

51 changes: 32 additions & 19 deletions src/client/components/pages/entities/author.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import EntityRelatedCollections from './related-collections';
import EntityReviews from './cb-review';
import EntityTitle from './title';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import ImportFooter from '../import-entities/footer';
import PropTypes from 'prop-types';
import WikipediaExtract from './wikipedia-extract';
import {kebabCase as _kebabCase} from 'lodash';
Expand All @@ -42,7 +43,7 @@ const {deletedEntityMessage, extractAttribute, getTypeAttribute, getEntityUrl,
ENTITY_TYPE_ICONS, getSortNameOfDefaultAlias, transformISODateForDisplay} = entityHelper;
const {Button, Col, Row} = bootstrap;

export function AuthorAttributes({author}) {
function AuthorAttributes({author}) {
if (author.deleted) {
return deletedEntityMessage;
}
Expand Down Expand Up @@ -130,6 +131,8 @@ function AuthorDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
reviewsRef.current.handleClick();
}, [reviewsRef]);

const {importMetadata} = entity;
const isImport = !entity.revision;
const urlPrefix = getEntityUrl(entity);
const editions = [];
if (entity?.authorCredits) {
Expand Down Expand Up @@ -163,20 +166,21 @@ function AuthorDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
<React.Fragment>
<Row>
<Col lg={8}>
<EditionTable editions={editions} entity={entity}/>
<EditionTable editions={editions} entity={entity} showAdd={!isImport}/>
<EntityLinks
entity={entity}
identifierTypes={identifierTypes}
urlPrefix={urlPrefix}
/>
<EntityRelatedCollections collections={entity.collections}/>
<Button
className="margin-top-d15"
href={`/work/create?${_kebabCase(entity.type)}=${entity.bbid}`}
variant="success"
>
<FontAwesomeIcon className="margin-right-0-5" icon={faPlus}/>Add Work
</Button>
{!isImport &&
<Button
className="margin-top-d15"
href={`/work/create?${_kebabCase(entity.type)}=${entity.bbid}`}
variant="success"
>
<FontAwesomeIcon className="margin-right-0-5" icon={faPlus}/>Add Work
</Button>}
</Col>
<Col lg={4}>
<EntityReviews
Expand All @@ -190,23 +194,32 @@ function AuthorDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
</Row>
</React.Fragment>}
<hr className="margin-top-d40"/>
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>
{!entity.deleted && <CBReviewModal
{importMetadata ?
<ImportFooter
hasVoted={importMetadata.userHasVoted}
importUrl={urlPrefix}
importedAt={importMetadata.importedAt}
source={importMetadata.source}
type={entity.type}
/> :
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>}
{!entity.deleted && !isImport &&
<CBReviewModal
entityBBID={entity.bbid}
entityName={entity.defaultAlias.name}
entityType={entity.type}
handleModalToggle={handleModalToggle}
handleUpdateReviews={handleUpdateReviews}
showModal={showCBReviewModal}
userId={user?.id}
/>}
/>}
</div>
);
}
Expand Down
36 changes: 24 additions & 12 deletions src/client/components/pages/entities/edition-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import EntityLinks from './links';
import EntityRelatedCollections from './related-collections';
import EntityReviews from './cb-review';
import EntityTitle from './title';
import ImportFooter from '../import-entities/footer';
import PropTypes from 'prop-types';
import WikipediaExtract from './wikipedia-extract';


const {deletedEntityMessage, getTypeAttribute, getEntityUrl, ENTITY_TYPE_ICONS, getSortNameOfDefaultAlias} = entityHelper;
const {Col, Row} = bootstrap;

export function EditionGroupAttributes({editionGroup}) {
function EditionGroupAttributes({editionGroup}) {
if (editionGroup.deleted) {
return deletedEntityMessage;
}
Expand Down Expand Up @@ -91,6 +92,8 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac
reviewsRef.current.handleClick();
}, [reviewsRef]);

const {importMetadata} = entity;
const isImport = !entity.revision;
const urlPrefix = getEntityUrl(entity);
const hasAuthorCredits = entity.creditSection;

Expand Down Expand Up @@ -137,7 +140,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac
<EntityAnnotation entity={entity}/>
{!entity.deleted &&
<React.Fragment>
<EditionTable editions={entity.editions} entity={entity}/>
<EditionTable editions={entity.editions} entity={entity} showAdd={!isImport}/>
<Row>
<Col lg={8}>
<EntityLinks
Expand All @@ -160,23 +163,32 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac
</Row>
</React.Fragment>}
<hr className="margin-top-d40"/>
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>
{!entity.deleted && <CBReviewModal
{importMetadata ?
<ImportFooter
hasVoted={importMetadata.userHasVoted}
importUrl={urlPrefix}
importedAt={importMetadata.importedAt}
source={importMetadata.source}
type={entity.type}
/> :
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>}
{!entity.deleted && !isImport &&
<CBReviewModal
entityBBID={entity.bbid}
entityName={entity.defaultAlias.name}
entityType={entity.type}
handleModalToggle={handleModalToggle}
handleUpdateReviews={handleUpdateReviews}
showModal={showCBReviewModal}
userId={user?.id}
/>}
/>}
</div>
);
}
Expand Down
31 changes: 22 additions & 9 deletions src/client/components/pages/entities/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import EntityLinks from './links';
import EntityRelatedCollections from './related-collections';
import EntityTitle from './title';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import ImportFooter from '../import-entities/footer';
import PropTypes from 'prop-types';
import React from 'react';
import WikipediaExtract from './wikipedia-extract';
Expand All @@ -39,7 +40,7 @@ const {
} = entityHelper;
const {Col, Row} = bootstrap;

export function EditionAttributes({edition}) {
function EditionAttributes({edition}) {
if (edition.deleted) {
return deletedEntityMessage;
}
Expand Down Expand Up @@ -108,6 +109,8 @@ EditionAttributes.propTypes = {


function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
const {importMetadata} = entity;
const isImport = !entity.revision;
// relationshipTypeId = 10 refers the relation (<Work> is contained by <Edition>)
const relationshipTypeId = 10;
const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId);
Expand Down Expand Up @@ -152,6 +155,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
</div>
);
}

return (
<div>
<Row className="entity-display-background">
Expand All @@ -176,6 +180,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
<React.Fragment>
<WorksTable
entity={entity}
showAdd={!isImport}
works={worksContainedByEditionWithAuthors}
/>
<EntityLinks
Expand All @@ -186,14 +191,22 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
<EntityRelatedCollections collections={entity.collections}/>
</React.Fragment>}
<hr className="margin-top-d40"/>
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>
{importMetadata ?
<ImportFooter
hasVoted={importMetadata.userHasVoted}
importUrl={urlPrefix}
importedAt={importMetadata.importedAt}
source={importMetadata.source}
type={entity.type}
/> :
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>}
</div>
);
}
Expand Down
31 changes: 21 additions & 10 deletions src/client/components/pages/entities/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import EntityImage from './image';
import EntityLinks from './links';
import EntityRelatedCollections from './related-collections';
import EntityTitle from './title';
import ImportFooter from '../import-entities/footer';
import PropTypes from 'prop-types';
import React from 'react';
import WikipediaExtract from './wikipedia-extract';
Expand All @@ -34,7 +35,7 @@ const {deletedEntityMessage, extractAttribute, getTypeAttribute, getEntityUrl,
ENTITY_TYPE_ICONS, getSortNameOfDefaultAlias, transformISODateForDisplay} = entityHelper;
const {Col, Row} = bootstrap;

export function PublisherAttributes({publisher}) {
function PublisherAttributes({publisher}) {
if (publisher.deleted) {
return deletedEntityMessage;
}
Expand Down Expand Up @@ -83,6 +84,8 @@ PublisherAttributes.propTypes = {


function PublisherDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
const {importMetadata} = entity;
const isImport = !entity.revision;
const urlPrefix = getEntityUrl(entity);
return (
<div>
Expand All @@ -103,7 +106,7 @@ function PublisherDisplayPage({entity, identifierTypes, user, wikipediaExtract})
<EntityAnnotation entity={entity}/>
{!entity.deleted &&
<React.Fragment>
<EditionTable showAuthorCreditsColumn editions={entity.editions} entity={entity}/>
<EditionTable showAuthorCreditsColumn editions={entity.editions} entity={entity} showAdd={!isImport}/>
<EntityLinks
entity={entity}
identifierTypes={identifierTypes}
Expand All @@ -112,14 +115,22 @@ function PublisherDisplayPage({entity, identifierTypes, user, wikipediaExtract})
<EntityRelatedCollections collections={entity.collections}/>
</React.Fragment>}
<hr className="margin-top-d40"/>
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>
{importMetadata ?
<ImportFooter
hasVoted={importMetadata.userHasVoted}
importUrl={urlPrefix}
importedAt={importMetadata.importedAt}
source={importMetadata.source}
type={entity.type}
/> :
<EntityFooter
bbid={entity.bbid}
deleted={entity.deleted}
entityType={entity.type}
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
user={user}
/>}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function EntityRelatedCollections({collections}) {
}
EntityRelatedCollections.displayName = 'EntityRelatedCollections';
EntityRelatedCollections.propTypes = {
collections: PropTypes.object.isRequired
collections: PropTypes.array.isRequired
};

export default EntityRelatedCollections;
Loading
Loading