diff --git a/entities.json b/entities.json index 8e662466b66..f9a166f0b27 100644 --- a/entities.json +++ b/entities.json @@ -239,7 +239,8 @@ "edit_table": true, "mbid": { "indexable": true, - "multiple": false + "multiple": false, + "relatable": "overview" }, "merging": false, "model": "Genre", diff --git a/lib/MusicBrainz/Server/Controller/Genre.pm b/lib/MusicBrainz/Server/Controller/Genre.pm index f29496c4766..f1005fb2b5a 100644 --- a/lib/MusicBrainz/Server/Controller/Genre.pm +++ b/lib/MusicBrainz/Server/Controller/Genre.pm @@ -9,11 +9,13 @@ use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array ); with 'MusicBrainz::Server::Controller::Role::Load' => { model => 'Genre', entity_name => 'genre', + relationships => { cardinal => ['show', 'edit'], default => ['url'] }, }; with 'MusicBrainz::Server::Controller::Role::LoadWithRowID'; with 'MusicBrainz::Server::Controller::Role::Annotation'; with 'MusicBrainz::Server::Controller::Role::Details'; with 'MusicBrainz::Server::Controller::Role::EditListing'; +with 'MusicBrainz::Server::Controller::Role::EditRelationships'; use MusicBrainz::Server::Constants qw( $EDIT_GENRE_CREATE diff --git a/lib/MusicBrainz/Server/Controller/Role/EditRelationships.pm b/lib/MusicBrainz/Server/Controller/Role/EditRelationships.pm index 5ab8bd2b82f..1d8e2e19e6b 100644 --- a/lib/MusicBrainz/Server/Controller/Role/EditRelationships.pm +++ b/lib/MusicBrainz/Server/Controller/Role/EditRelationships.pm @@ -298,14 +298,23 @@ role { my $seeded_relationships = get_seeded_relationships($c, $source_type, $source); my @link_type_tree = $c->model('LinkType')->get_full_tree; my @link_attribute_types = $c->model('LinkAttributeType')->get_all; + my $type_info = build_type_info( + $c, + qr/(^$source_type-|-$source_type$)/, + @link_type_tree, + ); $c->stash( seeded_relationships => $c->json->encode(to_json_array($seeded_relationships)), source_entity => $c->json->encode($source_entity), attr_info => $c->json->encode(\@link_attribute_types), - type_info => $c->json->encode(build_type_info($c, qr/(^$source_type-|-$source_type$)/, @link_type_tree)), + type_info => $c->json->encode($type_info), ); + $c->stash->{component_props}{sourceEntity} = $source_entity; + $c->stash->{component_props}{attrInfo} = to_json_array(\@link_attribute_types); + $c->stash->{component_props}{typeInfo} = $type_info; + my $post_creation = delete $opts{post_creation}; $opts{post_creation} = sub { diff --git a/lib/MusicBrainz/Server/Data/Genre.pm b/lib/MusicBrainz/Server/Data/Genre.pm index c5c24d61649..276f337b763 100644 --- a/lib/MusicBrainz/Server/Data/Genre.pm +++ b/lib/MusicBrainz/Server/Data/Genre.pm @@ -55,6 +55,7 @@ sub can_delete { 1 } sub delete { my ($self, $genre_id) = @_; + $self->c->model('Relationship')->delete_entities('genre', $genre_id); $self->annotation->delete($genre_id); $self->delete_returning_gids($genre_id); return; diff --git a/lib/MusicBrainz/Server/Entity/Genre.pm b/lib/MusicBrainz/Server/Entity/Genre.pm index 6d35ab0746e..da736815321 100644 --- a/lib/MusicBrainz/Server/Entity/Genre.pm +++ b/lib/MusicBrainz/Server/Entity/Genre.pm @@ -7,6 +7,7 @@ extends 'MusicBrainz::Server::Entity::CoreEntity'; with 'MusicBrainz::Server::Entity::Role::Annotation'; with 'MusicBrainz::Server::Entity::Role::Comment'; with 'MusicBrainz::Server::Entity::Role::LastUpdate'; +with 'MusicBrainz::Server::Entity::Role::Linkable'; sub entity_type { 'genre' } diff --git a/lib/MusicBrainz/Server/Form/Genre.pm b/lib/MusicBrainz/Server/Form/Genre.pm index e568f40a303..be1c0e5ff4e 100644 --- a/lib/MusicBrainz/Server/Form/Genre.pm +++ b/lib/MusicBrainz/Server/Form/Genre.pm @@ -3,6 +3,7 @@ use HTML::FormHandler::Moose; extends 'MusicBrainz::Server::Form'; with 'MusicBrainz::Server::Form::Role::Edit'; +with 'MusicBrainz::Server::Form::Role::Relationships'; has '+name' => ( default => 'edit-genre' ); diff --git a/root/genre/CreateGenre.js b/root/genre/CreateGenre.js index c2b78bf0de6..0ad993fa6b9 100644 --- a/root/genre/CreateGenre.js +++ b/root/genre/CreateGenre.js @@ -10,21 +10,38 @@ import * as React from 'react'; import Layout from '../layout'; +import * as manifest from '../static/manifest'; +import GenreEditForm from '../static/scripts/genre/components/GenreEditForm'; -import GenreEditForm from './GenreEditForm'; import type {GenreFormT} from './types'; type Props = { +$c: CatalystContextT, + +attrInfo: LinkAttrTypeOptionsT, +form: GenreFormT, + +sourceEntity: {entityType: 'genre'}, + +typeInfo: LinkTypeOptionsT, }; -const CreateGenre = ({$c, form}: Props): React.Element => ( +const CreateGenre = ({ + $c, + attrInfo, + form, + sourceEntity, + typeInfo, +}: Props): React.Element => (

{l('Add a new genre')}

- +
+ {manifest.js('genre/components/GenreEditForm', {async: 'async'})}
); diff --git a/root/genre/EditGenre.js b/root/genre/EditGenre.js index c4bc2d61b59..0d220f375d0 100644 --- a/root/genre/EditGenre.js +++ b/root/genre/EditGenre.js @@ -9,20 +9,28 @@ import * as React from 'react'; -import GenreEditForm from './GenreEditForm'; +import * as manifest from '../static/manifest'; +import GenreEditForm from '../static/scripts/genre/components/GenreEditForm'; + import GenreLayout from './GenreLayout'; import type {GenreFormT} from './types'; type Props = { +$c: CatalystContextT, + +attrInfo: LinkAttrTypeOptionsT, +entity: GenreT, +form: GenreFormT, + +sourceEntity: GenreT, + +typeInfo: LinkTypeOptionsT, }; const EditGenre = ({ $c, + attrInfo, entity, form, + sourceEntity, + typeInfo, }: Props): React.Element => ( - + + {manifest.js('genre/components/GenreEditForm', {async: 'async'})} ); diff --git a/root/genre/GenreEditForm.js b/root/genre/GenreEditForm.js deleted file mode 100644 index 8f8c178af50..00000000000 --- a/root/genre/GenreEditForm.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * @flow strict-local - * Copyright (C) 2019 MetaBrainz Foundation - * - * This file is part of MusicBrainz, the open internet music database, - * and is licensed under the GPL version 2, or (at your option) any - * later version: http://www.gnu.org/licenses/gpl-2.0.txt - */ - -import * as React from 'react'; - -import EnterEdit from '../components/EnterEdit'; -import EnterEditNote from '../components/EnterEditNote'; -import FormRowTextLong from '../components/FormRowTextLong'; - -import type {GenreFormT} from './types'; - -type Props = { - +$c: CatalystContextT, - +form: GenreFormT, -}; - -const GenreEditForm = ({ - $c, - form, -}: Props): React.Element<'form'> => ( -
-
-
- {l('Genre details')} - - -
- - -
-
-); - -export default GenreEditForm; diff --git a/root/genre/GenreIndex.js b/root/genre/GenreIndex.js index 602f53b2982..2804a0fe547 100644 --- a/root/genre/GenreIndex.js +++ b/root/genre/GenreIndex.js @@ -9,6 +9,7 @@ import * as React from 'react'; +import Relationships from '../components/Relationships'; import Annotation from '../static/scripts/common/components/Annotation'; import TagLink from '../static/scripts/common/components/TagLink'; import * as manifest from '../static/manifest'; @@ -42,6 +43,7 @@ const GenreIndex = ({ entity={genre} numberOfRevisions={numberOfRevisions} /> + {manifest.js('genre/index', {async: 'async'})} ); diff --git a/root/layout/components/sidebar/GenreSidebar.js b/root/layout/components/sidebar/GenreSidebar.js index 486dcf9ae42..20fa10df5a6 100644 --- a/root/layout/components/sidebar/GenreSidebar.js +++ b/root/layout/components/sidebar/GenreSidebar.js @@ -12,6 +12,7 @@ import * as React from 'react'; import {CatalystContext} from '../../../context'; import {isRelationshipEditor} from '../../../static/scripts/common/utility/privileges'; +import ExternalLinks from '../ExternalLinks'; import AnnotationLinks from './AnnotationLinks'; import EditLinks from './EditLinks'; @@ -27,6 +28,8 @@ const GenreSidebar = ({genre}: Props): React.Element<'div'> => { return (