Skip to content

Commit

Permalink
Reactivate LastFM importer (#1346)
Browse files Browse the repository at this point in the history
After merging PR #1339 we will want to reactivate the LastFM Importer that we deactivated with PR #1334
  • Loading branch information
MonkeyDo committed Mar 17, 2021
1 parent 987aa9a commit 4e0e238
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
4 changes: 2 additions & 2 deletions listenbrainz/webserver/static/js/src/LastFMImporter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe("LastFmImporter Page", () => {
expect(wrapper.html()).toMatchSnapshot();
});

xit("modal renders when button clicked", () => {
it("modal renders when button clicked", () => {
const wrapper = shallow(<LastFmImporter {...props} />);
// Simulate submiting the form
wrapper.find("form").simulate("submit", {
Expand All @@ -385,7 +385,7 @@ describe("LastFmImporter Page", () => {
expect(wrapper.exists("LastFMImporterModal")).toBe(true);
});

xit("submit button is disabled when input is empty", () => {
it("submit button is disabled when input is empty", () => {
const wrapper = shallow(<LastFmImporter {...props} />);
// Make sure that the input is empty
wrapper.setState({ lastfmUsername: "" });
Expand Down
58 changes: 27 additions & 31 deletions listenbrainz/webserver/static/js/src/LastFMImporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { IconProp } from "@fortawesome/fontawesome-svg-core";
import APIService from "./APIService";
import Scrobble from "./Scrobble";
import LastFMImporterModal from "./LastFMImporterModal";

export const LASTFM_RETRIES = 3;

export type ImporterProps = {
user: {
id?: string;
Expand Down Expand Up @@ -433,39 +435,33 @@ export default class LastFmImporter extends React.Component<
render() {
const { show, canClose, lastfmUsername, msg } = this.state;
return (
<div className="alert alert-danger">
We are having some issues with the LastFM importer, but we are working
on fixing it. Please try again later. Our apologies for the delay!
<div className="Importer">
<form onSubmit={this.handleSubmit}>
<input
type="text"
onChange={this.handleChange}
value={lastfmUsername}
placeholder="Last.fm Username"
size={30}
/>
<input type="submit" value="Import Now!" disabled={!lastfmUsername} />
</form>
{show && (
<LastFMImporterModal onClose={this.toggleModal} disable={!canClose}>
<img
src="/static/img/listenbrainz-logo.svg"
height="75"
className="img-responsive"
alt=""
/>
<br />
<br />
<div>{msg}</div>
<br />
</LastFMImporterModal>
)}
</div>
);
// return (
// <div className="Importer">
// <form onSubmit={this.handleSubmit}>
// <input
// type="text"
// onChange={this.handleChange}
// value={lastfmUsername}
// placeholder="Last.fm Username"
// size={30}
// />
// <input type="submit" value="Import Now!" disabled={!lastfmUsername} />
// </form>
// {show && (
// <LastFMImporterModal onClose={this.toggleModal} disable={!canClose}>
// <img
// src="/static/img/listenbrainz-logo.svg"
// height="75"
// className="img-responsive"
// alt=""
// />
// <br />
// <br />
// <div>{msg}</div>
// <br />
// </LastFMImporterModal>
// )}
// </div>
// );
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LastFmImporter Page renders 1`] = `"<div class=\\"alert alert-danger\\">We are having some issues with the LastFM importer, but we are working on fixing it. Please try again later. Our apologies for the delay!</div>"`;
exports[`LastFmImporter Page renders 1`] = `"<div class=\\"Importer\\"><form><input type=\\"text\\" placeholder=\\"Last.fm Username\\" size=\\"30\\" value=\\"\\"><input type=\\"submit\\" disabled=\\"\\" value=\\"Import Now!\\"></form></div>"`;

0 comments on commit 4e0e238

Please sign in to comment.