Skip to content

Commit

Permalink
refactor(entityRoutes): Remove reduntant prop keys
Browse files Browse the repository at this point in the history
In the routes for the entites, when generateProps
is done (in /create and /:bbid/edit), there are keys
like this one:

workTypes: res.locals.workTypes

Howver, this is redundant becuase generateProps does
an Object.assign({}, res.locals, ...), which means such
keys are already present, so they can be removed from the code.
  • Loading branch information
naiveai committed Dec 28, 2017
1 parent c44a308 commit 3fd7598
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"host": "127.0.0.1",
"database": "bookbrainz_test",
"user": "postgres",
"password": ""
"password": "admin"
}
}
}
2 changes: 0 additions & 2 deletions src/server/routes/entity/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ router.get(
);

const props = generateProps(req, res, {
creatorTypes: res.locals.creatorTypes,
entityType: 'creator',
genderOptions: res.locals.genders,
heading: 'Create Creator',
Expand Down Expand Up @@ -235,7 +234,6 @@ router.get(

const props = generateProps(req, res, {
creator,
creatorTypes: res.locals.creatorTypes,
entityType: 'creator',
genderOptions: res.locals.genders,
heading: 'Edit Creator',
Expand Down
4 changes: 0 additions & 4 deletions src/server/routes/entity/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ router.get(

const {Publication, Publisher} = req.app.locals.orm;
const propsPromise = generateProps(req, res, {
editionFormats: res.locals.editionFormats,
editionStatuses: res.locals.editionStatuses,
entityType: 'edition',
heading: 'Create Edition',
identifierTypes: filteredIdentifierTypes,
Expand Down Expand Up @@ -299,8 +297,6 @@ router.get(
);

const props = generateProps(req, res, {
editionFormats: res.locals.editionFormats,
editionStatuses: res.locals.editionStatuses,
entityType: 'edition',
heading: 'Edit Edition',
identifierTypes: filteredIdentifierTypes,
Expand Down
2 changes: 0 additions & 2 deletions src/server/routes/entity/publication.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ router.get(
identifierTypes: filteredIdentifierTypes,
initialState: {},
languageOptions: res.locals.languages,
publicationTypes: res.locals.publicationTypes,
requiresJS: true,
subheading: 'Add a new Publication to BookBrainz',
submissionUrl: '/publication/create/handler'
Expand Down Expand Up @@ -221,7 +220,6 @@ router.get(
identifierTypes: filteredIdentifierTypes,
initialState: publicationToFormState(publication),
languageOptions: res.locals.languages,
publicationTypes: res.locals.publicationTypes,
requiresJS: true,
subheading: 'Edit an existing Publication in BookBrainz',
submissionUrl: `/publication/${publication.bbid}/edit/handler`
Expand Down
2 changes: 0 additions & 2 deletions src/server/routes/entity/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ router.get(
identifierTypes: filteredIdentifierTypes,
initialState: {},
languageOptions: res.locals.languages,
publisherTypes: res.locals.publisherTypes,
requiresJS: true,
subheading: 'Add a new Publisher to BookBrainz',
submissionUrl: '/publisher/create/handler'
Expand Down Expand Up @@ -250,7 +249,6 @@ router.get(
identifierTypes: filteredIdentifierTypes,
initialState: publisherToFormState(publisher),
languageOptions: res.locals.languages,
publisherTypes: res.locals.publisherTypes,
requiresJS: true,
subheading: 'Edit an existing Publisher in BookBrainz',
submissionUrl: `/publisher/${publisher.bbid}/edit/handler`
Expand Down
6 changes: 2 additions & 4 deletions src/server/routes/entity/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ router.get(
languageOptions: res.locals.languages,
requiresJS: true,
subheading: 'Add a new Work to BookBrainz',
submissionUrl: '/work/create/handler',
workTypes: res.locals.workTypes
submissionUrl: '/work/create/handler'
});

const {initialState, ...rest} = props;
Expand Down Expand Up @@ -223,8 +222,7 @@ router.get(
languageOptions: res.locals.languages,
requiresJS: true,
subheading: 'Edit an existing Work in BookBrainz',
submissionUrl: `/work/${work.bbid}/edit/handler`,
workTypes: res.locals.workTypes
submissionUrl: `/work/${work.bbid}/edit/handler`
});

const {initialState, ...rest} = props;
Expand Down

0 comments on commit 3fd7598

Please sign in to comment.