mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
ocm, add OCM_REMOTE_SERVERS (#4745)
* ocm, add OCM_REMOTE_SERVERS * update Co-authored-by: lian <lian@seafile.com>
This commit is contained in:
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -25,8 +25,8 @@ jobs:
|
|||||||
|
|
||||||
- name: clone and build
|
- name: clone and build
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=1 --branch=master git://github.com/haiwen/seafile-test-deploy /tmp/seafile-test-deploy
|
git clone --depth=1 --branch=8.0 git://github.com/haiwen/seafile-test-deploy /tmp/seafile-test-deploy
|
||||||
cd /tmp/seafile-test-deploy && git fetch origin python3:python3 && git checkout python3
|
cd /tmp/seafile-test-deploy && git fetch origin 8.0:8.0 && git checkout 8.0
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
|
|
||||||
- name: pip install
|
- name: pip install
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
|
import Select from 'react-select';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext } from '../../utils/constants';
|
import { gettext, ocmRemoteServers } from '../../utils/constants';
|
||||||
import { Input } from 'reactstrap';
|
import { Input } from 'reactstrap';
|
||||||
import { Button } from 'reactstrap';
|
import { Button } from 'reactstrap';
|
||||||
import { seafileAPI } from '../../utils/seafile-api.js';
|
import { seafileAPI } from '../../utils/seafile-api.js';
|
||||||
@@ -34,7 +35,7 @@ class ShareItem extends React.Component {
|
|||||||
let item = this.props.item;
|
let item = this.props.item;
|
||||||
return (
|
return (
|
||||||
<tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
<tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
||||||
<td>{item.to_sever_url}</td>
|
<td><a href={item.to_server_url} target="_blank">{item.to_server_name}</a></td>
|
||||||
<td className="name">{item.to_user}</td>
|
<td className="name">{item.to_user}</td>
|
||||||
<td>{Utils.sharePerms(item.permission)}</td>
|
<td>{Utils.sharePerms(item.permission)}</td>
|
||||||
{/* <td>
|
{/* <td>
|
||||||
@@ -67,9 +68,9 @@ class ShareList extends React.Component {
|
|||||||
<table className="table-thead-hidden">
|
<table className="table-thead-hidden">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="40%">{gettext('Server URL')}</th>
|
<th width="30%">{gettext('Server')}</th>
|
||||||
<th width="25%">{gettext('User Email')}</th>
|
<th width="25%">{gettext('User Email')}</th>
|
||||||
<th width="20%">{gettext('Permission')}</th>
|
<th width="30%">{gettext('Permission')}</th>
|
||||||
<th width="15%"></th>
|
<th width="15%"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -155,7 +156,7 @@ class ShareToOtherServer extends React.Component {
|
|||||||
|
|
||||||
handleURLChange = (e) => {
|
handleURLChange = (e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
toServerURL: e.target.value,
|
toServerURL: e.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,17 +186,17 @@ class ShareToOtherServer extends React.Component {
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="40%">{gettext('Server URL')}</th>
|
<th width="30%">{gettext('Server')}</th>
|
||||||
<th width="25%">{gettext('User Email')}</th>
|
<th width="25%">{gettext('User Email')}</th>
|
||||||
<th width="20%">{gettext('Permission')}</th>
|
<th width="30%">{gettext('Permission')}</th>
|
||||||
<th width="15%"></th>
|
<th width="15%"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Input
|
<Select
|
||||||
value={toServerURL}
|
options={ocmRemoteServers}
|
||||||
onChange={this.handleURLChange}
|
onChange={this.handleURLChange}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -17,7 +17,7 @@ class Content extends Component {
|
|||||||
const emptyTip = (
|
const emptyTip = (
|
||||||
<EmptyTip>
|
<EmptyTip>
|
||||||
<h2>{gettext('No libraries have been shared with you')}</h2>
|
<h2>{gettext('No libraries have been shared with you')}</h2>
|
||||||
<p>{gettext('No libraries have been shared directly with you. You can find more shared libraries at "Shared with groups".')}</p>
|
<p>{gettext('No libraries have been shared with you from other servers.')}</p>
|
||||||
</EmptyTip>
|
</EmptyTip>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -68,6 +68,7 @@ export const enableShowContactEmailWhenSearchUser = window.app.pageOptions.enabl
|
|||||||
export const maxUploadFileSize = window.app.pageOptions.maxUploadFileSize;
|
export const maxUploadFileSize = window.app.pageOptions.maxUploadFileSize;
|
||||||
export const maxNumberOfFilesForFileupload = window.app.pageOptions.maxNumberOfFilesForFileupload;
|
export const maxNumberOfFilesForFileupload = window.app.pageOptions.maxNumberOfFilesForFileupload;
|
||||||
export const enableOCM = window.app.pageOptions.enableOCM;
|
export const enableOCM = window.app.pageOptions.enableOCM;
|
||||||
|
export const ocmRemoteServers = window.app.pageOptions.ocmRemoteServers;
|
||||||
|
|
||||||
export const curNoteMsg = window.app.pageOptions.curNoteMsg;
|
export const curNoteMsg = window.app.pageOptions.curNoteMsg;
|
||||||
export const curNoteID = window.app.pageOptions.curNoteID;
|
export const curNoteID = window.app.pageOptions.curNoteID;
|
||||||
|
@@ -15,7 +15,7 @@ from seahub.api2.authentication import TokenAuthentication
|
|||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error
|
||||||
|
|
||||||
from seaserv import seafile_api, ccnet_api
|
from seaserv import seafile_api
|
||||||
|
|
||||||
from seahub.utils.repo import get_available_repo_perms, get_repo_owner
|
from seahub.utils.repo import get_available_repo_perms, get_repo_owner
|
||||||
from seahub.base.templatetags.seahub_tags import email2nickname
|
from seahub.base.templatetags.seahub_tags import email2nickname
|
||||||
@@ -25,7 +25,7 @@ from seahub.ocm.settings import ENABLE_OCM, SUPPORTED_OCM_PROTOCOLS, \
|
|||||||
OCM_SEAFILE_PROTOCOL, OCM_RESOURCE_TYPE_LIBRARY, OCM_API_VERSION, \
|
OCM_SEAFILE_PROTOCOL, OCM_RESOURCE_TYPE_LIBRARY, OCM_API_VERSION, \
|
||||||
OCM_SHARE_TYPES, OCM_ENDPOINT, OCM_PROVIDER_ID, OCM_NOTIFICATION_TYPE_LIST, \
|
OCM_SHARE_TYPES, OCM_ENDPOINT, OCM_PROVIDER_ID, OCM_NOTIFICATION_TYPE_LIST, \
|
||||||
OCM_NOTIFICATION_SHARE_UNSHARED, OCM_NOTIFICATION_SHARE_DECLINED, OCM_PROTOCOL_URL, \
|
OCM_NOTIFICATION_SHARE_UNSHARED, OCM_NOTIFICATION_SHARE_DECLINED, OCM_PROTOCOL_URL, \
|
||||||
OCM_NOTIFICATION_URL, OCM_CREATE_SHARE_URL
|
OCM_NOTIFICATION_URL, OCM_CREATE_SHARE_URL, OCM_REMOTE_SERVERS
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -36,6 +36,12 @@ SEAFILE_PERMISSION2OCM_PERMISSION = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_server_name_by_url(url):
|
||||||
|
for name_domain_dict in OCM_REMOTE_SERVERS:
|
||||||
|
if name_domain_dict['server_url'] == url:
|
||||||
|
return name_domain_dict['server_name']
|
||||||
|
|
||||||
|
|
||||||
def gen_shared_secret(length=23):
|
def gen_shared_secret(length=23):
|
||||||
return ''.join(random.choice(string.ascii_lowercase + string.digits) for i in range(length))
|
return ''.join(random.choice(string.ascii_lowercase + string.digits) for i in range(length))
|
||||||
|
|
||||||
@@ -128,7 +134,6 @@ class OCMSharesView(APIView):
|
|||||||
error_msg = 'providerId invalid.'
|
error_msg = 'providerId invalid.'
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
other ocm protocol fields currently not used
|
other ocm protocol fields currently not used
|
||||||
|
|
||||||
@@ -289,7 +294,10 @@ class OCMSharesPrepareView(APIView):
|
|||||||
|
|
||||||
ocm_share_list = []
|
ocm_share_list = []
|
||||||
for ocm_share in ocm_shares:
|
for ocm_share in ocm_shares:
|
||||||
ocm_share_list.append(ocm_share.to_dict())
|
ocm_info = ocm_share.to_dict()
|
||||||
|
ocm_info['to_server_name'] = get_server_name_by_url(ocm_share.to_server_url)
|
||||||
|
ocm_share_list.append(ocm_info)
|
||||||
|
|
||||||
return Response({'ocm_share_list': ocm_share_list})
|
return Response({'ocm_share_list': ocm_share_list})
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
@@ -396,7 +404,10 @@ class OCMSharesPrepareView(APIView):
|
|||||||
permission=permission,
|
permission=permission,
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(ocm_share.to_dict())
|
ocm_info = ocm_share.to_dict()
|
||||||
|
ocm_info['to_server_name'] = get_server_name_by_url(ocm_share.to_server_url)
|
||||||
|
|
||||||
|
return Response(ocm_info)
|
||||||
|
|
||||||
|
|
||||||
class OCMSharePrepareView(APIView):
|
class OCMSharePrepareView(APIView):
|
||||||
|
@@ -48,7 +48,7 @@ class OCMShare(models.Model):
|
|||||||
'shared_secret': self.shared_secret,
|
'shared_secret': self.shared_secret,
|
||||||
'from_user': self.from_user,
|
'from_user': self.from_user,
|
||||||
'to_user': self.to_user,
|
'to_user': self.to_user,
|
||||||
'to_sever_url': self.to_server_url,
|
'to_server_url': self.to_server_url,
|
||||||
'repo_id': self.repo_id,
|
'repo_id': self.repo_id,
|
||||||
'repo_name': self.repo_name,
|
'repo_name': self.repo_name,
|
||||||
'path': self.path,
|
'path': self.path,
|
||||||
|
@@ -32,3 +32,5 @@ VIA_REPO_TOKEN_URL = {
|
|||||||
'UPLOAD_LINK': 'api/v2.1/via-repo-token/upload-link/',
|
'UPLOAD_LINK': 'api/v2.1/via-repo-token/upload-link/',
|
||||||
'DOWNLOAD_LINK': 'api/v2.1/via-repo-token/download-link/',
|
'DOWNLOAD_LINK': 'api/v2.1/via-repo-token/download-link/',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OCM_REMOTE_SERVERS = getattr(settings, 'OCM_REMOTE_SERVERS', {})
|
||||||
|
@@ -102,6 +102,16 @@
|
|||||||
repoPasswordMinLength: {{repo_password_min_length}},
|
repoPasswordMinLength: {{repo_password_min_length}},
|
||||||
canAddPublicRepo: {% if can_add_public_repo %} true {% else %} false {% endif %},
|
canAddPublicRepo: {% if can_add_public_repo %} true {% else %} false {% endif %},
|
||||||
enableOCM: {% if enable_ocm %} true {% else %} false {% endif %},
|
enableOCM: {% if enable_ocm %} true {% else %} false {% endif %},
|
||||||
|
ocmRemoteServers: (function () {
|
||||||
|
var servers = [];
|
||||||
|
{% for server in ocm_remote_servers %}
|
||||||
|
servers.push({
|
||||||
|
'label': '{{server.server_name|escapejs}}',
|
||||||
|
'value': '{{server.server_url|escapejs}}',
|
||||||
|
});
|
||||||
|
{% endfor %}
|
||||||
|
return servers;
|
||||||
|
})(),
|
||||||
canInvitePeople: {% if enable_guest_invitation and user.permissions.can_invite_guest %} true {% else %} false {% endif %},
|
canInvitePeople: {% if enable_guest_invitation and user.permissions.can_invite_guest %} true {% else %} false {% endif %},
|
||||||
customNavItems: {% if custom_nav_items %} JSON.parse('{{ custom_nav_items | escapejs }}') {% else %} {{'[]'}} {% endif %},
|
customNavItems: {% if custom_nav_items %} JSON.parse('{{ custom_nav_items | escapejs }}') {% else %} {{'[]'}} {% endif %},
|
||||||
enableShowContactEmailWhenSearchUser: {% if enable_show_contact_email_when_search_user %} true {% else %} false {% endif %},
|
enableShowContactEmailWhenSearchUser: {% if enable_show_contact_email_when_search_user %} true {% else %} false {% endif %},
|
||||||
|
@@ -61,7 +61,7 @@ from seahub.settings import AVATAR_FILE_STORAGE, \
|
|||||||
|
|
||||||
from seahub.wopi.settings import ENABLE_OFFICE_WEB_APP
|
from seahub.wopi.settings import ENABLE_OFFICE_WEB_APP
|
||||||
from seahub.onlyoffice.settings import ENABLE_ONLYOFFICE
|
from seahub.onlyoffice.settings import ENABLE_ONLYOFFICE
|
||||||
from seahub.ocm.settings import ENABLE_OCM
|
from seahub.ocm.settings import ENABLE_OCM, OCM_REMOTE_SERVERS
|
||||||
from seahub.constants import HASH_URLS, PERMISSION_READ
|
from seahub.constants import HASH_URLS, PERMISSION_READ
|
||||||
|
|
||||||
from seahub.weixin.settings import ENABLE_WEIXIN
|
from seahub.weixin.settings import ENABLE_WEIXIN
|
||||||
@@ -1210,4 +1210,5 @@ def react_fake_view(request, **kwargs):
|
|||||||
'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
|
'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
|
||||||
'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS,
|
'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS,
|
||||||
'enable_ocm': ENABLE_OCM,
|
'enable_ocm': ENABLE_OCM,
|
||||||
|
'ocm_remote_servers': OCM_REMOTE_SERVERS,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user