Skip to content
Snippets Groups Projects
Commit 76f2d08b authored by Allen Gilliland's avatar Allen Gilliland
Browse files

make it possible to link directly to a specific section of the Settings page.

parent 0f3989f1
No related branches found
No related tags found
No related merge requests found
......@@ -171,7 +171,7 @@ export default class AdminPeople extends Component {
<PasswordReveal password={user.password}></PasswordReveal>
<div style={{paddingLeft: "5em", paddingRight: "5em"}} className="pt4 text-centered">If you want to be able to send email invites, just go to the <a className="link text-bold" href="/admin/settings">Email Settings</a> page.</div>
<div style={{paddingLeft: "5em", paddingRight: "5em"}} className="pt4 text-centered">If you want to be able to send email invites, just go to the <a className="link text-bold" href="/admin/settings/?section=Email">Email Settings</a> page.</div>
</div>
<div className="Form-actions">
......
......@@ -10,6 +10,7 @@ import cx from 'classnames';
export default React.createClass({
displayName: "SettingsEditor",
propTypes: {
initialSection: React.string,
sections: React.PropTypes.object.isRequired,
updateSetting: React.PropTypes.func.isRequired
},
......@@ -20,6 +21,14 @@ export default React.createClass({
};
},
componentWillMount: function() {
if (this.props.initialSection) {
this.setState({
currentSection: this.props.initialSection
});
}
},
selectSection: function(section) {
this.setState({ currentSection: section });
},
......
......@@ -36,25 +36,31 @@ var EXTRA_SETTINGS_METADATA = {
"email-from-address": { display_name: "From Address", section: "Email", index: 5, type: "string" },
};
SettingsAdminControllers.controller('SettingsEditor', ['$scope', 'Settings', 'AppState', 'settings', function($scope, Settings, AppState, settings) {
$scope.SettingsEditor = SettingsEditor;
SettingsAdminControllers.controller('SettingsEditor', ['$scope', '$location', 'Settings', 'AppState', 'settings',
function($scope, $location, Settings, AppState, settings) {
$scope.SettingsEditor = SettingsEditor;
$scope.updateSetting = async function(setting) {
await Settings.put({ key: setting.key }, setting).$promise;
AppState.refreshSiteSettings();
}
if ('section' in $location.search()) {
$scope.initialSection = $location.search().section;
}
$scope.updateSetting = async function(setting) {
await Settings.put({ key: setting.key }, setting).$promise;
AppState.refreshSiteSettings();
}
$scope.sections = {};
settings.forEach(function(setting) {
var defaults = { display_name: keyToDisplayName(setting.key), placeholder: setting.default };
setting = _.extend(defaults, EXTRA_SETTINGS_METADATA[setting.key], setting);
var sectionName = setting.section || "Other";
$scope.sections[sectionName] = $scope.sections[sectionName] || [];
$scope.sections[sectionName].push(setting);
});
_.each($scope.sections, (section) => section.sort((a, b) => a.index - b.index))
$scope.sections = {};
settings.forEach(function(setting) {
var defaults = { display_name: keyToDisplayName(setting.key), placeholder: setting.default };
setting = _.extend(defaults, EXTRA_SETTINGS_METADATA[setting.key], setting);
var sectionName = setting.section || "Other";
$scope.sections[sectionName] = $scope.sections[sectionName] || [];
$scope.sections[sectionName].push(setting);
});
_.each($scope.sections, (section) => section.sort((a, b) => a.index - b.index))
function keyToDisplayName(key) {
return Humanize.capitalizeAll(key.replace(/-/g, " ")).trim();
function keyToDisplayName(key) {
return Humanize.capitalizeAll(key.replace(/-/g, " ")).trim();
}
}
}]);
]);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment