Skip to content

Commit

Permalink
Rewrite Preferences page to React/JSX
Browse files Browse the repository at this point in the history
as part of MBS-9699, plus:

- Remove unused checkbox for not yet implemented feature MBS-3285
  ('Notify me by email on new releases to my watched artists')
  which should be added to branch metabrainz/mbs-3285 instead;
- Reorder timezone and date/time format fields;
- Update date/time format options on timezone change;
- Add helper button to guess user timezone.
  • Loading branch information
yvanzo committed Oct 5, 2018
1 parent 84b33bb commit 2493c51
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 54 deletions.
18 changes: 18 additions & 0 deletions lib/MusicBrainz/Server/Controller/Account.pm
Expand Up @@ -4,7 +4,9 @@ BEGIN { extends 'MusicBrainz::Server::Controller' }

use namespace::autoclean;
use Digest::SHA qw(sha1_base64);
use List::MoreUtils qw( uniq );
use MusicBrainz::Server::ControllerUtils::JSON qw( serialize_pager );
use MusicBrainz::Server::Data::Utils qw( boolean_to_json );
use MusicBrainz::Server::Translation qw( l );
use MusicBrainz::Server::Validation qw( encode_entities is_positive_integer );
use Try::Tiny;
Expand Down Expand Up @@ -473,6 +475,22 @@ sub preferences : Path('/account/preferences') RequireAuth DenyWhenReadonly

$c->response->redirect($c->uri_for_action('/account/preferences', { ok => 1 }));
$c->detach;
} else {
$c->stash(
current_view => 'Node',
component_path => 'account/Preferences',
component_props => {
form => $form,
timezone_options => {
grouped => boolean_to_json(0),
options => [ map { {
value => $_,
label => $_
} } uniq values @{ $form->options_timezone } ],
},
},
);
$c->detach;
}
}

Expand Down
35 changes: 35 additions & 0 deletions root/account/Preferences.js
@@ -0,0 +1,35 @@
/*
* @flow
* Copyright (C) 2018 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 UserAccountLayout from '../components/UserAccountLayout';
import {withCatalystContext} from '../context';
import PreferencesForm from '../static/scripts/account/components/PreferencesForm';
import type {PreferencesFormPropsT} from '../static/scripts/account/components/PreferencesForm';
import {l} from '../static/scripts/common/i18n';
import * as manifest from '../static/manifest';

type Props = {|
+$c: CatalystContextT,
...PreferencesFormPropsT,
|};

const Preferences = withCatalystContext(({$c, ...props}) => (
<UserAccountLayout
page="preferences"
title={l('Preferences')}
user={$c.user}
>
<PreferencesForm {...props} />
{manifest.js('account/preferences')}
</UserAccountLayout>
));

export default Preferences;
54 changes: 0 additions & 54 deletions root/account/preferences.tt

This file was deleted.

4 changes: 4 additions & 0 deletions root/static/gulpfile.js
Expand Up @@ -261,6 +261,10 @@ runYarb('account/applications/register.js', function (b) {
b.external(commonBundle);
});

runYarb('account/preferences.js', function (b) {
b.external(commonBundle);
});

runYarb('area/index.js', function (b) {
b.external(commonBundle);
});
Expand Down
2 changes: 2 additions & 0 deletions root/static/images/attribution.txt
Expand Up @@ -129,10 +129,12 @@ Image set: Android
Author: http://www.androidicons.com
License: CC-BY (see download page)
Download: http://findicons.com/icon/80718/monitor (original, cropped in MusicBrainz)
http://findicons.com/icon/80717/magnet (original, cropped in MusicBrainz)

Images:

icons/video.png
icons/magnet.png

----------------------------------------------------------------------------

Expand Down
Binary file added root/static/images/icons/magnet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2493c51

Please sign in to comment.