diff --git a/spug_api/apps/repository/views.py b/spug_api/apps/repository/views.py index 2b20186..292e14a 100644 --- a/spug_api/apps/repository/views.py +++ b/spug_api/apps/repository/views.py @@ -17,11 +17,12 @@ import json class RepositoryView(View): @auth('deploy.repository.view|deploy.request.add|deploy.request.edit') def get(self, request): + apps = request.user.deploy_perms['apps'] deploy_id = request.GET.get('deploy_id') data = Repository.objects.annotate( app_name=F('app__name'), env_name=F('env__name'), - created_by_user=F('created_by__nickname')) + created_by_user=F('created_by__nickname')).filter(deploy_id__in=apps) if deploy_id: data = data.filter(deploy_id=deploy_id, status='5') return json_response([x.to_view() for x in data]) diff --git a/spug_web/src/pages/ssh/FileManager.js b/spug_web/src/pages/ssh/FileManager.js index 9df0cd9..9f999b7 100644 --- a/spug_web/src/pages/ssh/FileManager.js +++ b/spug_web/src/pages/ssh/FileManager.js @@ -18,6 +18,7 @@ import { AuthButton, Action } from 'components'; import { http, uniqueId, X_TOKEN } from 'libs'; import lds from 'lodash'; import styles from './index.module.less' +import moment from 'moment'; class FileManager extends React.Component { @@ -25,6 +26,7 @@ class FileManager extends React.Component { super(props); this.input = null; this.input2 = null + this.pwdHistoryCaches = new Map() this.state = { fetching: false, showDot: false, @@ -72,6 +74,7 @@ class FileManager extends React.Component { }, { title: '修改时间', dataIndex: 'date', + sorter: (a, b) => moment(a.date).unix() - moment(b.date).unix(), width: 190 }, { title: '属性', @@ -97,13 +100,19 @@ class FileManager extends React.Component { }; fetchFiles = (pwd) => { - this.setState({fetching: true}); - pwd = pwd || this.state.pwd; + this.setState({ fetching: true }); + pwd = pwd || (this.pwdHistoryCaches.get(this.props.id) || []); + if (this.pwdHistoryCaches.has(this.props.id)) { + let pwdCache = this.pwdHistoryCaches.get(this.props.id) + pwdCache.push(pwd.length > 0 ? pwd.splice(-1) : null) + pwd = pwdCache.filter(x => !!x) + } const path = '/' + pwd.join('/'); return http.get('/api/file/', {params: {id: this.props.id, path}}) .then(res => { const objects = lds.orderBy(res, [this._kindSort, 'name'], ['desc', 'asc']); this.setState({objects, pwd}) + this.pwdHistoryCaches.set(this.props.id, pwd) this.state.inputPath !== null && this.setState({inputPath: path}) }) .finally(() => this.setState({fetching: false}))