Skip to content

Commit

Permalink
Merge pull request #1100 from metabrainz/ac-order
Browse files Browse the repository at this point in the history
BB-803: Sort author credits by their position
  • Loading branch information
MonkeyDo authored Jun 25, 2024
2 parents 529da3c + 782074a commit adaed67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import PropTypes from 'prop-types';
import {map as _map, sortBy} from 'lodash';
import {AuthorCreditRow} from '../entity-editor/author-credit-editor/actions';
import React from 'react';
import {map as _map} from 'lodash';


function AuthorCreditDisplay({names}) {
const nameElements = _map(names, (name) => {
function AuthorCreditDisplay({names}:{names:AuthorCreditRow[]}) {
const nameElements = _map(sortBy(names, 'position'), (name) => {
const authorBBID = name.authorBBID ?? name.author?.id;
return (
<span key={`author-credit-${authorBBID}`}>
Expand All @@ -42,11 +42,5 @@ function AuthorCreditDisplay({names}) {
}

AuthorCreditDisplay.displayName = 'AuthorCreditDisplay';
AuthorCreditDisplay.propTypes = {
names: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object
]).isRequired
};

export default AuthorCreditDisplay;
2 changes: 1 addition & 1 deletion src/client/entity-editor/author-credit-editor/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type AuthorCreditRow = {
author: Author,
authorBBID: string,
position: number,
authohrCreditID: number
authorCreditID: number
};
export type AuthorCredit = {
authorCount: number,
Expand Down

0 comments on commit adaed67

Please sign in to comment.