From d9c9779327f7a87a0140ace89c6629ec229e10da Mon Sep 17 00:00:00 2001 From: awu0403 <76416779+awu0403@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:34:54 +0800 Subject: [PATCH] move user default quota (#7159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * move user default quota * update * optimize code --------- Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com> --- frontend/src/pages/org-admin/org-info.js | 41 ++----------------- .../org-admin/web-settings/input-item.js | 13 ++++-- .../org-admin/web-settings/web-settings.js | 37 +++++++++++++++-- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/frontend/src/pages/org-admin/org-info.js b/frontend/src/pages/org-admin/org-info.js index 10a941064b0..c2ebc6419f7 100644 --- a/frontend/src/pages/org-admin/org-info.js +++ b/frontend/src/pages/org-admin/org-info.js @@ -3,10 +3,8 @@ import { orgAdminAPI } from '../../utils/org-admin-api'; import { mediaUrl, gettext, orgMemberQuotaEnabled } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import MainPanelTopbar from './main-panel-topbar'; -import SetOrgUserDefaultQuota from '../../components/dialog/set-org-user-default-quota'; import '../../css/org-admin-info-page.css'; -const { orgID } = window.org.pageOptions; class OrgInfo extends Component { @@ -16,8 +14,6 @@ class OrgInfo extends Component { org_name: '', storage_quota: 0, storage_usage: 0, - isSetUserDefaultQuotaDialogOpen: false, - user_default_quota: 0, member_quota: 0, member_usage: 0, active_members: 0 @@ -29,33 +25,21 @@ class OrgInfo extends Component { const { org_id, org_name, member_quota, member_usage, active_members, - storage_quota, storage_usage, user_default_quota + storage_quota, storage_usage } = res.data; this.setState({ org_id, org_name, member_quota, member_usage, active_members, - storage_quota, storage_usage, user_default_quota + storage_quota, storage_usage }); }); } - toggleSetUserDefaultQuotaDialog = () => { - this.setState({ - isSetUserDefaultQuotaDialogOpen: !this.state.isSetUserDefaultQuotaDialogOpen - }); - }; - - updateQuota = (quota) => { - this.setState({ - user_default_quota: quota - }); - }; - render() { const { org_id, org_name, member_quota, member_usage, active_members, - storage_quota, storage_usage, user_default_quota + storage_quota, storage_usage } = this.state; return ( @@ -120,29 +104,10 @@ class OrgInfo extends Component {

{Utils.bytesToSize(storage_usage)}

)} - -
-

{gettext('User default quota')}

- {Utils.bytesToSize(user_default_quota)} - - - -
- {this.state.isSetUserDefaultQuotaDialogOpen && - - }
); } diff --git a/frontend/src/pages/org-admin/web-settings/input-item.js b/frontend/src/pages/org-admin/web-settings/input-item.js index 5587a4faf81..9d5c4df714f 100644 --- a/frontend/src/pages/org-admin/web-settings/input-item.js +++ b/frontend/src/pages/org-admin/web-settings/input-item.js @@ -1,6 +1,6 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { Input, Button } from 'reactstrap'; +import { Input, Button, InputGroup } from 'reactstrap'; import { gettext } from '../../../utils/constants'; import SettingItemBase from './setting-item-base'; @@ -12,6 +12,8 @@ const propTypes = { helpTip: PropTypes.string.isRequired, displayName: PropTypes.string.isRequired, disabled: PropTypes.bool.isRequired, + inputAddon: PropTypes.node, + valueFixed: PropTypes.number, }; class WebSettingInput extends Component { @@ -43,16 +45,18 @@ class WebSettingInput extends Component { }; onSubmit = (e) => { + const { valueFixed = 0 } = this.props; const value = this.state.value.trim(); if (value != this.props.value) { this.props.saveSetting(this.props.keyText, value); + this.setState({ value: parseInt(value).toFixed(valueFixed) }); } this.toggleBtns(); }; render() { const { isBtnsShown, value } = this.state; - const { helpTip, displayName, inputType, disabled } = this.props; + const { helpTip, displayName, inputType, disabled, inputAddon } = this.props; return ( : - + + + {inputAddon && inputAddon} + } extraContent={ isBtnsShown ? diff --git a/frontend/src/pages/org-admin/web-settings/web-settings.js b/frontend/src/pages/org-admin/web-settings/web-settings.js index b2466b0e17c..d7bcc1cf7dc 100644 --- a/frontend/src/pages/org-admin/web-settings/web-settings.js +++ b/frontend/src/pages/org-admin/web-settings/web-settings.js @@ -8,6 +8,7 @@ import MainPanelTopbar from '../main-panel-topbar'; import Section from './section'; import InputItem from './input-item'; import FileItem from './file-item'; +import { InputGroupAddon, InputGroupText } from 'reactstrap'; import '../../../css/system-admin-web-settings.css'; import CheckboxItem from '../../sys-admin/web-settings/checkbox-item'; @@ -27,19 +28,23 @@ class OrgWebSettings extends Component { file_ext_white_list: '', force_adfs_login: false, disable_org_encrypted_library: false, - disable_org_user_clean_trash: false + disable_org_user_clean_trash: false, + user_default_quota: '' }; } componentDidMount() { orgAdminAPI.orgAdminGetOrgInfo().then((res) => { + const user_default_quota = res.data.user_default_quota; + const i = parseInt(Math.floor(Math.log(user_default_quota) / Math.log(1000)), 10); this.setState({ loading: false, config_dict: res.data, file_ext_white_list: res.data.file_ext_white_list, force_adfs_login: res.data.force_adfs_login, disable_org_encrypted_library: res.data.disable_org_encrypted_library, - disable_org_user_clean_trash: res.data.disable_org_user_clean_trash + disable_org_user_clean_trash: res.data.disable_org_user_clean_trash, + user_default_quota: (user_default_quota / (1000 ** i)).toFixed(1), }); }).catch((error) => { this.setState({ @@ -82,8 +87,17 @@ class OrgWebSettings extends Component { }); }; + orgUpdateUserDefaultQuota = (key, quota) => { + orgAdminAPI.orgAdminSetOrgUserDefaultQuota(orgID, parseInt(quota)).then((res) => { + toaster.success(gettext('User default quota updated')); + }).catch((error) => { + let errMessage = Utils.getErrorMsg(error); + toaster.danger(errMessage); + }); + }; + render() { - const { loading, errorMsg, config_dict, file_ext_white_list, force_adfs_login, disable_org_encrypted_library, disable_org_user_clean_trash } = this.state; + const { loading, errorMsg, config_dict, file_ext_white_list, force_adfs_login, disable_org_encrypted_library, disable_org_user_clean_trash, user_default_quota } = this.state; let logoPath = this.state.logoPath; logoPath = logoPath.indexOf('image-view') != -1 ? logoPath : mediaUrl + logoPath; return ( @@ -169,6 +183,23 @@ class OrgWebSettings extends Component { } +
+ + + MB + + } + valueFixed={1} + /> + +
}