diff --git a/src/components/all.scss b/src/components/all.scss index 8bec9535..493d1fbe 100644 --- a/src/components/all.scss +++ b/src/components/all.scss @@ -23,6 +23,7 @@ @import './modules/LoginForm.scss'; @import './modules/CreateGroup.scss'; @import './modules/groups/MyGroups.scss'; +@import './modules/groups/GroupSettings.scss'; @import './modules/Modals.scss'; @import "./pages/Messages"; diff --git a/src/components/modules/CreateGroup.scss b/src/components/modules/CreateGroup.scss index a525b8b9..93391d0b 100644 --- a/src/components/modules/CreateGroup.scss +++ b/src/components/modules/CreateGroup.scss @@ -1,39 +1,39 @@ .CreateGroup { - h3 { - padding-left: 0.75rem; - } - .next-button { - width: 48px; - height: 48px; - padding-left: 13px !important; - color: white; - position: absolute; - bottom: 0.4rem; - right: 0.5rem; - box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.4); - } - .Stepper { - width: 85%; - margin-left: 1rem; - } - .icon-hint { - margin-left: 0.25rem; - } - .column { - padding-right: 0.5rem !important; - } - .error { - margin-bottom: 0px !important; - margin-top: 0.5rem; - } - .submit-error { - margin-left: 1rem; - max-width: 83%; - } + h3 { + padding-left: 0.75rem; + } + .next-button { + width: 48px; + height: 48px; + padding-left: 13px !important; + color: white; + position: absolute; + bottom: 0.4rem; + right: 0.5rem; + box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.4); + } + .Stepper { + width: 85%; + margin-left: 1rem; + } + .icon-hint { + margin-left: 0.25rem; + } + .column { + padding-right: 0.5rem !important; + } + .error { + margin-bottom: 0px !important; + margin-top: 0.5rem; + } + .submit-error { + margin-left: 1rem; + max-width: 83%; + } - .image-loader { - margin-top: 14px; - } + .image-loader { + margin-top: 14px; + } .image-preview { max-width: 75px; @@ -42,7 +42,7 @@ border: none; } .submit-loader { - margin-left: 0.5rem; - margin-top: 0.5rem; + margin-left: 0.5rem; + margin-top: 0.5rem; } } diff --git a/src/components/modules/Modals.jsx b/src/components/modules/Modals.jsx index 97705401..8ff3ffd2 100644 --- a/src/components/modules/Modals.jsx +++ b/src/components/modules/Modals.jsx @@ -6,6 +6,7 @@ import CloseButton from 'react-foundation-components/lib/global/close-button'; import Reveal from 'react-foundation-components/lib/global/reveal'; import CreateGroup from 'app/components/modules/CreateGroup' +import GroupSettings from 'app/components/modules/groups/GroupSettings' import MyGroups from 'app/components/modules/groups/MyGroups' import Donate from 'app/components/modules/Donate' import LoginForm from 'app/components/modules/LoginForm'; @@ -21,6 +22,7 @@ class Modals extends React.Component { show_donate_modal: PropTypes.bool, show_create_group_modal: PropTypes.bool, show_my_groups_modal: PropTypes.bool, + show_group_settings_modal: PropTypes.bool, show_app_download_modal: PropTypes.bool, hideDonate: PropTypes.func.isRequired, hideAppDownload: PropTypes.func.isRequired, @@ -44,11 +46,13 @@ class Modals extends React.Component { show_donate_modal, show_create_group_modal, show_my_groups_modal, + show_group_settings_modal, show_app_download_modal, hideLogin, hideDonate, hideCreateGroup, hideMyGroups, + hideGroupSettings, hideAppDownload, notifications, removeNotification, @@ -80,6 +84,10 @@ class Modals extends React.Component { } + {show_group_settings_modal && + + + } {show_app_download_modal && @@ -103,6 +111,7 @@ export default connect( show_donate_modal: state.user.get('show_donate_modal'), show_create_group_modal: state.user.get('show_create_group_modal'), show_my_groups_modal: state.user.get('show_my_groups_modal'), + show_group_settings_modal: state.user.get('show_group_settings_modal'), show_app_download_modal: state.user.get('show_app_download_modal'), loginUnclosable, notifications: state.app.get('notifications'), @@ -125,6 +134,10 @@ export default connect( if (e) e.preventDefault() dispatch(user.actions.hideMyGroups()) }, + hideGroupSettings: e => { + if (e) e.preventDefault() + dispatch(user.actions.hideGroupSettings()) + }, hideAppDownload: e => { if (e) e.preventDefault() dispatch(user.actions.hideAppDownload()) diff --git a/src/components/modules/groups/GroupSettings.jsx b/src/components/modules/groups/GroupSettings.jsx new file mode 100644 index 00000000..61f74904 --- /dev/null +++ b/src/components/modules/groups/GroupSettings.jsx @@ -0,0 +1,194 @@ +import React from 'react' +import {connect} from 'react-redux' +import { Formik, Form, Field, ErrorMessage, } from 'formik' +import { Map } from 'immutable' +import { api, formatter } from 'golos-lib-js' +import tt from 'counterpart' + +import g from 'app/redux/GlobalReducer' +import transaction from 'app/redux/TransactionReducer' +import user from 'app/redux/UserReducer' +import { session } from 'app/redux/UserSaga' +import DropdownMenu from 'app/components/elements/DropdownMenu' +import ExtLink from 'app/components/elements/ExtLink' +import Icon from 'app/components/elements/Icon' +import LoadingIndicator from 'app/components/elements/LoadingIndicator' +import DialogManager from 'app/components/elements/common/DialogManager' +import { showLoginDialog } from 'app/components/dialogs/LoginDialog' +import { getGroupLogo, getGroupMeta, getGroupTitle } from 'app/utils/groups' + +class GroupSettings extends React.Component { + constructor(props) { + super(props) + this.state = { + loaded: false + } + } + + componentDidMount() { + const { currentGroup } = this.props + const group = currentGroup.toJS() + const { name, member_list, privacy, json_metadata } = group + const meta = getGroupMeta(json_metadata) + let admin + for (const mem of member_list) { + if (mem.member_type === 'admin') { + admin = mem.account + } + break + } + const initialValues = { + title: meta.title, + logo: meta.logo, + admin, + privacy + } + this.setState({ + initialValues + }) + } + + onTitleChange = (e, { applyFieldValue }) => { + const { value } = e.target + if (value.trimLeft() !== value) { + return + } + applyFieldValue('title', value) + } + + onLogoChange = (e, { applyFieldValue }) => { + const { value } = e.target + applyFieldValue('logo', value) + } + + onAdminChange = (e, { applyFieldValue }) => { + const { value } = e.target + applyFieldValue('admin', value) + } + + validate = async () => { + + } + + onSubmit = async () => { + + } + + closeMe = (e) => { + e.preventDefault() + this.props.closeMe() + } + + render() { + const { currentGroup } = this.props + const group = currentGroup.toJS() + const { name, json_metadata } = group + + const meta = getGroupMeta(json_metadata) + const title = getGroupTitle(meta, name) + + const { initialValues } = this.state + + let form + if (!initialValues) { + form = + } else { + form = + {({ + handleSubmit, isSubmitting, isValid, values, errors, setFieldValue, applyFieldValue, setFieldTouched, handleChange, + }) => { + const disabled = !isValid + return ( +
+
+
+ {tt('create_group_jsx.title')} + this.onTitleChange(e, { applyFieldValue })} + autoFocus + validateOnBlur={false} + /> +
+
+ {tt('create_group_jsx.name2')}
+
+ {tt('create_group_jsx.name3')}{name} +
+
+
+
+
+ {tt('create_group_jsx.logo')} +
+ this.onLogoChange(e, { applyFieldValue })} + validateOnBlur={false} + /> + {tt('group_settings_jsx.upload')} +
+
+
+
+
+ {tt('create_group_jsx.admin')} + this.onAdminChange(e, { applyFieldValue })} + validateOnBlur={false} + /> +
+
+
+ + +
+
+ )}}
+ } + + return
+
+

{tt('group_settings_jsx.title_GROUP', { + GROUP: title + })}

+
+ {form} +
+ } +} + +export default connect( + (state, ownProps) => { + const currentUser = state.user.getIn(['current']) + const currentAccount = currentUser && state.global.getIn(['accounts', currentUser.get('username')]) + + return { ...ownProps, + currentUser, + currentAccount, + currentGroup: state.user.get('current_group'), + } + }, + dispatch => ({ + }) +)(GroupSettings) diff --git a/src/components/modules/groups/GroupSettings.scss b/src/components/modules/groups/GroupSettings.scss new file mode 100644 index 00000000..927dd851 --- /dev/null +++ b/src/components/modules/groups/GroupSettings.scss @@ -0,0 +1,5 @@ +.GroupSettings { + h3 { + padding-left: 0.75rem; + } +} diff --git a/src/components/modules/groups/MyGroups.jsx b/src/components/modules/groups/MyGroups.jsx index a87169f4..b43f78f0 100644 --- a/src/components/modules/groups/MyGroups.jsx +++ b/src/components/modules/groups/MyGroups.jsx @@ -1,9 +1,7 @@ import React from 'react' import {connect} from 'react-redux' -import { Formik, Form, Field, ErrorMessage, } from 'formik' import { Map } from 'immutable' import { api, formatter } from 'golos-lib-js' -import { Asset, Price, AssetEditor } from 'golos-lib-js/lib/utils' import tt from 'counterpart' import g from 'app/redux/GlobalReducer' @@ -14,7 +12,6 @@ import DropdownMenu from 'app/components/elements/DropdownMenu' import ExtLink from 'app/components/elements/ExtLink' import Icon from 'app/components/elements/Icon' import LoadingIndicator from 'app/components/elements/LoadingIndicator' -import FormikAgent from 'app/components/elements/donate/FormikUtils' import DialogManager from 'app/components/elements/common/DialogManager' import { showLoginDialog } from 'app/components/dialogs/LoginDialog' import { getGroupLogo, getGroupMeta } from 'app/utils/groups' @@ -73,6 +70,11 @@ class MyGroups extends React.Component { })) } + showGroupSettings = (e, group) => { + e.preventDefault() + this.props.showGroupSettings({ group }) + } + _renderGroup = (group) => { const { name, json_metadata } = group @@ -99,11 +101,15 @@ class MyGroups extends React.Component { { e.preventDefault() }}> - - {kebabItems.length ? @@ -147,7 +153,7 @@ class MyGroups extends React.Component { let button if (hasGroups) { - button = } @@ -183,6 +189,9 @@ export default connect( showCreateGroup() { dispatch(user.actions.showCreateGroup({ redirectAfter: false })) }, + showGroupSettings({ group }) { + dispatch(user.actions.showGroupSettings({ group })) + }, deleteGroup: ({ owner, name, password, onSuccess, onError }) => { const opData = { diff --git a/src/components/modules/groups/MyGroups.scss b/src/components/modules/groups/MyGroups.scss index 2bfb29ea..bee27a8d 100644 --- a/src/components/modules/groups/MyGroups.scss +++ b/src/components/modules/groups/MyGroups.scss @@ -23,5 +23,9 @@ .DropdownMenu.show > .VerticalMenu { transform: translateX(-100%); } + .btn-title { + margin-left: 5px; + vertical-align: middle; + } } } diff --git a/src/locales/en.json b/src/locales/en.json index 75f6df4d..c318f2e3 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -138,7 +138,17 @@ "title": "My Groups", "empty": "You have not any groups yet. ", "empty2": "You can ", - "create": "create your own group" + "create": "create your own group", + "create_more": "+ Create a group", + "edit": "Edit", + "login_hint_GROUP": "(delete \"%(GROUP)s\" group)", + "members": "Members" + }, + "group_settings_jsx": { + "title_GROUP": "%(GROUP)s Group", + "submit": "Save", + "owner": "Owner", + "upload": "Upload" }, "emoji_i18n": { "categoriesLabel": "Категории", @@ -243,6 +253,7 @@ "delete": "Delete", "dismiss": "Dismiss", "edit": "Edit", + "groups": "Groups", "feed": "Feed", "incorrect_password": "Incorrect password", "posting_not_memo": "Use posting key now, not memo", diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 3e5003cb..a2a539b6 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -104,6 +104,8 @@ "create_group_jsx": { "title": "Название", "name": "Ссылка chat.golos.app/", + "name2": "Ссылка", + "name3": "chat.golos.app/", "logo": "Логотип", "admin": "Администратор", "encrypted": "Шифровать сообщения в группе", @@ -141,9 +143,16 @@ "empty": "У вас пока нет групп. ", "empty2": "Вы можете ", "create": "создать свою группу", - "create_more": "Создать еще группу", + "create_more": "+ Создать еще группу", "edit": "Изменить", - "login_hint_GROUP": "(удаления группы \"%(GROUP)s\")" + "login_hint_GROUP": "(удаления группы \"%(GROUP)s\")", + "members": "Участники" + }, + "group_settings_jsx": { + "title_GROUP": "Группа %(GROUP)s", + "submit": "Сохранить", + "owner": "Владелец", + "upload": "Загрузить" }, "emoji_i18n": { "categoriesLabel": "Категории", diff --git a/src/redux/UserReducer.js b/src/redux/UserReducer.js index ead90c9b..50e75e0d 100644 --- a/src/redux/UserReducer.js +++ b/src/redux/UserReducer.js @@ -7,6 +7,7 @@ const defaultState = fromJS({ show_donate_modal: false, show_create_group_modal: false, show_my_groups_modal: false, + show_group_settings_modal: false, show_app_download_modal: false, loginLoading: false, pub_keys_used: null, @@ -138,6 +139,12 @@ export default createModule({ { action: 'HIDE_CREATE_GROUP', reducer: state => state.set('show_create_group_modal', false) }, { action: 'SHOW_MY_GROUPS', reducer: state => state.set('show_my_groups_modal', true) }, { action: 'HIDE_MY_GROUPS', reducer: state => state.set('show_my_groups_modal', false) }, + { action: 'SHOW_GROUP_SETTINGS', reducer: (state, { payload: { group }}) => { + state = state.set('show_group_settings_modal', true) + state = state.set('current_group', fromJS(group)) + return state + }}, + { action: 'HIDE_GROUP_SETTINGS', reducer: state => state.set('show_group_settings_modal', false) }, { action: 'SHOW_APP_DOWNLOAD', reducer: state => state.set('show_app_download_modal', true) }, { action: 'HIDE_APP_DOWNLOAD', reducer: state => state.set('show_app_download_modal', false) }, { action: 'SET_DONATE_DEFAULTS', reducer: (state, {payload}) => state.set('donate_defaults', fromJS(payload)) }, diff --git a/src/utils/groups.js b/src/utils/groups.js index 2de29c40..91e36d48 100644 --- a/src/utils/groups.js +++ b/src/utils/groups.js @@ -9,6 +9,15 @@ const getGroupMeta = (json_metadata) => { return meta } +const getGroupTitle = (meta, name, maxLength = 20) => { + const title = meta.title || name + let titleShr = title + if (titleShr.length > maxLength) { + titleShr = titleShr.substring(0, maxLength - 3) + '...' + } + return titleShr +} + const getGroupLogo = (json_metadata) => { const meta = getGroupMeta(json_metadata) @@ -24,5 +33,6 @@ const getGroupLogo = (json_metadata) => { export { getGroupMeta, - getGroupLogo + getGroupTitle, + getGroupLogo, }