Skip to content

Commit

Permalink
Merge pull request #2862 from metabrainz/spa-fixes
Browse files Browse the repository at this point in the history
Misc SPA fixes
  • Loading branch information
MonkeyDo committed May 6, 2024
2 parents f4aebf8 + d5e7596 commit 7f25720
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 32 deletions.
4 changes: 2 additions & 2 deletions frontend/js/src/error/ErrorBoundary.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Helmet } from "react-helmet";
import { isRouteErrorResponse, useRouteError } from "react-router-dom";
import { isRouteErrorResponse, Link, useRouteError } from "react-router-dom";

const ErrorStatusMessage: { [key: number]: string } = {
400: "Invalid request",
Expand Down Expand Up @@ -35,7 +35,7 @@ export function ErrorBoundary() {
<code>{`${errorStatus}: ${errorMessage}`}</code>
</p>
<p>
<a href="/">Back to home page</a>
<Link to="/">Back to home page</Link>
</p>
</>
) : (
Expand Down
22 changes: 10 additions & 12 deletions frontend/js/src/explore/music-neighborhood/components/Panel.tsx
@@ -1,10 +1,7 @@
import * as React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faArrowUpRightFromSquare,
faInfo,
} from "@fortawesome/free-solid-svg-icons";
import { faInfo } from "@fortawesome/free-solid-svg-icons";
import Spinner from "react-loader-spinner";
import { Link } from "react-router-dom";
import ReleaseCard from "../../fresh-releases/components/ReleaseCard";
import SideBar from "../../../components/Sidebar";
import { COLOR_LB_ORANGE } from "../../../utils/constants";
Expand Down Expand Up @@ -53,15 +50,16 @@ function Panel({ artistInfo, loading }: PanelProps) {
</div>
<div id="artist-wiki">{artistInfo.wiki}</div>
<div className="artist-mb-link">
<a
<Link
id="artist-mb-link-button"
href={artistInfo.link}
target="_blank"
rel="noreferrer"
to={
artistInfo.link.endsWith("/")
? artistInfo.link
: `${artistInfo.link}/`
}
>
<strong>More </strong>
<FontAwesomeIcon icon={faArrowUpRightFromSquare} />
</a>
<strong>Artist page</strong>
</Link>
</div>
</div>
{artistInfo.topAlbum && (
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/src/home/Homepage.tsx
Expand Up @@ -268,7 +268,7 @@ export function HomePageWrapper() {
currentUser?.name &&
(redirectParam === "true" || redirectParam === null)
) {
return <Navigate to={`/user/${currentUser.name}`} replace />;
return <Navigate to={`/user/${currentUser.name}/`} replace />;
}
return <HomePage />;
}
Expand Down
12 changes: 12 additions & 0 deletions frontend/js/src/user/components/follow/UserSocialNetwork.tsx
Expand Up @@ -53,6 +53,18 @@ export default class UserSocialNetwork extends React.Component<
await this.getSimilarArtists();
}

async componentDidUpdate(prevProps: UserSocialNetworkProps) {
const { user: currentUser } = this.props;
if (prevProps.user.name !== currentUser.name) {
await this.getFollowing();
await this.getFollowers();
await this.getSimilarUsers();
await this.getCurrentUserFollowing();
await this.getSimilarity();
await this.getSimilarArtists();
}
}

getSimilarUsers = async () => {
const { user } = this.props;
const { APIService } = this.context;
Expand Down
Expand Up @@ -108,7 +108,7 @@ export default function RecommendationPlaylistSettings({
{playlist.creator} |{" "}
{extension?.created_for && `For ${extension?.created_for}`}
<br />
<Link to={playlist.identifier}>Link to this playlist</Link>
<Link to={`/playlist/${playlistId}/`}>Link to this playlist</Link>
</div>
<hr />
{playlist.annotation && (
Expand Down
10 changes: 1 addition & 9 deletions frontend/js/src/utils/utils.tsx
Expand Up @@ -280,15 +280,7 @@ const getStatsArtistLink = (
}
const firstArtist = _.first(artist_mbids);
if (firstArtist) {
return (
<Link
to={`/artist/${firstArtist}/`}
target="_blank"
rel="noopener noreferrer"
>
{artist_name}
</Link>
);
return <Link to={`/artist/${firstArtist}/`}>{artist_name}</Link>;
}
return artist_name;
};
Expand Down
8 changes: 4 additions & 4 deletions listenbrainz/webserver/templates/art/svg-templates/macros.j2
@@ -1,11 +1,11 @@
{% macro render_entity_link (entity, mbid, name) %}
{%- if mbid is defined and mbid is not none -%}
{% if entity == 'recording' %}
{% set host = 'musicbrainz' %}
{% set hostURL = 'https://musicbrainz.org' %}
{% else %}
{% set host = 'listenbrainz' %}
{% set hostURL = '' %}
{% endif %}
<a href="https://{{ host }}.org/{{ entity }}/{{ mbid }}" target="_blank">
<a href="{{ host }}/{{ entity }}/{{ mbid }}" target="_blank">
{{ name|upper }}
<title>{{ name }}</title>
</a>
Expand All @@ -17,7 +17,7 @@

{% macro render_image_link(entity, image) %}
{% if image.entity_mbid %}
<a href="https://listenbrainz.org/{{ entity }}/{{ image.entity_mbid }}" target="_blank">
<a href="/{{ entity }}/{{ image.entity_mbid }}" target="_blank">
{% endif %}
<image
x="{{ image.x }}"
Expand Down
3 changes: 1 addition & 2 deletions listenbrainz/webserver/views/entity_pages.py
Expand Up @@ -10,7 +10,6 @@
from listenbrainz.db.metadata import get_metadata_for_artist
from listenbrainz.webserver.views.api_tools import is_valid_uuid
from listenbrainz.webserver.views.metadata_api import fetch_release_group_metadata
import orjson
import psycopg2
from psycopg2.extras import DictCursor

Expand Down Expand Up @@ -115,7 +114,7 @@ def artist_entity(artist_mbid):
""" Show a artist page with all their relevant information """
# VA artist mbid
if artist_mbid in {"89ad4ac3-39f7-470e-963a-56509c546377"}:
raise BadRequest(f"Provided artist mbid is disabled for viewing on ListenBrainz")
return jsonify({"error": "Provided artist mbid is disabled for viewing on ListenBrainz"}), 400

if not is_valid_uuid(artist_mbid):
return jsonify({"error": "Provided artist mbid is invalid: %s" % artist_mbid}), 400
Expand Down
Expand Up @@ -94,7 +94,7 @@ def _get_props(active_section, user):
"name": user.musicbrainz_id,
},
"recommendations": recommendations,
"last_updated": data.created.strftime('%d %b %Y'),
"lastUpdated": data.created.strftime('%d %b %Y'),
"errorMsg": ""
}

Expand Down

0 comments on commit 7f25720

Please sign in to comment.