diff --git a/web/source/settings-panel/admin/settings.js b/web/source/settings-panel/admin/settings.js index 198d7a07..c88aa454 100644 --- a/web/source/settings-panel/admin/settings.js +++ b/web/source/settings-panel/admin/settings.js @@ -30,7 +30,6 @@ const adminActions = require("../redux/reducers/instances").actions; const { TextInput, TextArea, - Checkbox, File } = require("../components/form-fields").formFields(adminActions.setAdminSettingsVal, (state) => state.instances.adminSettings); @@ -45,7 +44,7 @@ module.exports = function AdminSettings() { setStatus("PATCHing"); setError(""); return Promise.try(() => { - return dispatch(api.admin.updateProfile()); + return dispatch(api.admin.updateInstance()); }).then(() => { setStatus("Saved!"); }).catch((e) => { @@ -91,7 +90,7 @@ module.exports = function AdminSettings() { placeHolder="" /> -
+ {/*

Instance avatar

{instance.avatar @@ -111,7 +110,7 @@ module.exports = function AdminSettings() { fileType="image/*" />
-
+
*/} ); diff --git a/web/source/settings-panel/lib/api/admin.js b/web/source/settings-panel/lib/api/admin.js index ad32e10f..7c4d3f94 100644 --- a/web/source/settings-panel/lib/api/admin.js +++ b/web/source/settings-panel/lib/api/admin.js @@ -19,52 +19,26 @@ "use strict"; const Promise = require("bluebird"); -const d = require("dotty"); -const user = require("../../redux/reducers/user").actions; +const instance = require("../../redux/reducers/instances").actions; module.exports = function ({ apiCall, getChanges }) { - function updateInstance(selector, keys) { - return function (dispatch, getState) { - return Promise.try(() => { - const state = selector(getState()); - - const update = getChanges(state, keys); - - return dispatch(apiCall("PATCH", "/api/v1/instance", update, "form")); - }).then((account) => { - return dispatch(user.setAccount(account)); - }); - }; - } - return { - fetchAccount: function fetchAccount() { - return function (dispatch, _getState) { + updateInstance: function updateInstance() { + return function (dispatch, getState) { return Promise.try(() => { - return dispatch(apiCall("GET", "/api/v1/accounts/verify_credentials")); - }).then((account) => { - return dispatch(user.setAccount(account)); + const state = getState().instances.adminSettings; + + const update = getChanges(state, { + formKeys: ["title", "short_description", "description", "contact_username", "email", "terms"], + // fileKeys: ["avatar", "header"] + }); + + return dispatch(apiCall("PATCH", "/api/v1/instance", update, "form")); + }).then((data) => { + return dispatch(instance.setInstanceInfo(data)); }); }; - }, - - updateProfile: function updateProfile() { - const formKeys = ["display_name", "locked", "source", "custom_css", "note"]; - - const renamedKeys = { - note: "source.note" - }; - - const fileKeys = ["header", "avatar"]; - - return updateCredentials((state) => state.user.profile, {formKeys, renamedKeys, fileKeys}); - }, - - updateSettings: function updateProfile() { - const formKeys = ["source"]; - - return updateCredentials((state) => state.user.settings, {formKeys}); } }; }; \ No newline at end of file diff --git a/web/source/settings-panel/lib/api/index.js b/web/source/settings-panel/lib/api/index.js index 3a68a8a2..1624c375 100644 --- a/web/source/settings-panel/lib/api/index.js +++ b/web/source/settings-panel/lib/api/index.js @@ -175,6 +175,7 @@ module.exports = { }, oauth: require("./oauth")(submoduleArgs), user: require("./user")(submoduleArgs), + admin: require("./admin")(submoduleArgs), apiCall, getChanges }; \ No newline at end of file