From 59a925dd3afe53b59fd08ecb33ed2de0dce4ce39 Mon Sep 17 00:00:00 2001 From: ilearnit Date: Thu, 18 Apr 2019 08:08:56 +0000 Subject: [PATCH] fix shared with all --- .../shared-with-all/public-shared-view.js | 30 ++++++++++--------- frontend/src/utils/constants.js | 1 + seahub/templates/base_for_react.html | 1 + seahub/views/__init__.py | 1 + 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/shared-with-all/public-shared-view.js b/frontend/src/pages/shared-with-all/public-shared-view.js index c1d0c62118..44184d7c5f 100644 --- a/frontend/src/pages/shared-with-all/public-shared-view.js +++ b/frontend/src/pages/shared-with-all/public-shared-view.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import cookie from 'react-cookies'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem} from 'reactstrap'; import { seafileAPI } from '../../utils/seafile-api'; -import { gettext, loginUrl } from '../../utils/constants'; +import { gettext, loginUrl, canAddPublicRepo } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import Repo from '../../models/repo'; import toaster from '../../components/toast'; @@ -169,20 +169,22 @@ class PublicSharedView extends React.Component { return (
-
- -
- - - {gettext('Add Library')} - - - {gettext('Share existing libraries')} - {gettext('New Library')} - - + {canAddPublicRepo && +
+ +
+ + + {gettext('Add Library')} + + + {gettext('Share existing libraries')} + {gettext('New Library')} + + +
-
+ }
diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 6416d63d73..b91d603635 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -44,6 +44,7 @@ export const enableRepoHistorySetting = window.app.pageOptions.enableRepoHistory export const isSystemStaff = window.app.pageOptions.isSystemStaff; export const thumbnailSizeForOriginal = window.app.pageOptions.thumbnailSizeForOriginal; export const repoPasswordMinLength = window.app.pageOptions.repoPasswordMinLength; +export const canAddPublicRepo = window.app.pageOptions.canAddPublicRepo; export const curNoteMsg = window.app.pageOptions.curNoteMsg; export const curNoteID = window.app.pageOptions.curNoteID; diff --git a/seahub/templates/base_for_react.html b/seahub/templates/base_for_react.html index 8b0351d74e..38636de009 100644 --- a/seahub/templates/base_for_react.html +++ b/seahub/templates/base_for_react.html @@ -81,6 +81,7 @@ isSystemStaff: {% if request.user.is_staff %} true {% else %} false {% endif %}, thumbnailSizeForOriginal: {{ thumbnail_size_for_original }}, repoPasswordMinLength: {{repo_password_min_length}}, + canAddPublicRepo: {% if can_add_public_repo %} true {% else %} false {% endif %}, {% if request.user.is_authenticated and request.cur_note %} curNoteMsg: '{{ request.cur_note.message|urlize }}', diff --git a/seahub/views/__init__.py b/seahub/views/__init__.py index 65c5cdce52..ee87e2b993 100644 --- a/seahub/views/__init__.py +++ b/seahub/views/__init__.py @@ -1228,6 +1228,7 @@ def react_fake_view(request, **kwargs): 'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING, 'enable_reset_encrypted_repo_password': ENABLE_RESET_ENCRYPTED_REPO_PASSWORD, 'is_email_configured': IS_EMAIL_CONFIGURED, + 'can_add_public_repo': request.user.permissions.can_add_public_repo(), }) @login_required