You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
5.2 KiB
177 lines
5.2 KiB
8 years ago
|
/*
|
||
|
* Minio Browser (C) 2016 Minio, Inc.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
import * as actions from './actions'
|
||
|
import { minioBrowserPrefix } from './constants'
|
||
|
|
||
|
export default (state = {
|
||
|
buckets: [],
|
||
|
visibleBuckets: [],
|
||
|
objects: [],
|
||
|
storageInfo: {},
|
||
|
serverInfo: {},
|
||
|
currentBucket: '',
|
||
|
currentPath: '',
|
||
|
showMakeBucketModal: false,
|
||
|
uploads: {},
|
||
|
alert: {
|
||
|
show: false,
|
||
|
type: 'danger',
|
||
|
message: ''
|
||
|
},
|
||
|
loginError: false,
|
||
|
sortNameOrder: false,
|
||
|
sortSizeOrder: false,
|
||
|
sortDateOrder: false,
|
||
|
latestUiVersion: currentUiVersion,
|
||
|
sideBarActive: false,
|
||
|
loginRedirectPath: minioBrowserPrefix,
|
||
|
settings: {
|
||
|
accessKey: '',
|
||
|
secretKey: '',
|
||
|
secretKeyVisible: false
|
||
|
},
|
||
|
showSettings: false,
|
||
|
policies: [],
|
||
|
deleteConfirmation: {
|
||
|
object: '',
|
||
|
show: false
|
||
|
},
|
||
|
shareObject: {
|
||
|
show: false,
|
||
|
url: '',
|
||
|
expiry: 604800
|
||
|
},
|
||
|
prefixWritable: false
|
||
|
}, action) => {
|
||
|
let newState = Object.assign({}, state)
|
||
|
switch (action.type) {
|
||
|
case actions.SET_WEB:
|
||
|
newState.web = action.web
|
||
|
break
|
||
|
case actions.SET_BUCKETS:
|
||
|
newState.buckets = action.buckets
|
||
|
break
|
||
|
case actions.ADD_BUCKET:
|
||
|
newState.buckets = [action.bucket, ...newState.buckets]
|
||
|
newState.visibleBuckets = [action.bucket, ...newState.visibleBuckets]
|
||
|
break
|
||
|
case actions.SET_VISIBLE_BUCKETS:
|
||
|
newState.visibleBuckets = action.visibleBuckets
|
||
|
break
|
||
|
case actions.SET_CURRENT_BUCKET:
|
||
|
newState.currentBucket = action.currentBucket
|
||
|
break
|
||
|
case actions.SET_OBJECTS:
|
||
|
newState.objects = action.objects
|
||
|
break
|
||
|
case actions.SET_CURRENT_PATH:
|
||
|
newState.currentPath = action.currentPath
|
||
|
break
|
||
|
case actions.SET_STORAGE_INFO:
|
||
|
newState.storageInfo = action.storageInfo
|
||
|
break
|
||
|
case actions.SET_SERVER_INFO:
|
||
|
newState.serverInfo = action.serverInfo
|
||
|
break
|
||
|
case actions.SHOW_MAKEBUCKET_MODAL:
|
||
|
newState.showMakeBucketModal = action.showMakeBucketModal
|
||
|
break
|
||
|
case actions.UPLOAD_PROGRESS:
|
||
|
newState.uploads = Object.assign({}, newState.uploads)
|
||
|
newState.uploads[action.slug].loaded = action.loaded
|
||
|
break
|
||
|
case actions.ADD_UPLOAD:
|
||
|
newState.uploads = Object.assign({}, newState.uploads, {
|
||
|
[action.slug]: {
|
||
|
loaded: 0,
|
||
|
size: action.size,
|
||
|
xhr: action.xhr,
|
||
|
name: action.name
|
||
|
}
|
||
|
})
|
||
|
break
|
||
|
case actions.STOP_UPLOAD:
|
||
|
newState.uploads = Object.assign({}, newState.uploads)
|
||
|
delete newState.uploads[action.slug]
|
||
|
break
|
||
|
case actions.SET_ALERT:
|
||
|
if (newState.alert.alertTimeout) clearTimeout(newState.alert.alertTimeout)
|
||
|
if (!action.alert.show) {
|
||
|
newState.alert = Object.assign({}, newState.alert, {
|
||
|
show: false
|
||
|
})
|
||
|
} else {
|
||
|
newState.alert = action.alert
|
||
|
}
|
||
|
break
|
||
|
case actions.SET_LOGIN_ERROR:
|
||
|
newState.loginError = true
|
||
|
break
|
||
|
case actions.SET_SHOW_ABORT_MODAL:
|
||
|
newState.showAbortModal = action.showAbortModal
|
||
|
break
|
||
|
case actions.SHOW_ABOUT:
|
||
|
newState.showAbout = action.showAbout
|
||
|
break
|
||
|
case actions.SET_SORT_NAME_ORDER:
|
||
|
newState.sortNameOrder = action.sortNameOrder
|
||
|
break
|
||
|
case actions.SET_SORT_SIZE_ORDER:
|
||
|
newState.sortSizeOrder = action.sortSizeOrder
|
||
|
break
|
||
|
case actions.SET_SORT_DATE_ORDER:
|
||
|
newState.sortDateOrder = action.sortDateOrder
|
||
|
break
|
||
|
case actions.SET_LATEST_UI_VERSION:
|
||
|
newState.latestUiVersion = action.latestUiVersion
|
||
|
break
|
||
|
case actions.SET_SIDEBAR_STATUS:
|
||
|
newState.sidebarStatus = action.sidebarStatus
|
||
|
break
|
||
|
case actions.SET_LOGIN_REDIRECT_PATH:
|
||
|
newState.loginRedirectPath = action.path
|
||
|
case actions.SET_LOAD_BUCKET:
|
||
|
newState.loadBucket = action.loadBucket
|
||
|
break
|
||
|
case actions.SET_LOAD_PATH:
|
||
|
newState.loadPath = action.loadPath
|
||
|
break
|
||
|
case actions.SHOW_SETTINGS:
|
||
|
newState.showSettings = action.showSettings
|
||
|
break
|
||
|
case actions.SET_SETTINGS:
|
||
|
newState.settings = Object.assign({}, newState.settings, action.settings)
|
||
|
break
|
||
|
case actions.SHOW_BUCKET_POLICY:
|
||
|
newState.showBucketPolicy = action.showBucketPolicy
|
||
|
break
|
||
|
case actions.SET_POLICIES:
|
||
|
newState.policies = action.policies
|
||
|
break
|
||
|
case actions.DELETE_CONFIRMATION:
|
||
|
newState.deleteConfirmation = Object.assign({}, action.payload)
|
||
|
break
|
||
|
case actions.SET_SHARE_OBJECT:
|
||
|
newState.shareObject = Object.assign({}, action.shareObject)
|
||
|
break
|
||
|
case actions.SET_PREFIX_WRITABLE:
|
||
|
newState.prefixWritable = action.prefixWritable
|
||
|
break
|
||
|
}
|
||
|
return newState
|
||
|
}
|