mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
revert browser newux changes (#5714)
This commit is contained in:
@@ -20,19 +20,25 @@ import BucketDropdown from "./BucketDropdown"
|
||||
|
||||
export const Bucket = ({ bucket, isActive, selectBucket }) => {
|
||||
return (
|
||||
<div
|
||||
<li
|
||||
className={classNames({
|
||||
buckets__item: true,
|
||||
"buckets__item--active": isActive
|
||||
active: isActive
|
||||
})}
|
||||
onClick={e => {
|
||||
e.preventDefault()
|
||||
selectBucket(bucket)
|
||||
}}
|
||||
>
|
||||
<a href="">{bucket}</a>
|
||||
<BucketDropdown bucket={bucket} />
|
||||
</div>
|
||||
<a
|
||||
href=""
|
||||
className={classNames({
|
||||
"fesli-loading": false
|
||||
})}
|
||||
>
|
||||
{bucket}
|
||||
</a>
|
||||
<BucketDropdown bucket={bucket}/>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ import classNames from "classnames"
|
||||
import { connect } from "react-redux"
|
||||
import * as actionsBuckets from "./actions"
|
||||
import { getCurrentBucket } from "./selectors"
|
||||
import { Dropdown } from "react-bootstrap"
|
||||
import { MenuItem } from "react-bootstrap"
|
||||
import Dropdown from "react-bootstrap/lib/Dropdown"
|
||||
|
||||
export class BucketDropdown extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -45,35 +44,38 @@ export class BucketDropdown extends React.Component {
|
||||
render() {
|
||||
const { bucket, showBucketPolicy, deleteBucket, currentBucket } = this.props
|
||||
return (
|
||||
<Dropdown
|
||||
pullRight
|
||||
open={this.state.showBucketDropdown}
|
||||
onToggle={this.toggleDropdown.bind(this)}
|
||||
className="buckets__item__actions"
|
||||
<Dropdown
|
||||
open = {this.state.showBucketDropdown}
|
||||
onToggle = {this.toggleDropdown.bind(this)}
|
||||
className="bucket-dropdown"
|
||||
id="bucket-dropdown"
|
||||
>
|
||||
<Dropdown.Toggle noCaret className="dropdown-toggle--icon">
|
||||
<Dropdown.Toggle noCaret>
|
||||
<i className="zmdi zmdi-more-vert" />
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu>
|
||||
<MenuItem
|
||||
onClick={e => {
|
||||
e.stopPropagation()
|
||||
showBucketPolicy()
|
||||
}}
|
||||
>
|
||||
{" "}
|
||||
Edit Policy
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={e => {
|
||||
e.stopPropagation()
|
||||
deleteBucket(bucket)
|
||||
}}
|
||||
>
|
||||
{" "}
|
||||
Delete Bucket
|
||||
</MenuItem>
|
||||
<Dropdown.Menu className="dropdown-menu-right">
|
||||
<li>
|
||||
<a
|
||||
onClick={e => {
|
||||
e.stopPropagation()
|
||||
this.toggleDropdown()
|
||||
showBucketPolicy()
|
||||
}}
|
||||
>
|
||||
Edit policy
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
onClick={e => {
|
||||
e.stopPropagation()
|
||||
this.toggleDropdown()
|
||||
deleteBucket(bucket)
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</a>
|
||||
</li>
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
)
|
||||
|
||||
@@ -17,28 +17,14 @@
|
||||
import React from "react"
|
||||
import { connect } from "react-redux"
|
||||
import { Scrollbars } from "react-custom-scrollbars"
|
||||
import InfiniteScroll from "react-infinite-scroller"
|
||||
import * as actionsBuckets from "./actions"
|
||||
import { getFilteredBuckets } from "./selectors"
|
||||
import { getVisibleBuckets } from "./selectors"
|
||||
import BucketContainer from "./BucketContainer"
|
||||
import web from "../web"
|
||||
import history from "../history"
|
||||
import { pathSlice } from "../utils"
|
||||
|
||||
export class BucketList extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
page: 1
|
||||
}
|
||||
}
|
||||
componentWillReceiveProps(nexProps) {
|
||||
if (this.props.filter != nexProps.filter) {
|
||||
this.setState({
|
||||
page: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
componentWillMount() {
|
||||
const { fetchBuckets, setBucketList, selectBucket } = this.props
|
||||
if (web.LoggedIn()) {
|
||||
@@ -53,29 +39,19 @@ export class BucketList extends React.Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
loadNextPage() {
|
||||
this.setState({
|
||||
page: this.state.page + 1
|
||||
})
|
||||
}
|
||||
render() {
|
||||
const { filteredBuckets } = this.props
|
||||
const visibleBuckets = filteredBuckets.slice(0, this.state.page * 100)
|
||||
const { visibleBuckets } = this.props
|
||||
return (
|
||||
<div className="buckets__list">
|
||||
<InfiniteScroll
|
||||
pageStart={0}
|
||||
loadMore={this.loadNextPage.bind(this)}
|
||||
hasMore={filteredBuckets.length > visibleBuckets.length}
|
||||
useWindow={false}
|
||||
element="div"
|
||||
initialLoad={false}
|
||||
className="buckets__scroll"
|
||||
<div className="fesl-inner">
|
||||
<Scrollbars
|
||||
renderTrackVertical={props => <div className="scrollbar-vertical" />}
|
||||
>
|
||||
{visibleBuckets.map(bucket => (
|
||||
<BucketContainer key={bucket} bucket={bucket} />
|
||||
))}
|
||||
</InfiniteScroll>
|
||||
<ul>
|
||||
{visibleBuckets.map(bucket => (
|
||||
<BucketContainer key={bucket} bucket={bucket} />
|
||||
))}
|
||||
</ul>
|
||||
</Scrollbars>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -83,8 +59,7 @@ export class BucketList extends React.Component {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
filteredBuckets: getFilteredBuckets(state),
|
||||
filter: state.buckets.filter
|
||||
visibleBuckets: getVisibleBuckets(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,29 +21,24 @@ import * as actionsBuckets from "./actions"
|
||||
import PolicyInput from "./PolicyInput"
|
||||
import Policy from "./Policy"
|
||||
|
||||
export const BucketPolicyModal = ({
|
||||
showBucketPolicy,
|
||||
currentBucket,
|
||||
hideBucketPolicy,
|
||||
policies
|
||||
}) => {
|
||||
export const BucketPolicyModal = ({ showBucketPolicy, currentBucket, hideBucketPolicy, policies }) => {
|
||||
return (
|
||||
<Modal
|
||||
className="policy"
|
||||
animation={false}
|
||||
show={showBucketPolicy}
|
||||
onHide={hideBucketPolicy}
|
||||
<Modal className="modal-policy"
|
||||
animation={ false }
|
||||
show={ showBucketPolicy }
|
||||
onHide={ hideBucketPolicy }
|
||||
>
|
||||
<Modal.Header>
|
||||
Bucket Policy
|
||||
<small>Bucket Name: {currentBucket}</small>
|
||||
<i className="close" onClick={hideBucketPolicy} />
|
||||
</Modal.Header>
|
||||
<div className="policy__content">
|
||||
<ModalHeader>
|
||||
Bucket Policy (
|
||||
{ currentBucket })
|
||||
<button className="close close-alt" onClick={ hideBucketPolicy }>
|
||||
<span>×</span>
|
||||
</button>
|
||||
</ModalHeader>
|
||||
<div className="pm-body">
|
||||
<PolicyInput />
|
||||
{policies.map((policy, i) => (
|
||||
<Policy key={i} prefix={policy.prefix} policy={policy.policy} />
|
||||
))}
|
||||
{ policies.map((policy, i) => <Policy key={ i } prefix={ policy.prefix } policy={ policy.policy } />
|
||||
) }
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
@@ -63,4 +58,4 @@ const mapDispatchToProps = dispatch => {
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(BucketPolicyModal)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(BucketPolicyModal)
|
||||
@@ -19,17 +19,17 @@ import { connect } from "react-redux"
|
||||
import * as actionsBuckets from "./actions"
|
||||
|
||||
export const BucketSearch = ({ onChange }) => (
|
||||
<div className="buckets__search">
|
||||
<div className="form-group form-group--icon">
|
||||
<i className="form-group__icon zmdi zmdi-search" />
|
||||
<input
|
||||
className="form-group__field"
|
||||
type="text"
|
||||
onChange={e => onChange(e.target.value)}
|
||||
placeholder="Search Buckets..."
|
||||
/>
|
||||
<i className="form-group__helper" />
|
||||
</div>
|
||||
<div
|
||||
className="input-group ig-dark ig-left ig-search"
|
||||
style={{ display: "block" }}
|
||||
>
|
||||
<input
|
||||
className="ig-text"
|
||||
type="text"
|
||||
onChange={e => onChange(e.target.value)}
|
||||
placeholder="Search Buckets..."
|
||||
/>
|
||||
<i className="ig-helpers" />
|
||||
</div>
|
||||
)
|
||||
|
||||
|
||||
@@ -45,32 +45,30 @@ export class MakeBucketModal extends React.Component {
|
||||
const { showMakeBucketModal } = this.props
|
||||
return (
|
||||
<Modal
|
||||
className="create-bucket"
|
||||
className="modal-create-bucket"
|
||||
bsSize="small"
|
||||
animation={false}
|
||||
show={showMakeBucketModal}
|
||||
onHide={this.hideModal.bind(this)}
|
||||
>
|
||||
<i className="close" onClick={this.hideModal.bind(this)} />
|
||||
<Modal.Body>
|
||||
<button className="close close-alt" onClick={this.hideModal.bind(this)}>
|
||||
<span>×</span>
|
||||
</button>
|
||||
<ModalBody>
|
||||
<form onSubmit={this.onSubmit.bind(this)}>
|
||||
<div className="form-group form-group--centered">
|
||||
<div className="input-group">
|
||||
<input
|
||||
className="form-group__field"
|
||||
className="ig-text"
|
||||
type="text"
|
||||
placeholder="Bucket Name"
|
||||
value={this.state.bucketName}
|
||||
onChange={e =>
|
||||
this.setState({
|
||||
bucketName: e.target.value
|
||||
})
|
||||
}
|
||||
onChange={e => this.setState({ bucketName: e.target.value })}
|
||||
autoFocus
|
||||
/>
|
||||
<i className="form-group__helper" />
|
||||
<i className="ig-helpers" />
|
||||
</div>
|
||||
</form>
|
||||
</Modal.Body>
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { READ_ONLY, WRITE_ONLY, READ_WRITE } from '../constants'
|
||||
|
||||
import React from "react"
|
||||
import { connect } from "react-redux"
|
||||
import classnames from "classnames"
|
||||
import * as actionsBuckets from "./actions"
|
||||
import * as actionsAlert from "../alert/actions"
|
||||
import web from "../web"
|
||||
@@ -23,55 +26,51 @@ import web from "../web"
|
||||
export class Policy extends React.Component {
|
||||
removePolicy(e) {
|
||||
e.preventDefault()
|
||||
const { currentBucket, prefix, fetchPolicies, showAlert } = this.props
|
||||
web
|
||||
.SetBucketPolicy({
|
||||
const {currentBucket, prefix, fetchPolicies, showAlert} = this.props
|
||||
web.
|
||||
SetBucketPolicy({
|
||||
bucketName: currentBucket,
|
||||
prefix: prefix,
|
||||
policy: "none"
|
||||
policy: 'none'
|
||||
})
|
||||
.then(() => {
|
||||
fetchPolicies(currentBucket)
|
||||
})
|
||||
.catch(e => showAlert("danger", e.message))
|
||||
.catch(e => showAlert('danger', e.message))
|
||||
}
|
||||
|
||||
render() {
|
||||
const { policy, prefix } = this.props
|
||||
const {policy, prefix} = this.props
|
||||
let newPrefix = prefix
|
||||
|
||||
if (newPrefix === "") newPrefix = "*"
|
||||
let policyUpdated =
|
||||
policy == "readonly"
|
||||
? "Read Only"
|
||||
: policy == "writeonly"
|
||||
? "Write Only"
|
||||
: policy == "readwrite" ? "Read and Write" : ""
|
||||
if (newPrefix === '')
|
||||
newPrefix = '*'
|
||||
|
||||
return (
|
||||
<div className="policy__row">
|
||||
<div className="form-group">
|
||||
<input
|
||||
type="text"
|
||||
value={newPrefix}
|
||||
className="form-group__field form-group__field--static"
|
||||
readOnly
|
||||
/>
|
||||
<div className="pmb-list">
|
||||
<div className="pmbl-item">
|
||||
{ newPrefix }
|
||||
</div>
|
||||
<div className="form-group policy__access">
|
||||
<input
|
||||
type="text"
|
||||
value={policyUpdated}
|
||||
className="form-group__field form-group__field--static"
|
||||
readOnly
|
||||
/>
|
||||
<div className="pmbl-item">
|
||||
<select className="form-control"
|
||||
disabled
|
||||
value={ policy }>
|
||||
<option value={ READ_ONLY }>
|
||||
Read Only
|
||||
</option>
|
||||
<option value={ WRITE_ONLY }>
|
||||
Write Only
|
||||
</option>
|
||||
<option value={ READ_WRITE }>
|
||||
Read and Write
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="pmbl-item">
|
||||
<button className="btn btn-block btn-danger" onClick={ this.removePolicy.bind(this) }>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
className="btn btn--sm btn--danger"
|
||||
onClick={this.removePolicy.bind(this)}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -87,13 +86,8 @@ const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchPolicies: bucket => dispatch(actionsBuckets.fetchPolicies(bucket)),
|
||||
showAlert: (type, message) =>
|
||||
dispatch(
|
||||
actionsAlert.set({
|
||||
type: type,
|
||||
message: message
|
||||
})
|
||||
)
|
||||
dispatch(actionsAlert.set({ type: type, message: message }))
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Policy)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Policy)
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { READ_ONLY, WRITE_ONLY, READ_WRITE } from "../constants"
|
||||
import { READ_ONLY, WRITE_ONLY, READ_WRITE } from '../constants'
|
||||
|
||||
import React from "react"
|
||||
import { connect } from "react-redux"
|
||||
@@ -37,61 +37,61 @@ export class PolicyInput extends React.Component {
|
||||
handlePolicySubmit(e) {
|
||||
e.preventDefault()
|
||||
const { currentBucket, fetchPolicies, showAlert } = this.props
|
||||
|
||||
if (this.prefix.value === "*") this.prefix.value = ""
|
||||
|
||||
|
||||
if (this.prefix.value === "*")
|
||||
this.prefix.value = ""
|
||||
|
||||
let policyAlreadyExists = this.props.policies.some(
|
||||
elem =>
|
||||
this.prefix.value === elem.prefix && this.policy.value === elem.policy
|
||||
elem => this.prefix.value === elem.prefix && this.policy.value === elem.policy
|
||||
)
|
||||
if (policyAlreadyExists) {
|
||||
showAlert("danger", "Policy for this prefix already exists.")
|
||||
return
|
||||
}
|
||||
|
||||
web
|
||||
.SetBucketPolicy({
|
||||
|
||||
web.
|
||||
SetBucketPolicy({
|
||||
bucketName: currentBucket,
|
||||
prefix: this.prefix.value,
|
||||
policy: this.policy.value
|
||||
})
|
||||
.then(() => {
|
||||
fetchPolicies(currentBucket)
|
||||
this.prefix.value = ""
|
||||
this.prefix.value = ''
|
||||
})
|
||||
.catch(e => showAlert("danger", e.message))
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="policy__row policy__row--add">
|
||||
<div className="form-group">
|
||||
<input
|
||||
<header className="pmb-list">
|
||||
<div className="pmbl-item">
|
||||
<input
|
||||
type="text"
|
||||
ref={prefix => (this.prefix = prefix)}
|
||||
className="form-group__field"
|
||||
ref={ prefix => this.prefix = prefix }
|
||||
className="form-control"
|
||||
placeholder="Prefix"
|
||||
/>
|
||||
<i className="form-group__helper" />
|
||||
</div>
|
||||
<div className="form-group policy__access">
|
||||
<select
|
||||
ref={policy => (this.policy = policy)}
|
||||
className="form-group__field select"
|
||||
>
|
||||
<option value={READ_ONLY}>Read Only</option>
|
||||
<option value={WRITE_ONLY}>Write Only</option>
|
||||
<option value={READ_WRITE}>Read and Write</option>
|
||||
<div className="pmbl-item">
|
||||
<select ref={ policy => this.policy = policy } className="form-control">
|
||||
<option value={ READ_ONLY }>
|
||||
Read Only
|
||||
</option>
|
||||
<option value={ WRITE_ONLY }>
|
||||
Write Only
|
||||
</option>
|
||||
<option value={ READ_WRITE }>
|
||||
Read and Write
|
||||
</option>
|
||||
</select>
|
||||
<i className="form-group__helper" />
|
||||
</div>
|
||||
<button
|
||||
className="btn btn--sm btn--primary"
|
||||
onClick={this.handlePolicySubmit.bind(this)}
|
||||
>
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
<div className="pmbl-item">
|
||||
<button className="btn btn-block btn-primary" onClick={ this.handlePolicySubmit.bind(this) }>
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -108,13 +108,8 @@ const mapDispatchToProps = dispatch => {
|
||||
fetchPolicies: bucket => dispatch(actionsBuckets.fetchPolicies(bucket)),
|
||||
setPolicies: policies => dispatch(actionsBuckets.setPolicies(policies)),
|
||||
showAlert: (type, message) =>
|
||||
dispatch(
|
||||
actionsAlert.set({
|
||||
type: type,
|
||||
message: message
|
||||
})
|
||||
)
|
||||
dispatch(actionsAlert.set({ type: type, message: message }))
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(PolicyInput)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(PolicyInput)
|
||||
@@ -28,14 +28,12 @@ describe("Bucket", () => {
|
||||
const wrapper = shallow(
|
||||
<Bucket bucket={"test"} selectBucket={selectBucket} />
|
||||
)
|
||||
wrapper.find("div").simulate("click", {
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
wrapper.find("li").simulate("click", { preventDefault: jest.fn() })
|
||||
expect(selectBucket).toHaveBeenCalledWith("test")
|
||||
})
|
||||
|
||||
it("should highlight the selected bucket", () => {
|
||||
const wrapper = shallow(<Bucket bucket={"test"} isActive={true} />)
|
||||
expect(wrapper.find("div").hasClass("buckets__item--active")).toBeTruthy()
|
||||
expect(wrapper.find("li").hasClass("active")).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -31,23 +31,21 @@ describe("BucketContainer", () => {
|
||||
})
|
||||
store.dispatch = jest.fn()
|
||||
})
|
||||
|
||||
|
||||
it("should render without crashing", () => {
|
||||
shallow(<BucketContainer store={store} />)
|
||||
shallow(<BucketContainer store={store}/>)
|
||||
})
|
||||
|
||||
it("maps state and dispatch to props", () => {
|
||||
const wrapper = shallow(<BucketContainer store={store} />)
|
||||
expect(wrapper.props()).toEqual(
|
||||
expect.objectContaining({
|
||||
isActive: expect.any(Boolean),
|
||||
selectBucket: expect.any(Function)
|
||||
})
|
||||
)
|
||||
it('maps state and dispatch to props', () => {
|
||||
const wrapper = shallow(<BucketContainer store={store}/>)
|
||||
expect(wrapper.props()).toEqual(expect.objectContaining({
|
||||
isActive: expect.any(Boolean),
|
||||
selectBucket: expect.any(Function)
|
||||
}))
|
||||
})
|
||||
|
||||
it("maps selectBucket to dispatch action", () => {
|
||||
const wrapper = shallow(<BucketContainer store={store} />)
|
||||
it('maps selectBucket to dispatch action', () => {
|
||||
const wrapper = shallow(<BucketContainer store={store}/>)
|
||||
wrapper.props().selectBucket()
|
||||
expect(store.dispatch).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -24,9 +24,13 @@ describe("BucketDropdown", () => {
|
||||
})
|
||||
|
||||
it("should call toggleDropdown on dropdown toggle", () => {
|
||||
const spy = jest.spyOn(BucketDropdown.prototype, "toggleDropdown")
|
||||
const wrapper = shallow(<BucketDropdown />)
|
||||
wrapper.find("Uncontrolled(Dropdown)").simulate("toggle")
|
||||
const spy = jest.spyOn(BucketDropdown.prototype, 'toggleDropdown')
|
||||
const wrapper = shallow(
|
||||
<BucketDropdown />
|
||||
)
|
||||
wrapper
|
||||
.find("Uncontrolled(Dropdown)")
|
||||
.simulate("toggle")
|
||||
expect(spy).toHaveBeenCalled()
|
||||
spy.mockReset()
|
||||
spy.mockRestore()
|
||||
@@ -38,11 +42,9 @@ describe("BucketDropdown", () => {
|
||||
<BucketDropdown showBucketPolicy={showBucketPolicy} />
|
||||
)
|
||||
wrapper
|
||||
.find("MenuItem")
|
||||
.find("li a")
|
||||
.at(0)
|
||||
.simulate("click", {
|
||||
stopPropagation: jest.fn()
|
||||
})
|
||||
.simulate("click", { stopPropagation: jest.fn() })
|
||||
expect(showBucketPolicy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -52,11 +54,9 @@ describe("BucketDropdown", () => {
|
||||
<BucketDropdown bucket={"test"} deleteBucket={deleteBucket} />
|
||||
)
|
||||
wrapper
|
||||
.find("MenuItem")
|
||||
.find("li a")
|
||||
.at(1)
|
||||
.simulate("click", {
|
||||
stopPropagation: jest.fn()
|
||||
})
|
||||
.simulate("click", { stopPropagation: jest.fn() })
|
||||
expect(deleteBucket).toHaveBeenCalledWith("test")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,13 +29,13 @@ jest.mock("../../web", () => ({
|
||||
describe("BucketList", () => {
|
||||
it("should render without crashing", () => {
|
||||
const fetchBuckets = jest.fn()
|
||||
shallow(<BucketList filteredBuckets={[]} fetchBuckets={fetchBuckets} />)
|
||||
shallow(<BucketList visibleBuckets={[]} fetchBuckets={fetchBuckets} />)
|
||||
})
|
||||
|
||||
it("should call fetchBuckets before component is mounted", () => {
|
||||
const fetchBuckets = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<BucketList filteredBuckets={[]} fetchBuckets={fetchBuckets} />
|
||||
<BucketList visibleBuckets={[]} fetchBuckets={fetchBuckets} />
|
||||
)
|
||||
expect(fetchBuckets).toHaveBeenCalled()
|
||||
})
|
||||
@@ -46,7 +46,7 @@ describe("BucketList", () => {
|
||||
history.push("/bk1/pre1")
|
||||
const wrapper = shallow(
|
||||
<BucketList
|
||||
filteredBuckets={[]}
|
||||
visibleBuckets={[]}
|
||||
setBucketList={setBucketList}
|
||||
selectBucket={selectBucket}
|
||||
/>
|
||||
|
||||
@@ -21,7 +21,7 @@ import { READ_ONLY, WRITE_ONLY, READ_WRITE } from "../../constants"
|
||||
|
||||
describe("BucketPolicyModal", () => {
|
||||
it("should render without crashing", () => {
|
||||
shallow(<BucketPolicyModal policies={[]} />)
|
||||
shallow(<BucketPolicyModal policies={[]}/>)
|
||||
})
|
||||
|
||||
it("should call hideBucketPolicy when close button is clicked", () => {
|
||||
@@ -29,13 +29,13 @@ describe("BucketPolicyModal", () => {
|
||||
const wrapper = shallow(
|
||||
<BucketPolicyModal hideBucketPolicy={hideBucketPolicy} policies={[]} />
|
||||
)
|
||||
wrapper.find("i.close").simulate("click")
|
||||
wrapper.find("button").simulate("click")
|
||||
expect(hideBucketPolicy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should include the PolicyInput and Policy components when there are any policies", () => {
|
||||
const wrapper = shallow(
|
||||
<BucketPolicyModal policies={[{ prefix: "test", policy: READ_ONLY }]} />
|
||||
<BucketPolicyModal policies={ [{prefix: "test", policy: READ_ONLY}] } />
|
||||
)
|
||||
expect(wrapper.find("Connect(PolicyInput)").length).toBe(1)
|
||||
expect(wrapper.find("Connect(Policy)").length).toBe(1)
|
||||
|
||||
@@ -26,11 +26,7 @@ describe("BucketSearch", () => {
|
||||
it("should call onChange with search text", () => {
|
||||
const onChange = jest.fn()
|
||||
const wrapper = shallow(<BucketSearch onChange={onChange} />)
|
||||
wrapper.find("input").simulate("change", {
|
||||
target: {
|
||||
value: "test"
|
||||
}
|
||||
})
|
||||
wrapper.find("input").simulate("change", { target: { value: "test" } })
|
||||
expect(onChange).toHaveBeenCalledWith("test")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("MakeBucketModal", () => {
|
||||
const wrapper = shallow(
|
||||
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />
|
||||
)
|
||||
wrapper.find("i.close").simulate("click")
|
||||
wrapper.find("button").simulate("click")
|
||||
expect(hideMakeBucketModal).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -38,12 +38,10 @@ describe("MakeBucketModal", () => {
|
||||
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />
|
||||
)
|
||||
wrapper.find("input").simulate("change", {
|
||||
target: {
|
||||
value: "test"
|
||||
}
|
||||
target: { value: "test" }
|
||||
})
|
||||
expect(wrapper.state("bucketName")).toBe("test")
|
||||
wrapper.find("i.close").simulate("click")
|
||||
wrapper.find("button").simulate("click")
|
||||
expect(wrapper.state("bucketName")).toBe("")
|
||||
})
|
||||
|
||||
@@ -57,13 +55,9 @@ describe("MakeBucketModal", () => {
|
||||
/>
|
||||
)
|
||||
wrapper.find("input").simulate("change", {
|
||||
target: {
|
||||
value: "test"
|
||||
}
|
||||
})
|
||||
wrapper.find("form").simulate("submit", {
|
||||
preventDefault: jest.fn()
|
||||
target: { value: "test" }
|
||||
})
|
||||
wrapper.find("form").simulate("submit", { preventDefault: jest.fn() })
|
||||
expect(makeBucket).toHaveBeenCalledWith("test")
|
||||
})
|
||||
|
||||
@@ -77,13 +71,9 @@ describe("MakeBucketModal", () => {
|
||||
/>
|
||||
)
|
||||
wrapper.find("input").simulate("change", {
|
||||
target: {
|
||||
value: "test"
|
||||
}
|
||||
})
|
||||
wrapper.find("form").simulate("submit", {
|
||||
preventDefault: jest.fn()
|
||||
target: { value: "test" }
|
||||
})
|
||||
wrapper.find("form").simulate("submit", { preventDefault: jest.fn() })
|
||||
expect(hideMakeBucketModal).toHaveBeenCalled()
|
||||
expect(wrapper.state("bucketName")).toBe("")
|
||||
})
|
||||
|
||||
@@ -28,31 +28,27 @@ jest.mock("../../web", () => ({
|
||||
|
||||
describe("Policy", () => {
|
||||
it("should render without crashing", () => {
|
||||
shallow(
|
||||
<Policy currentBucket={"bucket"} prefix={"foo"} policy={READ_ONLY} />
|
||||
)
|
||||
shallow(<Policy currentBucket={"bucket"} prefix={"foo"} policy={READ_ONLY} />)
|
||||
})
|
||||
|
||||
it("should call web.setBucketPolicy and fetchPolicies on submit", () => {
|
||||
const fetchPolicies = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<Policy
|
||||
<Policy
|
||||
currentBucket={"bucket"}
|
||||
prefix={"foo"}
|
||||
policy={READ_ONLY}
|
||||
fetchPolicies={fetchPolicies}
|
||||
/>
|
||||
)
|
||||
wrapper.find("button").simulate("click", {
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
wrapper.find("button").simulate("click", { preventDefault: jest.fn() })
|
||||
|
||||
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
||||
bucketName: "bucket",
|
||||
prefix: "foo",
|
||||
policy: "none"
|
||||
})
|
||||
|
||||
|
||||
setImmediate(() => {
|
||||
expect(fetchPolicies).toHaveBeenCalledWith("bucket")
|
||||
})
|
||||
@@ -62,11 +58,6 @@ describe("Policy", () => {
|
||||
const wrapper = shallow(
|
||||
<Policy currentBucket={"bucket"} prefix={""} policy={READ_ONLY} />
|
||||
)
|
||||
expect(
|
||||
wrapper
|
||||
.find("input")
|
||||
.at(0)
|
||||
.prop("value")
|
||||
).toEqual("*")
|
||||
expect(wrapper.find(".pmbl-item").at(0).text()).toEqual("*")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,9 +29,7 @@ jest.mock("../../web", () => ({
|
||||
describe("PolicyInput", () => {
|
||||
it("should render without crashing", () => {
|
||||
const fetchPolicies = jest.fn()
|
||||
shallow(
|
||||
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />
|
||||
)
|
||||
shallow(<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies}/>)
|
||||
})
|
||||
|
||||
it("should call fetchPolicies after the component has mounted", () => {
|
||||
@@ -47,21 +45,11 @@ describe("PolicyInput", () => {
|
||||
it("should call web.setBucketPolicy and fetchPolicies on submit", () => {
|
||||
const fetchPolicies = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<PolicyInput
|
||||
currentBucket={"bucket"}
|
||||
policies={[]}
|
||||
fetchPolicies={fetchPolicies}
|
||||
/>
|
||||
<PolicyInput currentBucket={"bucket"} policies={[]} fetchPolicies={fetchPolicies}/>
|
||||
)
|
||||
wrapper.instance().prefix = {
|
||||
value: "baz"
|
||||
}
|
||||
wrapper.instance().policy = {
|
||||
value: READ_ONLY
|
||||
}
|
||||
wrapper.find("button").simulate("click", {
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
wrapper.instance().prefix = { value: "baz" }
|
||||
wrapper.instance().policy = { value: READ_ONLY }
|
||||
wrapper.find("button").simulate("click", { preventDefault: jest.fn() })
|
||||
|
||||
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
||||
bucketName: "bucket",
|
||||
@@ -77,25 +65,13 @@ describe("PolicyInput", () => {
|
||||
it("should change the prefix '*' to an empty string", () => {
|
||||
const fetchPolicies = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<PolicyInput
|
||||
currentBucket={"bucket"}
|
||||
policies={[]}
|
||||
fetchPolicies={fetchPolicies}
|
||||
/>
|
||||
<PolicyInput currentBucket={"bucket"} policies={[]} fetchPolicies={fetchPolicies}/>
|
||||
)
|
||||
wrapper.instance().prefix = {
|
||||
value: "*"
|
||||
}
|
||||
wrapper.instance().policy = {
|
||||
value: READ_ONLY
|
||||
}
|
||||
wrapper.instance().prefix = { value: "*" }
|
||||
wrapper.instance().policy = { value: READ_ONLY }
|
||||
|
||||
wrapper.find("button").simulate("click", {
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
wrapper.find("button").simulate("click", { preventDefault: jest.fn() })
|
||||
|
||||
expect(wrapper.instance().prefix).toEqual({
|
||||
value: ""
|
||||
})
|
||||
expect(wrapper.instance().prefix).toEqual({ value: "" })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,20 +17,12 @@
|
||||
import configureStore from "redux-mock-store"
|
||||
import thunk from "redux-thunk"
|
||||
import * as actionsBuckets from "../actions"
|
||||
import * as objectActions from "../../objects/actions"
|
||||
import history from "../../history"
|
||||
|
||||
jest.mock("../../web", () => ({
|
||||
ListBuckets: jest.fn(() => {
|
||||
return Promise.resolve({
|
||||
buckets: [
|
||||
{
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2"
|
||||
}
|
||||
]
|
||||
})
|
||||
return Promise.resolve({ buckets: [{ name: "test1" }, { name: "test2" }] })
|
||||
}),
|
||||
MakeBucket: jest.fn(() => {
|
||||
return Promise.resolve()
|
||||
@@ -51,14 +43,8 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SET_LIST and buckets/SET_CURRENT_BUCKET with first bucket after fetching the buckets", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SET_LIST",
|
||||
buckets: ["test1", "test2"]
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test1"
|
||||
}
|
||||
{ type: "buckets/SET_LIST", buckets: ["test1", "test2"] },
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" }
|
||||
]
|
||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -70,14 +56,8 @@ describe("Buckets actions", () => {
|
||||
history.push("/test2")
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SET_LIST",
|
||||
buckets: ["test1", "test2"]
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test2"
|
||||
}
|
||||
{ type: "buckets/SET_LIST", buckets: ["test1", "test2"] },
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test2" }
|
||||
]
|
||||
window.location
|
||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||
@@ -90,14 +70,8 @@ describe("Buckets actions", () => {
|
||||
history.push("/test3")
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SET_LIST",
|
||||
buckets: ["test1", "test2"]
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test1"
|
||||
}
|
||||
{ type: "buckets/SET_LIST", buckets: ["test1", "test2"] },
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" }
|
||||
]
|
||||
window.location
|
||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||
@@ -109,10 +83,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SET_CURRENT_BUCKET action when selectBucket is called", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test1"
|
||||
}
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" }
|
||||
]
|
||||
store.dispatch(actionsBuckets.selectBucket("test1"))
|
||||
const actions = store.getActions()
|
||||
@@ -122,10 +93,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SHOW_MAKE_BUCKET_MODAL for showMakeBucketModal", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
||||
show: true
|
||||
}
|
||||
{ type: "buckets/SHOW_MAKE_BUCKET_MODAL", show: true }
|
||||
]
|
||||
store.dispatch(actionsBuckets.showMakeBucketModal())
|
||||
const actions = store.getActions()
|
||||
@@ -135,10 +103,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SHOW_MAKE_BUCKET_MODAL for hideMakeBucketModal", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
||||
show: false
|
||||
}
|
||||
{ type: "buckets/SHOW_MAKE_BUCKET_MODAL", show: false }
|
||||
]
|
||||
store.dispatch(actionsBuckets.hideMakeBucketModal())
|
||||
const actions = store.getActions()
|
||||
@@ -148,10 +113,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SHOW_BUCKET_POLICY for showBucketPolicy", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SHOW_BUCKET_POLICY",
|
||||
show: true
|
||||
}
|
||||
{ type: "buckets/SHOW_BUCKET_POLICY", show: true }
|
||||
]
|
||||
store.dispatch(actionsBuckets.showBucketPolicy())
|
||||
const actions = store.getActions()
|
||||
@@ -161,10 +123,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SHOW_BUCKET_POLICY for hideBucketPolicy", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SHOW_BUCKET_POLICY",
|
||||
show: false
|
||||
}
|
||||
{ type: "buckets/SHOW_BUCKET_POLICY", show: false }
|
||||
]
|
||||
store.dispatch(actionsBuckets.hideBucketPolicy())
|
||||
const actions = store.getActions()
|
||||
@@ -174,10 +133,7 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/SET_POLICIES action", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/SET_POLICIES",
|
||||
policies: ["test1", "test2"]
|
||||
}
|
||||
{ type: "buckets/SET_POLICIES", policies: ["test1", "test2"] }
|
||||
]
|
||||
store.dispatch(actionsBuckets.setPolicies(["test1", "test2"]))
|
||||
const actions = store.getActions()
|
||||
@@ -186,12 +142,7 @@ describe("Buckets actions", () => {
|
||||
|
||||
it("creates buckets/ADD action", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/ADD",
|
||||
bucket: "test"
|
||||
}
|
||||
]
|
||||
const expectedActions = [{ type: "buckets/ADD", bucket: "test" }]
|
||||
store.dispatch(actionsBuckets.addBucket("test"))
|
||||
const actions = store.getActions()
|
||||
expect(actions).toEqual(expectedActions)
|
||||
@@ -199,12 +150,7 @@ describe("Buckets actions", () => {
|
||||
|
||||
it("creates buckets/REMOVE action", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/REMOVE",
|
||||
bucket: "test"
|
||||
}
|
||||
]
|
||||
const expectedActions = [{ type: "buckets/REMOVE", bucket: "test" }]
|
||||
store.dispatch(actionsBuckets.removeBucket("test"))
|
||||
const actions = store.getActions()
|
||||
expect(actions).toEqual(expectedActions)
|
||||
@@ -213,14 +159,8 @@ describe("Buckets actions", () => {
|
||||
it("creates buckets/ADD and buckets/SET_CURRENT_BUCKET after creating the bucket", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "buckets/ADD",
|
||||
bucket: "test1"
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test1"
|
||||
}
|
||||
{ type: "buckets/ADD", bucket: "test1" },
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" }
|
||||
]
|
||||
return store.dispatch(actionsBuckets.makeBucket("test1")).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -228,37 +168,18 @@ describe("Buckets actions", () => {
|
||||
})
|
||||
})
|
||||
|
||||
it(
|
||||
"creates alert/SET, buckets/REMOVE, buckets/SET_LIST and buckets/SET_CURRENT_BUCKET " +
|
||||
"after deleting the bucket",
|
||||
() => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "alert/SET",
|
||||
alert: {
|
||||
id: 0,
|
||||
message: "Bucket 'test3' has been deleted.",
|
||||
type: "info"
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "buckets/REMOVE",
|
||||
bucket: "test3"
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_LIST",
|
||||
buckets: ["test1", "test2"]
|
||||
},
|
||||
{
|
||||
type: "buckets/SET_CURRENT_BUCKET",
|
||||
bucket: "test1"
|
||||
}
|
||||
]
|
||||
return store.dispatch(actionsBuckets.deleteBucket("test3")).then(() => {
|
||||
const actions = store.getActions()
|
||||
expect(actions).toEqual(expectedActions)
|
||||
})
|
||||
}
|
||||
)
|
||||
it("creates alert/SET, buckets/REMOVE, buckets/SET_LIST and buckets/SET_CURRENT_BUCKET " +
|
||||
"after deleting the bucket", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{ type: "alert/SET", alert: {id: 0, message: "Bucket 'test3' has been deleted.", type: "info"} },
|
||||
{ type: "buckets/REMOVE", bucket: "test3" },
|
||||
{ type: "buckets/SET_LIST", buckets: ["test1", "test2"] },
|
||||
{ type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" }
|
||||
]
|
||||
return store.dispatch(actionsBuckets.deleteBucket("test3")).then(() => {
|
||||
const actions = store.getActions()
|
||||
expect(actions).toEqual(expectedActions)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -40,9 +40,7 @@ describe("buckets reducer", () => {
|
||||
|
||||
it("should handle ADD", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
list: ["test1", "test2"]
|
||||
},
|
||||
{ list: ["test1", "test2"] },
|
||||
{
|
||||
type: actions.ADD,
|
||||
bucket: "test3"
|
||||
@@ -53,9 +51,7 @@ describe("buckets reducer", () => {
|
||||
|
||||
it("should handle REMOVE", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
list: ["test1", "test2"]
|
||||
},
|
||||
{ list: ["test1", "test2"] },
|
||||
{
|
||||
type: actions.REMOVE,
|
||||
bucket: "test2"
|
||||
@@ -95,7 +91,7 @@ describe("buckets reducer", () => {
|
||||
})
|
||||
expect(newState.showBucketPolicy).toBeTruthy()
|
||||
})
|
||||
|
||||
|
||||
it("should handle SHOW_MAKE_BUCKET_MODAL", () => {
|
||||
const newState = reducer(undefined, {
|
||||
type: actions.SHOW_MAKE_BUCKET_MODAL,
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getFilteredBuckets, getCurrentBucket } from "../selectors"
|
||||
import { getVisibleBuckets, getCurrentBucket } from "../selectors"
|
||||
|
||||
describe("getFilteredBuckets", () => {
|
||||
describe("getVisibleBuckets", () => {
|
||||
let state
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
@@ -28,11 +28,11 @@ describe("getFilteredBuckets", () => {
|
||||
|
||||
it("should return all buckets if no filter specified", () => {
|
||||
state.buckets.filter = ""
|
||||
expect(getFilteredBuckets(state)).toEqual(["test1", "test11", "test2"])
|
||||
expect(getVisibleBuckets(state)).toEqual(["test1", "test11", "test2"])
|
||||
})
|
||||
|
||||
it("should return all matching buckets if filter is specified", () => {
|
||||
state.buckets.filter = "test1"
|
||||
expect(getFilteredBuckets(state)).toEqual(["test1", "test11"])
|
||||
expect(getVisibleBuckets(state)).toEqual(["test1", "test11"])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -114,7 +114,7 @@ export const deleteBucket = bucket => {
|
||||
dispatch(removeBucket(bucket))
|
||||
dispatch(fetchBuckets())
|
||||
})
|
||||
.catch(err => {
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
@@ -153,8 +153,10 @@ export const fetchPolicies = bucket => {
|
||||
})
|
||||
.then(res => {
|
||||
let policies = res.policies
|
||||
if (policies) dispatch(setPolicies(policies))
|
||||
else dispatch(setPolicies([]))
|
||||
if(policies)
|
||||
dispatch(setPolicies(policies))
|
||||
else
|
||||
dispatch(setPolicies([]))
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
@@ -180,4 +182,4 @@ export const showBucketPolicy = () => ({
|
||||
export const hideBucketPolicy = () => ({
|
||||
type: SHOW_BUCKET_POLICY,
|
||||
show: false
|
||||
})
|
||||
})
|
||||
@@ -49,7 +49,7 @@ export default (
|
||||
case actionsBuckets.REMOVE:
|
||||
return {
|
||||
...state,
|
||||
list: removeBucket(state.list, action)
|
||||
list: removeBucket(state.list, action),
|
||||
}
|
||||
case actionsBuckets.SET_FILTER:
|
||||
return {
|
||||
|
||||
@@ -19,7 +19,7 @@ import { createSelector } from "reselect"
|
||||
const bucketsSelector = state => state.buckets.list
|
||||
const bucketsFilterSelector = state => state.buckets.filter
|
||||
|
||||
export const getFilteredBuckets = createSelector(
|
||||
export const getVisibleBuckets = createSelector(
|
||||
bucketsSelector,
|
||||
bucketsFilterSelector,
|
||||
(buckets, filter) => buckets.filter(bucket => bucket.indexOf(filter) > -1)
|
||||
|
||||
Reference in New Issue
Block a user