Commit 305e614e authored by Benjamin Bouvier's avatar Benjamin Bouvier
Browse files

[client] Rejigger URLs so all the settings subsections have a uniform URL and a title;

parent e83bbe4c
......@@ -26,7 +26,8 @@ class ParamMenu extends React.Component {
<div className="settings-dropdown-menu">
<ul>
<li>
<NavLink to={URL.categories.url(this.props.currentAccountId)}>
<NavLink
to={URL.settings.url('categories', this.props.currentAccountId)}>
<span className="fa fa-list-ul" />
{$t('client.menu.categories')}
</NavLink>
......
......@@ -5,6 +5,7 @@ import URL from '../../urls';
import BackupParameters from './backup';
import BankAccountsList from './bank-accesses';
import CategoryList from '../categories';
import CustomizationParameters from './customization';
import EmailsParameters from './emails';
import LogsSection from './logs';
......@@ -12,30 +13,34 @@ import WeboobParameters from './weboob';
const SettingsComponents = props => {
let currentAccountId = URL.settings.accountId(props.match);
return (
<Switch>
<Route
path={URL.settings.url('accounts', currentAccountId)}
component={BankAccountsList}
/>
<Route
path={URL.settings.url('emails', currentAccountId)}
component={EmailsParameters}
/>
<Route
path={URL.settings.url('backup', currentAccountId)}
component={BackupParameters}
/>
<Route
path={URL.settings.url('weboob', currentAccountId)}
component={WeboobParameters}
path={URL.settings.url('categories', currentAccountId)}
component={CategoryList}
/>
<Route
path={URL.settings.url('customization', currentAccountId)}
component={CustomizationParameters}
/>
<Route
path={URL.settings.url('emails', currentAccountId)}
component={EmailsParameters}
/>
<Route path={URL.settings.url('logs', currentAccountId)} component={LogsSection} />
<Route
path={URL.settings.url('weboob', currentAccountId)}
component={WeboobParameters}
/>
<Redirect to={URL.settings.url('accounts', currentAccountId)} push={false} />
</Switch>
);
......
......@@ -16,7 +16,6 @@ import LazyLoader from './components/lazyLoader';
// Components
import About from './components/about';
import CategoryList from './components/categories';
import loadCharts from 'bundle-loader?lazy!./components/charts';
import OperationList from './components/operations';
import Budget from './components/budget';
......@@ -180,7 +179,6 @@ class BaseApp extends React.Component {
<Route path={URL.reports.pattern} component={OperationList} />
<Route path={URL.budgets.pattern} component={Budget} />
<Route path={URL.charts.pattern} component={Charts} />
<Route path={URL.categories.pattern} component={CategoryList} />
<Route path={URL.duplicates.pattern} component={DuplicatesList} />
<Route path={URL.settings.pattern} component={Settings} />
<Route path={URL.about.pattern} component={About} />
......
// The list of the available sections.
const SECTIONS = ['about', 'budget', 'categories', 'charts', 'duplicates', 'reports', 'settings'];
const SETTINGS_SUBSECTIONS = [
'accounts',
'backup',
'categories',
'customization',
'emails',
'logs',
'weboob'
];
function getCurrentAccountId(match) {
return match.params.currentAccountId;
......@@ -38,13 +47,6 @@ const URLs = {
accountId: getCurrentAccountId
},
categories: {
pattern: '/categories/:currentAccountId',
url(accountId) {
return `/categories/${accountId}`;
}
},
settings: {
pattern: '/settings/:subsection/:currentAccountId',
url(subsection, accountId) {
......@@ -78,7 +80,7 @@ const URLs = {
},
sections: {
pattern: '/:section',
pattern: '/:section/:subsection?',
genericPattern: '/:section/:subsection?/:currentAccountId',
sub(match, section, defaultValue) {
let { section: matchSection, subsection: matchSubsection } = match.params;
......@@ -87,7 +89,16 @@ const URLs = {
: defaultValue;
},
title(match) {
return match && SECTIONS.includes(match.params.section) ? match.params.section : null;
if (!match || !match.params) {
return null;
}
if (SETTINGS_SUBSECTIONS.includes(match.params.subsection)) {
return match.params.subsection;
}
if (SECTIONS.includes(match.params.section)) {
return match.params.section;
}
return null;
},
accountId: getCurrentAccountId
}
......
......@@ -155,18 +155,22 @@
"add_custom_label": "Add a custom label"
},
"menu": {
"about": "About",
"accounts": "Bank accounts",
"backup": "Backups",
"banks": "Banks",
"budget": "Budget",
"categories": "Categories",
"charts": "Charts",
"settings": "Settings",
"customization": "Customization",
"different_currencies": "Different currencies",
"duplicates": "Duplicates",
"sublists": "Accounts",
"emails": "Alerts",
"logs": "Logs",
"outstanding_balance": "Ongoing: ",
"reports": "Reports",
"budget": "Budget",
"about": "About",
"different_currencies": "Different currencies",
"total": "Total",
"outstanding_balance": "Ongoing: "
"weboob": "Weboob"
},
"operations": {
"amount": "Amount",
......
......@@ -155,18 +155,22 @@
"add_custom_label": "Ajouter un libellé personnalisé"
},
"menu": {
"about": "À propos",
"accounts": "Comptes bancaires",
"backup": "Sauvegardes",
"banks": "Banques",
"budget": "Budget",
"categories": "Catégories",
"charts": "Graphiques",
"settings": "Préférences",
"customization": "Personnalisation",
"different_currencies": "Devises différentes",
"duplicates": "Doublons",
"sublists": "Comptes",
"emails": "Alertes",
"logs": "Journaux",
"outstanding_balance": "Encours : ",
"reports": "Relevé",
"budget": "Budget",
"about": "À propos",
"different_currencies": "Devises différentes",
"total": "Total",
"outstanding_balance": "Encours : "
"weboob": "Weboob"
},
"operations": {
"amount": "Montant",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment