mirror of
https://github.com/minio/minio.git
synced 2024-12-25 14:45:54 -05:00
Fix failing unit tests in browser (#5688)
* format js files using prettier Used the following command to format the files prettier --write "browser/app/js/**/*.js" * fix failing unit tests in browser
This commit is contained in:
parent
cb3818be27
commit
c0e45f9098
@ -31,7 +31,7 @@ describe("App", () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<MemoryRouter initialEntries={["/login"]}>
|
<MemoryRouter initialEntries={["/login"]}>
|
||||||
<App />
|
<App />
|
||||||
</MemoryRouter>,
|
</MemoryRouter>
|
||||||
)
|
)
|
||||||
expect(wrapper.text()).toBe("Login")
|
expect(wrapper.text()).toBe("Login")
|
||||||
})
|
})
|
||||||
@ -40,7 +40,7 @@ describe("App", () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<MemoryRouter initialEntries={["/"]}>
|
<MemoryRouter initialEntries={["/"]}>
|
||||||
<App />
|
<App />
|
||||||
</MemoryRouter>,
|
</MemoryRouter>
|
||||||
)
|
)
|
||||||
expect(wrapper.text()).toBe("Browser")
|
expect(wrapper.text()).toBe("Browser")
|
||||||
})
|
})
|
||||||
@ -49,7 +49,7 @@ describe("App", () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<MemoryRouter initialEntries={["/bucket"]}>
|
<MemoryRouter initialEntries={["/bucket"]}>
|
||||||
<App />
|
<App />
|
||||||
</MemoryRouter>,
|
</MemoryRouter>
|
||||||
)
|
)
|
||||||
expect(wrapper.text()).toBe("Browser")
|
expect(wrapper.text()).toBe("Browser")
|
||||||
})
|
})
|
||||||
@ -58,7 +58,7 @@ describe("App", () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<MemoryRouter initialEntries={["/bucket/a/b/c"]}>
|
<MemoryRouter initialEntries={["/bucket/a/b/c"]}>
|
||||||
<App />
|
<App />
|
||||||
</MemoryRouter>,
|
</MemoryRouter>
|
||||||
)
|
)
|
||||||
expect(wrapper.text()).toBe("Browser")
|
expect(wrapper.text()).toBe("Browser")
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,7 @@ describe("jsonrpc", () => {
|
|||||||
try {
|
try {
|
||||||
let jsonRPC = new JSONrpc({
|
let jsonRPC = new JSONrpc({
|
||||||
endpoint: "htt://localhost:9000",
|
endpoint: "htt://localhost:9000",
|
||||||
namespace: "Test",
|
namespace: "Test"
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
done()
|
done()
|
||||||
@ -30,7 +30,7 @@ describe("jsonrpc", () => {
|
|||||||
it("should succeed with valid endpoint", () => {
|
it("should succeed with valid endpoint", () => {
|
||||||
let jsonRPC = new JSONrpc({
|
let jsonRPC = new JSONrpc({
|
||||||
endpoint: "http://localhost:9000/webrpc",
|
endpoint: "http://localhost:9000/webrpc",
|
||||||
namespace: "Test",
|
namespace: "Test"
|
||||||
})
|
})
|
||||||
expect(jsonRPC.version).toEqual("2.0")
|
expect(jsonRPC.version).toEqual("2.0")
|
||||||
expect(jsonRPC.host).toEqual("localhost")
|
expect(jsonRPC.host).toEqual("localhost")
|
||||||
|
@ -28,13 +28,13 @@ export const AlertContainer = ({ alert, clearAlert }) => {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
alert: state.alert,
|
alert: state.alert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
clearAlert: () => dispatch(alertActions.clear()),
|
clearAlert: () => dispatch(alertActions.clear())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ describe("Alert", () => {
|
|||||||
it("should call onDismiss when close button is clicked", () => {
|
it("should call onDismiss when close button is clicked", () => {
|
||||||
const onDismiss = jest.fn()
|
const onDismiss = jest.fn()
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<Alert show={true} type="danger" message="test" onDismiss={onDismiss} />,
|
<Alert show={true} type="danger" message="test" onDismiss={onDismiss} />
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click", {
|
wrapper.find("i").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(onDismiss).toHaveBeenCalled()
|
expect(onDismiss).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
@ -21,15 +21,13 @@ import { AlertContainer } from "../AlertContainer"
|
|||||||
describe("Alert", () => {
|
describe("Alert", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(
|
shallow(
|
||||||
<AlertContainer
|
<AlertContainer alert={{ show: true, type: "danger", message: "Test" }} />
|
||||||
alert={{ show: true, type: "danger", message: "Test" }}
|
|
||||||
/>,
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render nothing if message is empty", () => {
|
it("should render nothing if message is empty", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<AlertContainer alert={{ show: true, type: "danger", message: "" }} />,
|
<AlertContainer alert={{ show: true, type: "danger", message: "" }} />
|
||||||
)
|
)
|
||||||
expect(wrapper.find("Alert").length).toBe(0)
|
expect(wrapper.find("Alert").length).toBe(0)
|
||||||
})
|
})
|
||||||
|
@ -32,15 +32,15 @@ describe("Alert actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
id: 0,
|
id: 0,
|
||||||
message: "Test alert",
|
message: "Test alert",
|
||||||
type: "danger",
|
type: "danger"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
actionsAlert.set({
|
actionsAlert.set({
|
||||||
message: "Test alert",
|
message: "Test alert",
|
||||||
type: "danger",
|
type: "danger"
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
expect(actions).toEqual(expectedActions)
|
expect(actions).toEqual(expectedActions)
|
||||||
@ -53,20 +53,20 @@ describe("Alert actions", () => {
|
|||||||
type: "alert/SET",
|
type: "alert/SET",
|
||||||
alert: {
|
alert: {
|
||||||
id: 1,
|
id: 1,
|
||||||
message: "Test alert",
|
message: "Test alert"
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "alert/CLEAR",
|
type: "alert/CLEAR",
|
||||||
alert: {
|
alert: {
|
||||||
id: 1,
|
id: 1
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
actionsAlert.set({
|
actionsAlert.set({
|
||||||
message: "Test alert",
|
message: "Test alert"
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
jest.runAllTimers()
|
jest.runAllTimers()
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -77,8 +77,8 @@ describe("Alert actions", () => {
|
|||||||
const store = mockStore()
|
const store = mockStore()
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "alert/CLEAR",
|
type: "alert/CLEAR"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsAlert.clear())
|
store.dispatch(actionsAlert.clear())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
|
@ -21,7 +21,7 @@ describe("alert reducer", () => {
|
|||||||
it("should return the initial state", () => {
|
it("should return the initial state", () => {
|
||||||
expect(reducer(undefined, {})).toEqual({
|
expect(reducer(undefined, {})).toEqual({
|
||||||
show: false,
|
show: false,
|
||||||
type: "danger",
|
type: "danger"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -32,14 +32,14 @@ describe("alert reducer", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
id: 1,
|
id: 1,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
},
|
}
|
||||||
}),
|
})
|
||||||
).toEqual({
|
).toEqual({
|
||||||
show: true,
|
show: true,
|
||||||
id: 1,
|
id: 1,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -49,15 +49,15 @@ describe("alert reducer", () => {
|
|||||||
{
|
{
|
||||||
show: true,
|
show: true,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actionsAlert.CLEAR,
|
type: actionsAlert.CLEAR
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
show: false,
|
show: false,
|
||||||
type: "danger",
|
type: "danger"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -68,18 +68,18 @@ describe("alert reducer", () => {
|
|||||||
show: true,
|
show: true,
|
||||||
id: 1,
|
id: 1,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actionsAlert.CLEAR,
|
type: actionsAlert.CLEAR,
|
||||||
alert: {
|
alert: {
|
||||||
id: 1,
|
id: 1
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
show: false,
|
show: false,
|
||||||
type: "danger",
|
type: "danger"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,20 +90,20 @@ describe("alert reducer", () => {
|
|||||||
show: true,
|
show: true,
|
||||||
id: 1,
|
id: 1,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actionsAlert.CLEAR,
|
type: actionsAlert.CLEAR,
|
||||||
alert: {
|
alert: {
|
||||||
id: 2,
|
id: 2
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
show: true,
|
show: true,
|
||||||
id: 1,
|
id: 1,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Test message",
|
message: "Test message"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -27,22 +27,22 @@ export const set = alert => {
|
|||||||
dispatch({
|
dispatch({
|
||||||
type: CLEAR,
|
type: CLEAR,
|
||||||
alert: {
|
alert: {
|
||||||
id,
|
id
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
}, 5000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SET,
|
type: SET,
|
||||||
alert: Object.assign({}, alert, {
|
alert: Object.assign({}, alert, {
|
||||||
id,
|
id
|
||||||
}),
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clear = () => {
|
export const clear = () => {
|
||||||
return {
|
return {
|
||||||
type: CLEAR,
|
type: CLEAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import * as actionsAlert from "./actions"
|
|||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
show: false,
|
show: false,
|
||||||
type: "danger",
|
type: "danger"
|
||||||
}
|
}
|
||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
@ -27,7 +27,7 @@ export default (state = initialState, action) => {
|
|||||||
show: true,
|
show: true,
|
||||||
id: action.alert.id,
|
id: action.alert.id,
|
||||||
type: action.alert.type,
|
type: action.alert.type,
|
||||||
message: action.alert.message,
|
message: action.alert.message
|
||||||
}
|
}
|
||||||
case actionsAlert.CLEAR:
|
case actionsAlert.CLEAR:
|
||||||
if (action.alert && action.alert.id != state.id) {
|
if (action.alert && action.alert.id != state.id) {
|
||||||
|
@ -28,29 +28,29 @@ export class BrowserDropdown extends React.Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
showAboutModal: false,
|
showAboutModal: false,
|
||||||
showChangePasswordModal: false,
|
showChangePasswordModal: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showAbout(e) {
|
showAbout(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.setState({
|
this.setState({
|
||||||
showAboutModal: true,
|
showAboutModal: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
hideAbout() {
|
hideAbout() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showAboutModal: false,
|
showAboutModal: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
showChangePassword(e) {
|
showChangePassword(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.setState({
|
this.setState({
|
||||||
showChangePasswordModal: true,
|
showChangePasswordModal: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
hideChangePassword() {
|
hideChangePassword() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showChangePasswordModal: false,
|
showChangePasswordModal: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -142,13 +142,13 @@ export class BrowserDropdown extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
serverInfo: state.browser.serverInfo,
|
serverInfo: state.browser.serverInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
fetchServerInfo: () => dispatch(browserActions.fetchServerInfo()),
|
fetchServerInfo: () => dispatch(browserActions.fetchServerInfo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
ModalBody,
|
ModalBody,
|
||||||
ModalHeader,
|
ModalHeader,
|
||||||
OverlayTrigger,
|
OverlayTrigger
|
||||||
} from "react-bootstrap"
|
} from "react-bootstrap"
|
||||||
|
|
||||||
export class ChangePasswordModal extends React.Component {
|
export class ChangePasswordModal extends React.Component {
|
||||||
@ -33,7 +33,7 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
accessKey: "",
|
accessKey: "",
|
||||||
secretKey: "",
|
secretKey: "",
|
||||||
keysReadOnly: false,
|
keysReadOnly: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// When its shown, it loads the access key and secret key.
|
// When its shown, it loads the access key and secret key.
|
||||||
@ -45,13 +45,13 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
accessKey: "xxxxxxxxx",
|
accessKey: "xxxxxxxxx",
|
||||||
secretKey: "xxxxxxxxx",
|
secretKey: "xxxxxxxxx",
|
||||||
keysReadOnly: true,
|
keysReadOnly: true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
web.GetAuth().then(data => {
|
web.GetAuth().then(data => {
|
||||||
this.setState({
|
this.setState({
|
||||||
accessKey: data.accessKey,
|
accessKey: data.accessKey,
|
||||||
secretKey: data.secretKey,
|
secretKey: data.secretKey
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -60,19 +60,19 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
// Handle field changes from inside the modal.
|
// Handle field changes from inside the modal.
|
||||||
accessKeyChange(e) {
|
accessKeyChange(e) {
|
||||||
this.setState({
|
this.setState({
|
||||||
accessKey: e.target.value,
|
accessKey: e.target.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
secretKeyChange(e) {
|
secretKeyChange(e) {
|
||||||
this.setState({
|
this.setState({
|
||||||
secretKey: e.target.value,
|
secretKey: e.target.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
secretKeyVisible(secretKeyVisible) {
|
secretKeyVisible(secretKeyVisible) {
|
||||||
this.setState({
|
this.setState({
|
||||||
secretKeyVisible,
|
secretKeyVisible
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,18 +84,18 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
web
|
web
|
||||||
.SetAuth({
|
.SetAuth({
|
||||||
accessKey,
|
accessKey,
|
||||||
secretKey,
|
secretKey
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
showAlert({
|
showAlert({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "Changed credentials",
|
message: "Changed credentials"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
showAlert({
|
showAlert({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
accessKey: data.accessKey,
|
accessKey: data.accessKey,
|
||||||
secretKey: data.secretKey,
|
secretKey: data.secretKey,
|
||||||
secretKeyVisible: true,
|
secretKeyVisible: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
<input
|
<input
|
||||||
type={this.state.secretKeyVisible ? "text" : "password"}
|
type={this.state.secretKeyVisible ? "text" : "password"}
|
||||||
value={this.state.secretKey}
|
value={this.state.secretKey}
|
||||||
onChange={this.accessKeyChange.bind(this)}
|
onChange={this.secretKeyChange.bind(this)}
|
||||||
id="secretKey"
|
id="secretKey"
|
||||||
className="form-group__field"
|
className="form-group__field"
|
||||||
name="secretKey"
|
name="secretKey"
|
||||||
@ -148,7 +148,7 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
<i
|
<i
|
||||||
onClick={this.secretKeyVisible.bind(
|
onClick={this.secretKeyVisible.bind(
|
||||||
this,
|
this,
|
||||||
!this.state.secretKeyVisible,
|
!this.state.secretKeyVisible
|
||||||
)}
|
)}
|
||||||
className={
|
className={
|
||||||
"form-group__addon zmdi " +
|
"form-group__addon zmdi " +
|
||||||
@ -191,13 +191,13 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
serverInfo: state.browser.serverInfo,
|
serverInfo: state.browser.serverInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
showAlert: alert => dispatch(alertActions.set(alert)),
|
showAlert: alert => dispatch(alertActions.set(alert))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ let ConfirmModal = ({
|
|||||||
cancelText,
|
cancelText,
|
||||||
okHandler,
|
okHandler,
|
||||||
cancelHandler,
|
cancelHandler,
|
||||||
show,
|
show
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import Path from "../objects/Path"
|
import Path from "../objects/Path"
|
||||||
import ObjectsBulkActions from "../objects/ObjectsBulkActions"
|
import Toolbar from "../objects/Toolbar"
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
return (
|
return (
|
||||||
<header className="header">
|
<header className="header">
|
||||||
<ObjectsBulkActions />
|
<Toolbar />
|
||||||
<Path />
|
<Path />
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ export class Login extends React.Component {
|
|||||||
web
|
web
|
||||||
.Login({
|
.Login({
|
||||||
username: document.getElementById("accessKey").value,
|
username: document.getElementById("accessKey").value,
|
||||||
password: document.getElementById("secretKey").value,
|
password: document.getElementById("secretKey").value
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
history.push("/")
|
history.push("/")
|
||||||
@ -114,10 +114,10 @@ const mapDispatchToProps = dispatch => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
actionsAlert.set({
|
actionsAlert.set({
|
||||||
type: type,
|
type: type,
|
||||||
message: message,
|
message: message
|
||||||
}),
|
})
|
||||||
),
|
),
|
||||||
clearAlert: () => dispatch(actionsAlert.clear()),
|
clearAlert: () => dispatch(actionsAlert.clear())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import { getPrefixWritable } from "../objects/selectors"
|
|||||||
export const MainActions = ({
|
export const MainActions = ({
|
||||||
prefixWritable,
|
prefixWritable,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
showMakeBucketModal,
|
showMakeBucketModal
|
||||||
}) => {
|
}) => {
|
||||||
const uploadTooltip = <Tooltip id="tooltip-upload-file">Upload file</Tooltip>
|
const uploadTooltip = <Tooltip id="tooltip-upload-file">Upload file</Tooltip>
|
||||||
const makeBucketTooltip = (
|
const makeBucketTooltip = (
|
||||||
@ -89,14 +89,14 @@ export const MainActions = ({
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
prefixWritable: getPrefixWritable(state),
|
prefixWritable: getPrefixWritable(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
uploadFile: file => dispatch(uploadsActions.uploadFile(file)),
|
uploadFile: file => dispatch(uploadsActions.uploadFile(file)),
|
||||||
showMakeBucketModal: () => dispatch(actionsBuckets.showMakeBucketModal()),
|
showMakeBucketModal: () => dispatch(actionsBuckets.showMakeBucketModal())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export const SideBar = ({ sidebarOpen }) => {
|
|||||||
<aside
|
<aside
|
||||||
className={classNames({
|
className={classNames({
|
||||||
sidebar: true,
|
sidebar: true,
|
||||||
"sidebar--toggled": sidebarOpen,
|
"sidebar--toggled": sidebarOpen
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div className="sidebar__inner">
|
<div className="sidebar__inner">
|
||||||
@ -53,13 +53,13 @@ export const SideBar = ({ sidebarOpen }) => {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
sidebarOpen: state.browser.sidebarOpen,
|
sidebarOpen: state.browser.sidebarOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ export const SidebarBackdrop = ({ sidebarOpen, toggleSidebar }) => (
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
sidebarOpen: state.browser.sidebarOpen,
|
sidebarOpen: state.browser.sidebarOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ export const SidebarToggle = ({ sidebarOpen, toggleSidebar }) => (
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
sidebarOpen: state.browser.sidebarOpen,
|
sidebarOpen: state.browser.sidebarOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,13 +44,13 @@ export class StorageInfo extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
storageInfo: state.browser.storageInfo,
|
storageInfo: state.browser.storageInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
fetchStorageInfo: () => dispatch(actionsCommon.fetchStorageInfo()),
|
fetchStorageInfo: () => dispatch(actionsCommon.fetchStorageInfo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ describe("AboutModal", () => {
|
|||||||
version: "test",
|
version: "test",
|
||||||
memory: "test",
|
memory: "test",
|
||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test"
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
@ -33,9 +33,9 @@ describe("AboutModal", () => {
|
|||||||
it("should call hideAbout when close button is clicked", () => {
|
it("should call hideAbout when close button is clicked", () => {
|
||||||
const hideAbout = jest.fn()
|
const hideAbout = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<AboutModal serverInfo={serverInfo} hideAbout={hideAbout} />,
|
<AboutModal serverInfo={serverInfo} hideAbout={hideAbout} />
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click")
|
wrapper.find("i").simulate("click")
|
||||||
expect(hideAbout).toHaveBeenCalled()
|
expect(hideAbout).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -23,12 +23,12 @@ describe("BrowserDropdown", () => {
|
|||||||
version: "test",
|
version: "test",
|
||||||
memory: "test",
|
memory: "test",
|
||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test"
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(
|
shallow(
|
||||||
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />,
|
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -38,17 +38,17 @@ describe("BrowserDropdown", () => {
|
|||||||
<BrowserDropdown
|
<BrowserDropdown
|
||||||
serverInfo={serverInfo}
|
serverInfo={serverInfo}
|
||||||
fetchServerInfo={fetchServerInfo}
|
fetchServerInfo={fetchServerInfo}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(fetchServerInfo).toHaveBeenCalled()
|
expect(fetchServerInfo).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should show AboutModal when About link is clicked", () => {
|
it("should show AboutModal when About link is clicked", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />,
|
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />
|
||||||
)
|
)
|
||||||
wrapper.find("#show-about").simulate("click", {
|
wrapper.find("#show-about").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
wrapper.update()
|
wrapper.update()
|
||||||
expect(wrapper.state("showAboutModal")).toBeTruthy()
|
expect(wrapper.state("showAboutModal")).toBeTruthy()
|
||||||
@ -57,10 +57,10 @@ describe("BrowserDropdown", () => {
|
|||||||
|
|
||||||
it("should logout and redirect to /login when logout is clicked", () => {
|
it("should logout and redirect to /login when logout is clicked", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />,
|
<BrowserDropdown serverInfo={serverInfo} fetchServerInfo={jest.fn()} />
|
||||||
)
|
)
|
||||||
wrapper.find("#logout").simulate("click", {
|
wrapper.find("#logout").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(window.location.pathname.endsWith("/login")).toBeTruthy()
|
expect(window.location.pathname.endsWith("/login")).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
@ -22,13 +22,13 @@ jest.mock("../../web", () => ({
|
|||||||
GetAuth: jest.fn(() => {
|
GetAuth: jest.fn(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
accessKey: "test1",
|
accessKey: "test1",
|
||||||
secretKey: "test2",
|
secretKey: "test2"
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
GenerateAuth: jest.fn(() => {
|
GenerateAuth: jest.fn(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
accessKey: "gen1",
|
accessKey: "gen1",
|
||||||
secretKey: "gen2",
|
secretKey: "gen2"
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
SetAuth: jest.fn(({ accessKey, secretKey }) => {
|
SetAuth: jest.fn(({ accessKey, secretKey }) => {
|
||||||
@ -36,10 +36,10 @@ jest.mock("../../web", () => ({
|
|||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
message: "Error",
|
message: "Error"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("ChangePasswordModal", () => {
|
describe("ChangePasswordModal", () => {
|
||||||
@ -49,8 +49,8 @@ describe("ChangePasswordModal", () => {
|
|||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test",
|
||||||
info: {
|
info: {
|
||||||
isEnvCreds: false,
|
isEnvCreds: false
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
@ -69,8 +69,8 @@ describe("ChangePasswordModal", () => {
|
|||||||
const newServerInfo = {
|
const newServerInfo = {
|
||||||
...serverInfo,
|
...serverInfo,
|
||||||
info: {
|
info: {
|
||||||
isEnvCreds: true,
|
isEnvCreds: true
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
const wrapper = shallow(<ChangePasswordModal serverInfo={newServerInfo} />)
|
const wrapper = shallow(<ChangePasswordModal serverInfo={newServerInfo} />)
|
||||||
expect(wrapper.state("accessKey")).toBe("xxxxxxxxx")
|
expect(wrapper.state("accessKey")).toBe("xxxxxxxxx")
|
||||||
@ -93,23 +93,23 @@ describe("ChangePasswordModal", () => {
|
|||||||
it("should update accessKey and secretKey when Update button is clicked", () => {
|
it("should update accessKey and secretKey when Update button is clicked", () => {
|
||||||
const showAlert = jest.fn()
|
const showAlert = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ChangePasswordModal serverInfo={serverInfo} showAlert={showAlert} />,
|
<ChangePasswordModal serverInfo={serverInfo} showAlert={showAlert} />
|
||||||
)
|
)
|
||||||
wrapper.find("#accessKey").simulate("change", {
|
wrapper.find("#accessKey").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test3",
|
value: "test3"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#secretKey").simulate("change", {
|
wrapper.find("#secretKey").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test4",
|
value: "test4"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#update-keys").simulate("click")
|
wrapper.find("#update-keys").simulate("click")
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
expect(showAlert).toHaveBeenCalledWith({
|
expect(showAlert).toHaveBeenCalledWith({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "Changed credentials",
|
message: "Changed credentials"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -120,7 +120,7 @@ describe("ChangePasswordModal", () => {
|
|||||||
<ChangePasswordModal
|
<ChangePasswordModal
|
||||||
serverInfo={serverInfo}
|
serverInfo={serverInfo}
|
||||||
hideChangePassword={hideChangePassword}
|
hideChangePassword={hideChangePassword}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("#cancel-change-password").simulate("click")
|
wrapper.find("#cancel-change-password").simulate("click")
|
||||||
expect(hideChangePassword).toHaveBeenCalled()
|
expect(hideChangePassword).toHaveBeenCalled()
|
||||||
|
@ -18,25 +18,8 @@ import React from "react"
|
|||||||
import { shallow } from "enzyme"
|
import { shallow } from "enzyme"
|
||||||
import Header from "../Header"
|
import Header from "../Header"
|
||||||
|
|
||||||
jest.mock("../../web", () => ({
|
|
||||||
LoggedIn: jest
|
|
||||||
.fn(() => true)
|
|
||||||
.mockReturnValueOnce(true)
|
|
||||||
.mockReturnValueOnce(false),
|
|
||||||
}))
|
|
||||||
describe("Header", () => {
|
describe("Header", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(<Header />)
|
shallow(<Header />)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render Login button when the user has not LoggedIn", () => {
|
|
||||||
const wrapper = shallow(<Header />)
|
|
||||||
expect(wrapper.find("a").text()).toBe("Login")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should render StorageInfo and BrowserDropdown when the user has LoggedIn", () => {
|
|
||||||
const wrapper = shallow(<Header />)
|
|
||||||
expect(wrapper.find("Connect(BrowserDropdown)").length).toBe(1)
|
|
||||||
expect(wrapper.find("Connect(StorageInfo)").length).toBe(1)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -23,10 +23,10 @@ jest.mock("../../web", () => ({
|
|||||||
Login: jest.fn(() => {
|
Login: jest.fn(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
token: "test",
|
token: "test",
|
||||||
uiVersion: "2018-02-01T01:17:47Z",
|
uiVersion: "2018-02-01T01:17:47Z"
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
LoggedIn: jest.fn(),
|
LoggedIn: jest.fn()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("Login", () => {
|
describe("Login", () => {
|
||||||
@ -41,7 +41,7 @@ describe("Login", () => {
|
|||||||
alert={{ show: false, type: "danger" }}
|
alert={{ show: false, type: "danger" }}
|
||||||
showAlert={showAlertMock}
|
showAlert={showAlertMock}
|
||||||
clearAlert={clearAlertMock}
|
clearAlert={clearAlertMock}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ describe("Login", () => {
|
|||||||
clearAlert={clearAlertMock}
|
clearAlert={clearAlertMock}
|
||||||
/>,
|
/>,
|
||||||
{
|
{
|
||||||
attachTo: document.body,
|
attachTo: document.body
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(document.body.classList.contains("is-guest")).toBeTruthy()
|
expect(document.body.classList.contains("is-guest")).toBeTruthy()
|
||||||
})
|
})
|
||||||
@ -69,14 +69,14 @@ describe("Login", () => {
|
|||||||
clearAlert={clearAlertMock}
|
clearAlert={clearAlertMock}
|
||||||
/>,
|
/>,
|
||||||
{
|
{
|
||||||
attachTo: document.body,
|
attachTo: document.body
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
// case where both keys are empty - displays the second warning
|
// case where both keys are empty - displays the second warning
|
||||||
wrapper.find("form").simulate("submit")
|
wrapper.find("form").simulate("submit")
|
||||||
expect(showAlertMock).toHaveBeenCalledWith(
|
expect(showAlertMock).toHaveBeenCalledWith(
|
||||||
"danger",
|
"danger",
|
||||||
"Secret Key cannot be empty",
|
"Secret Key cannot be empty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// case where access key is empty
|
// case where access key is empty
|
||||||
@ -84,7 +84,7 @@ describe("Login", () => {
|
|||||||
wrapper.find("form").simulate("submit")
|
wrapper.find("form").simulate("submit")
|
||||||
expect(showAlertMock).toHaveBeenCalledWith(
|
expect(showAlertMock).toHaveBeenCalledWith(
|
||||||
"danger",
|
"danger",
|
||||||
"Access Key cannot be empty",
|
"Access Key cannot be empty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// case where secret key is empty
|
// case where secret key is empty
|
||||||
@ -92,7 +92,7 @@ describe("Login", () => {
|
|||||||
wrapper.find("form").simulate("submit")
|
wrapper.find("form").simulate("submit")
|
||||||
expect(showAlertMock).toHaveBeenCalledWith(
|
expect(showAlertMock).toHaveBeenCalledWith(
|
||||||
"danger",
|
"danger",
|
||||||
"Secret Key cannot be empty",
|
"Secret Key cannot be empty"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -105,15 +105,15 @@ describe("Login", () => {
|
|||||||
clearAlert={clearAlertMock}
|
clearAlert={clearAlertMock}
|
||||||
/>,
|
/>,
|
||||||
{
|
{
|
||||||
attachTo: document.body,
|
attachTo: document.body
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
document.getElementById("accessKey").value = "accessKey"
|
document.getElementById("accessKey").value = "accessKey"
|
||||||
document.getElementById("secretKey").value = "secretKey"
|
document.getElementById("secretKey").value = "secretKey"
|
||||||
wrapper.find("form").simulate("submit")
|
wrapper.find("form").simulate("submit")
|
||||||
expect(web.Login).toHaveBeenCalledWith({
|
expect(web.Login).toHaveBeenCalledWith({
|
||||||
username: "accessKey",
|
username: "accessKey",
|
||||||
password: "secretKey",
|
password: "secretKey"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,7 @@ jest.mock("../../web", () => ({
|
|||||||
.fn(() => true)
|
.fn(() => true)
|
||||||
.mockReturnValueOnce(true)
|
.mockReturnValueOnce(true)
|
||||||
.mockReturnValueOnce(false)
|
.mockReturnValueOnce(false)
|
||||||
.mockReturnValueOnce(false),
|
.mockReturnValueOnce(false)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("MainActions", () => {
|
describe("MainActions", () => {
|
||||||
@ -52,10 +52,10 @@ describe("MainActions", () => {
|
|||||||
it("should call showMakeBucketModal when create bucket icon is clicked", () => {
|
it("should call showMakeBucketModal when create bucket icon is clicked", () => {
|
||||||
const showMakeBucketModal = jest.fn()
|
const showMakeBucketModal = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<MainActions showMakeBucketModal={showMakeBucketModal} />,
|
<MainActions showMakeBucketModal={showMakeBucketModal} />
|
||||||
)
|
)
|
||||||
wrapper.find("#show-make-bucket").simulate("click", {
|
wrapper.find("#show-make-bucket").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(showMakeBucketModal).toHaveBeenCalled()
|
expect(showMakeBucketModal).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -64,13 +64,13 @@ describe("MainActions", () => {
|
|||||||
const uploadFile = jest.fn()
|
const uploadFile = jest.fn()
|
||||||
const wrapper = shallow(<MainActions uploadFile={uploadFile} />)
|
const wrapper = shallow(<MainActions uploadFile={uploadFile} />)
|
||||||
const file = new Blob(["file content"], {
|
const file = new Blob(["file content"], {
|
||||||
type: "text/plain",
|
type: "text/plain"
|
||||||
})
|
})
|
||||||
wrapper.find("#file-input").simulate("change", {
|
wrapper.find("#file-input").simulate("change", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn(),
|
||||||
target: {
|
target: {
|
||||||
files: [file],
|
files: [file]
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
expect(uploadFile).toHaveBeenCalledWith(file)
|
expect(uploadFile).toHaveBeenCalledWith(file)
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ import { shallow } from "enzyme"
|
|||||||
import { SideBar } from "../SideBar"
|
import { SideBar } from "../SideBar"
|
||||||
|
|
||||||
jest.mock("../../web", () => ({
|
jest.mock("../../web", () => ({
|
||||||
LoggedIn: jest.fn(() => false).mockReturnValueOnce(true),
|
LoggedIn: jest.fn(() => false).mockReturnValueOnce(true)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("SideBar", () => {
|
describe("SideBar", () => {
|
||||||
@ -31,13 +31,4 @@ describe("SideBar", () => {
|
|||||||
const wrapper = shallow(<SideBar />)
|
const wrapper = shallow(<SideBar />)
|
||||||
expect(wrapper.find("Connect(BucketSearch)").length).toBe(0)
|
expect(wrapper.find("Connect(BucketSearch)").length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call clickOutside when the user clicks outside the sidebar", () => {
|
|
||||||
const clickOutside = jest.fn()
|
|
||||||
const wrapper = shallow(<SideBar clickOutside={clickOutside} />)
|
|
||||||
wrapper.simulate("clickOut", {
|
|
||||||
preventDefault: jest.fn(),
|
|
||||||
})
|
|
||||||
expect(clickOutside).toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -16,20 +16,20 @@
|
|||||||
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { shallow } from "enzyme"
|
import { shallow } from "enzyme"
|
||||||
import { MobileHeader } from "../MobileHeader"
|
import { SidebarToggle } from "../SidebarToggle"
|
||||||
|
|
||||||
describe("Bucket", () => {
|
describe("SidebarToggle", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(<MobileHeader sidebarOpen={false} />)
|
shallow(<SidebarToggle sidebarOpen={false} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should toggleSidebar when trigger is clicked", () => {
|
it("should toggleSidebar when trigger is clicked", () => {
|
||||||
const toggleSidebar = jest.fn()
|
const toggleSidebar = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<MobileHeader sidebarOpen={false} toggleSidebar={toggleSidebar} />,
|
<SidebarToggle sidebarOpen={false} toggleSidebar={toggleSidebar} />
|
||||||
)
|
)
|
||||||
wrapper.find("#sidebar-toggle").simulate("click", {
|
wrapper.find("button").simulate("click", {
|
||||||
stopPropagation: jest.fn(),
|
stopPropagation: jest.fn()
|
||||||
})
|
})
|
||||||
expect(toggleSidebar).toHaveBeenCalled()
|
expect(toggleSidebar).toHaveBeenCalled()
|
||||||
})
|
})
|
@ -24,7 +24,7 @@ describe("StorageInfo", () => {
|
|||||||
<StorageInfo
|
<StorageInfo
|
||||||
storageInfo={{ total: 100, free: 60 }}
|
storageInfo={{ total: 100, free: 60 }}
|
||||||
fetchStorageInfo={jest.fn()}
|
fetchStorageInfo={jest.fn()}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ describe("StorageInfo", () => {
|
|||||||
<StorageInfo
|
<StorageInfo
|
||||||
storageInfo={{ total: 100, free: 60 }}
|
storageInfo={{ total: 100, free: 60 }}
|
||||||
fetchStorageInfo={fetchStorageInfo}
|
fetchStorageInfo={fetchStorageInfo}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(fetchStorageInfo).toHaveBeenCalled()
|
expect(fetchStorageInfo).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
@ -23,8 +23,8 @@ jest.mock("../../web", () => ({
|
|||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
Total: 100,
|
Total: 100,
|
||||||
Free: 60,
|
Free: 60
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
ServerInfo: jest.fn(() => {
|
ServerInfo: jest.fn(() => {
|
||||||
@ -33,9 +33,9 @@ jest.mock("../../web", () => ({
|
|||||||
MinioMemory: "test",
|
MinioMemory: "test",
|
||||||
MinioPlatform: "test",
|
MinioPlatform: "test",
|
||||||
MinioRuntime: "test",
|
MinioRuntime: "test",
|
||||||
MinioGlobalInfo: "test",
|
MinioGlobalInfo: "test"
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}),
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const middlewares = [thunk]
|
const middlewares = [thunk]
|
||||||
@ -49,9 +49,9 @@ describe("Common actions", () => {
|
|||||||
type: "common/SET_STORAGE_INFO",
|
type: "common/SET_STORAGE_INFO",
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
total: 100,
|
total: 100,
|
||||||
free: 60,
|
free: 60
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsCommon.fetchStorageInfo()).then(() => {
|
return store.dispatch(actionsCommon.fetchStorageInfo()).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -69,9 +69,9 @@ describe("Common actions", () => {
|
|||||||
memory: "test",
|
memory: "test",
|
||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test",
|
||||||
info: "test",
|
info: "test"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsCommon.fetchServerInfo()).then(() => {
|
return store.dispatch(actionsCommon.fetchServerInfo()).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
|
@ -23,9 +23,9 @@ describe("common reducer", () => {
|
|||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
total: 0,
|
total: 0,
|
||||||
free: 0,
|
free: 0
|
||||||
},
|
},
|
||||||
serverInfo: {},
|
serverInfo: {}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -33,14 +33,14 @@ describe("common reducer", () => {
|
|||||||
expect(
|
expect(
|
||||||
reducer(
|
reducer(
|
||||||
{
|
{
|
||||||
sidebarOpen: false,
|
sidebarOpen: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actionsCommon.TOGGLE_SIDEBAR,
|
type: actionsCommon.TOGGLE_SIDEBAR
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
sidebarOpen: true,
|
sidebarOpen: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -48,14 +48,14 @@ describe("common reducer", () => {
|
|||||||
expect(
|
expect(
|
||||||
reducer(
|
reducer(
|
||||||
{
|
{
|
||||||
sidebarOpen: true,
|
sidebarOpen: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actionsCommon.CLOSE_SIDEBAR,
|
type: actionsCommon.CLOSE_SIDEBAR
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
sidebarOpen: false,
|
sidebarOpen: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -67,15 +67,15 @@ describe("common reducer", () => {
|
|||||||
type: actionsCommon.SET_STORAGE_INFO,
|
type: actionsCommon.SET_STORAGE_INFO,
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
total: 100,
|
total: 100,
|
||||||
free: 40,
|
free: 40
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
),
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
total: 100,
|
total: 100,
|
||||||
free: 40,
|
free: 40
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -88,15 +88,15 @@ describe("common reducer", () => {
|
|||||||
memory: "test",
|
memory: "test",
|
||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test",
|
||||||
info: "test",
|
info: "test"
|
||||||
},
|
}
|
||||||
}).serverInfo,
|
}).serverInfo
|
||||||
).toEqual({
|
).toEqual({
|
||||||
version: "test",
|
version: "test",
|
||||||
memory: "test",
|
memory: "test",
|
||||||
platform: "test",
|
platform: "test",
|
||||||
runtime: "test",
|
runtime: "test",
|
||||||
info: "test",
|
info: "test"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -22,11 +22,11 @@ export const SET_STORAGE_INFO = "common/SET_STORAGE_INFO"
|
|||||||
export const SET_SERVER_INFO = "common/SET_SERVER_INFO"
|
export const SET_SERVER_INFO = "common/SET_SERVER_INFO"
|
||||||
|
|
||||||
export const toggleSidebar = () => ({
|
export const toggleSidebar = () => ({
|
||||||
type: TOGGLE_SIDEBAR,
|
type: TOGGLE_SIDEBAR
|
||||||
})
|
})
|
||||||
|
|
||||||
export const closeSidebar = () => ({
|
export const closeSidebar = () => ({
|
||||||
type: CLOSE_SIDEBAR,
|
type: CLOSE_SIDEBAR
|
||||||
})
|
})
|
||||||
|
|
||||||
export const fetchStorageInfo = () => {
|
export const fetchStorageInfo = () => {
|
||||||
@ -34,7 +34,7 @@ export const fetchStorageInfo = () => {
|
|||||||
return web.StorageInfo().then(res => {
|
return web.StorageInfo().then(res => {
|
||||||
const storageInfo = {
|
const storageInfo = {
|
||||||
total: res.storageInfo.Total,
|
total: res.storageInfo.Total,
|
||||||
free: res.storageInfo.Free,
|
free: res.storageInfo.Free
|
||||||
}
|
}
|
||||||
dispatch(setStorageInfo(storageInfo))
|
dispatch(setStorageInfo(storageInfo))
|
||||||
})
|
})
|
||||||
@ -43,7 +43,7 @@ export const fetchStorageInfo = () => {
|
|||||||
|
|
||||||
export const setStorageInfo = storageInfo => ({
|
export const setStorageInfo = storageInfo => ({
|
||||||
type: SET_STORAGE_INFO,
|
type: SET_STORAGE_INFO,
|
||||||
storageInfo,
|
storageInfo
|
||||||
})
|
})
|
||||||
|
|
||||||
export const fetchServerInfo = () => {
|
export const fetchServerInfo = () => {
|
||||||
@ -54,7 +54,7 @@ export const fetchServerInfo = () => {
|
|||||||
memory: res.MinioMemory,
|
memory: res.MinioMemory,
|
||||||
platform: res.MinioPlatform,
|
platform: res.MinioPlatform,
|
||||||
runtime: res.MinioRuntime,
|
runtime: res.MinioRuntime,
|
||||||
info: res.MinioGlobalInfo,
|
info: res.MinioGlobalInfo
|
||||||
}
|
}
|
||||||
dispatch(setServerInfo(serverInfo))
|
dispatch(setServerInfo(serverInfo))
|
||||||
})
|
})
|
||||||
@ -63,5 +63,5 @@ export const fetchServerInfo = () => {
|
|||||||
|
|
||||||
export const setServerInfo = serverInfo => ({
|
export const setServerInfo = serverInfo => ({
|
||||||
type: SET_SERVER_INFO,
|
type: SET_SERVER_INFO,
|
||||||
serverInfo,
|
serverInfo
|
||||||
})
|
})
|
||||||
|
@ -21,29 +21,29 @@ export default (
|
|||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
storageInfo: {
|
storageInfo: {
|
||||||
total: 0,
|
total: 0,
|
||||||
free: 0,
|
free: 0
|
||||||
},
|
},
|
||||||
serverInfo: {},
|
serverInfo: {}
|
||||||
},
|
},
|
||||||
action,
|
action
|
||||||
) => {
|
) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actionsCommon.TOGGLE_SIDEBAR:
|
case actionsCommon.TOGGLE_SIDEBAR:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
sidebarOpen: !state.sidebarOpen,
|
sidebarOpen: !state.sidebarOpen
|
||||||
})
|
})
|
||||||
case actionsCommon.CLOSE_SIDEBAR:
|
case actionsCommon.CLOSE_SIDEBAR:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
sidebarOpen: false,
|
sidebarOpen: false
|
||||||
})
|
})
|
||||||
case actionsCommon.SET_STORAGE_INFO:
|
case actionsCommon.SET_STORAGE_INFO:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
storageInfo: action.storageInfo,
|
storageInfo: action.storageInfo
|
||||||
})
|
})
|
||||||
case actionsCommon.SET_SERVER_INFO:
|
case actionsCommon.SET_SERVER_INFO:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
serverInfo: action.serverInfo,
|
serverInfo: action.serverInfo
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
@ -23,7 +23,7 @@ export const Bucket = ({ bucket, isActive, selectBucket }) => {
|
|||||||
<div
|
<div
|
||||||
className={classNames({
|
className={classNames({
|
||||||
buckets__item: true,
|
buckets__item: true,
|
||||||
"buckets__item--active": isActive,
|
"buckets__item--active": isActive
|
||||||
})}
|
})}
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -22,13 +22,13 @@ import Bucket from "./Bucket"
|
|||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
isActive: getCurrentBucket(state) === ownProps.bucket,
|
isActive: getCurrentBucket(state) === ownProps.bucket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
selectBucket: bucket => dispatch(actionsBuckets.selectBucket(bucket)),
|
selectBucket: bucket => dispatch(actionsBuckets.selectBucket(bucket))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,18 +26,18 @@ export class BucketDropdown extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
showBucketDropdown: false,
|
showBucketDropdown: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleDropdown() {
|
toggleDropdown() {
|
||||||
if (this.state.showBucketDropdown) {
|
if (this.state.showBucketDropdown) {
|
||||||
this.setState({
|
this.setState({
|
||||||
showBucketDropdown: false,
|
showBucketDropdown: false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
showBucketDropdown: true,
|
showBucketDropdown: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ export class BucketDropdown extends React.Component {
|
|||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
deleteBucket: bucket => dispatch(actionsBuckets.deleteBucket(bucket)),
|
deleteBucket: bucket => dispatch(actionsBuckets.deleteBucket(bucket)),
|
||||||
showBucketPolicy: () => dispatch(actionsBuckets.showBucketPolicy()),
|
showBucketPolicy: () => dispatch(actionsBuckets.showBucketPolicy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export const BucketPolicyModal = ({
|
|||||||
showBucketPolicy,
|
showBucketPolicy,
|
||||||
currentBucket,
|
currentBucket,
|
||||||
hideBucketPolicy,
|
hideBucketPolicy,
|
||||||
policies,
|
policies
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@ -53,13 +53,13 @@ const mapStateToProps = state => {
|
|||||||
return {
|
return {
|
||||||
currentBucket: state.buckets.currentBucket,
|
currentBucket: state.buckets.currentBucket,
|
||||||
showBucketPolicy: state.buckets.showBucketPolicy,
|
showBucketPolicy: state.buckets.showBucketPolicy,
|
||||||
policies: state.buckets.policies,
|
policies: state.buckets.policies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
hideBucketPolicy: () => dispatch(actionsBuckets.hideBucketPolicy()),
|
hideBucketPolicy: () => dispatch(actionsBuckets.hideBucketPolicy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ const mapDispatchToProps = dispatch => {
|
|||||||
return {
|
return {
|
||||||
onChange: filter => {
|
onChange: filter => {
|
||||||
dispatch(actionsBuckets.setFilter(filter))
|
dispatch(actionsBuckets.setFilter(filter))
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export class MakeBucketModal extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
bucketName: "",
|
bucketName: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onSubmit(e) {
|
onSubmit(e) {
|
||||||
@ -37,7 +37,7 @@ export class MakeBucketModal extends React.Component {
|
|||||||
}
|
}
|
||||||
hideModal() {
|
hideModal() {
|
||||||
this.setState({
|
this.setState({
|
||||||
bucketName: "",
|
bucketName: ""
|
||||||
})
|
})
|
||||||
this.props.hideMakeBucketModal()
|
this.props.hideMakeBucketModal()
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ export class MakeBucketModal extends React.Component {
|
|||||||
value={this.state.bucketName}
|
value={this.state.bucketName}
|
||||||
onChange={e =>
|
onChange={e =>
|
||||||
this.setState({
|
this.setState({
|
||||||
bucketName: e.target.value,
|
bucketName: e.target.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
autoFocus
|
autoFocus
|
||||||
@ -78,14 +78,14 @@ export class MakeBucketModal extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
showMakeBucketModal: state.buckets.showMakeBucketModal,
|
showMakeBucketModal: state.buckets.showMakeBucketModal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
makeBucket: bucket => dispatch(actionsBuckets.makeBucket(bucket)),
|
makeBucket: bucket => dispatch(actionsBuckets.makeBucket(bucket)),
|
||||||
hideMakeBucketModal: () => dispatch(actionsBuckets.hideMakeBucketModal()),
|
hideMakeBucketModal: () => dispatch(actionsBuckets.hideMakeBucketModal())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export class Policy extends React.Component {
|
|||||||
.SetBucketPolicy({
|
.SetBucketPolicy({
|
||||||
bucketName: currentBucket,
|
bucketName: currentBucket,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
policy: "none",
|
policy: "none"
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchPolicies(currentBucket)
|
fetchPolicies(currentBucket)
|
||||||
@ -79,7 +79,7 @@ export class Policy extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
currentBucket: state.buckets.currentBucket,
|
currentBucket: state.buckets.currentBucket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,9 +90,9 @@ const mapDispatchToProps = dispatch => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
actionsAlert.set({
|
actionsAlert.set({
|
||||||
type: type,
|
type: type,
|
||||||
message: message,
|
message: message
|
||||||
}),
|
})
|
||||||
),
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export class PolicyInput extends React.Component {
|
|||||||
|
|
||||||
let policyAlreadyExists = this.props.policies.some(
|
let policyAlreadyExists = this.props.policies.some(
|
||||||
elem =>
|
elem =>
|
||||||
this.prefix.value === elem.prefix && this.policy.value === elem.policy,
|
this.prefix.value === elem.prefix && this.policy.value === elem.policy
|
||||||
)
|
)
|
||||||
if (policyAlreadyExists) {
|
if (policyAlreadyExists) {
|
||||||
showAlert("danger", "Policy for this prefix already exists.")
|
showAlert("danger", "Policy for this prefix already exists.")
|
||||||
@ -53,7 +53,7 @@ export class PolicyInput extends React.Component {
|
|||||||
.SetBucketPolicy({
|
.SetBucketPolicy({
|
||||||
bucketName: currentBucket,
|
bucketName: currentBucket,
|
||||||
prefix: this.prefix.value,
|
prefix: this.prefix.value,
|
||||||
policy: this.policy.value,
|
policy: this.policy.value
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchPolicies(currentBucket)
|
fetchPolicies(currentBucket)
|
||||||
@ -99,7 +99,7 @@ export class PolicyInput extends React.Component {
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
currentBucket: state.buckets.currentBucket,
|
currentBucket: state.buckets.currentBucket,
|
||||||
policies: state.buckets.policies,
|
policies: state.buckets.policies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +111,9 @@ const mapDispatchToProps = dispatch => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
actionsAlert.set({
|
actionsAlert.set({
|
||||||
type: type,
|
type: type,
|
||||||
message: message,
|
message: message
|
||||||
}),
|
})
|
||||||
),
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,16 +26,16 @@ describe("Bucket", () => {
|
|||||||
it("should call selectBucket when clicked", () => {
|
it("should call selectBucket when clicked", () => {
|
||||||
const selectBucket = jest.fn()
|
const selectBucket = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Bucket bucket={"test"} selectBucket={selectBucket} />,
|
<Bucket bucket={"test"} selectBucket={selectBucket} />
|
||||||
)
|
)
|
||||||
wrapper.find("li").simulate("click", {
|
wrapper.find("div").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(selectBucket).toHaveBeenCalledWith("test")
|
expect(selectBucket).toHaveBeenCalledWith("test")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should highlight the selected bucket", () => {
|
it("should highlight the selected bucket", () => {
|
||||||
const wrapper = shallow(<Bucket bucket={"test"} isActive={true} />)
|
const wrapper = shallow(<Bucket bucket={"test"} isActive={true} />)
|
||||||
expect(wrapper.find("li").hasClass("active")).toBeTruthy()
|
expect(wrapper.find("div").hasClass("buckets__item--active")).toBeTruthy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -26,8 +26,8 @@ describe("BucketContainer", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = mockStore({
|
store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "Test",
|
currentBucket: "Test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
store.dispatch = jest.fn()
|
store.dispatch = jest.fn()
|
||||||
})
|
})
|
||||||
@ -41,8 +41,8 @@ describe("BucketContainer", () => {
|
|||||||
expect(wrapper.props()).toEqual(
|
expect(wrapper.props()).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
isActive: expect.any(Boolean),
|
isActive: expect.any(Boolean),
|
||||||
selectBucket: expect.any(Function),
|
selectBucket: expect.any(Function)
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ describe("BucketDropdown", () => {
|
|||||||
it("should call showBucketPolicy when Edit Policy link is clicked", () => {
|
it("should call showBucketPolicy when Edit Policy link is clicked", () => {
|
||||||
const showBucketPolicy = jest.fn()
|
const showBucketPolicy = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BucketDropdown showBucketPolicy={showBucketPolicy} />,
|
<BucketDropdown showBucketPolicy={showBucketPolicy} />
|
||||||
)
|
)
|
||||||
wrapper
|
wrapper
|
||||||
.find("li a")
|
.find("MenuItem")
|
||||||
.at(0)
|
.at(0)
|
||||||
.simulate("click", {
|
.simulate("click", {
|
||||||
stopPropagation: jest.fn(),
|
stopPropagation: jest.fn()
|
||||||
})
|
})
|
||||||
expect(showBucketPolicy).toHaveBeenCalled()
|
expect(showBucketPolicy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -49,13 +49,13 @@ describe("BucketDropdown", () => {
|
|||||||
it("should call deleteBucket when Delete link is clicked", () => {
|
it("should call deleteBucket when Delete link is clicked", () => {
|
||||||
const deleteBucket = jest.fn()
|
const deleteBucket = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BucketDropdown bucket={"test"} deleteBucket={deleteBucket} />,
|
<BucketDropdown bucket={"test"} deleteBucket={deleteBucket} />
|
||||||
)
|
)
|
||||||
wrapper
|
wrapper
|
||||||
.find("li a")
|
.find("MenuItem")
|
||||||
.at(1)
|
.at(1)
|
||||||
.simulate("click", {
|
.simulate("click", {
|
||||||
stopPropagation: jest.fn(),
|
stopPropagation: jest.fn()
|
||||||
})
|
})
|
||||||
expect(deleteBucket).toHaveBeenCalledWith("test")
|
expect(deleteBucket).toHaveBeenCalledWith("test")
|
||||||
})
|
})
|
||||||
|
@ -23,19 +23,19 @@ jest.mock("../../web", () => ({
|
|||||||
LoggedIn: jest
|
LoggedIn: jest
|
||||||
.fn(() => false)
|
.fn(() => false)
|
||||||
.mockReturnValueOnce(true)
|
.mockReturnValueOnce(true)
|
||||||
.mockReturnValueOnce(true),
|
.mockReturnValueOnce(true)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("BucketList", () => {
|
describe("BucketList", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
const fetchBuckets = jest.fn()
|
const fetchBuckets = jest.fn()
|
||||||
shallow(<BucketList visibleBuckets={[]} fetchBuckets={fetchBuckets} />)
|
shallow(<BucketList filteredBuckets={[]} fetchBuckets={fetchBuckets} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call fetchBuckets before component is mounted", () => {
|
it("should call fetchBuckets before component is mounted", () => {
|
||||||
const fetchBuckets = jest.fn()
|
const fetchBuckets = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BucketList visibleBuckets={[]} fetchBuckets={fetchBuckets} />,
|
<BucketList filteredBuckets={[]} fetchBuckets={fetchBuckets} />
|
||||||
)
|
)
|
||||||
expect(fetchBuckets).toHaveBeenCalled()
|
expect(fetchBuckets).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -46,10 +46,10 @@ describe("BucketList", () => {
|
|||||||
history.push("/bk1/pre1")
|
history.push("/bk1/pre1")
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BucketList
|
<BucketList
|
||||||
visibleBuckets={[]}
|
filteredBuckets={[]}
|
||||||
setBucketList={setBucketList}
|
setBucketList={setBucketList}
|
||||||
selectBucket={selectBucket}
|
selectBucket={selectBucket}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(setBucketList).toHaveBeenCalledWith(["bk1"])
|
expect(setBucketList).toHaveBeenCalledWith(["bk1"])
|
||||||
expect(selectBucket).toHaveBeenCalledWith("bk1", "pre1")
|
expect(selectBucket).toHaveBeenCalledWith("bk1", "pre1")
|
||||||
|
@ -27,15 +27,15 @@ describe("BucketPolicyModal", () => {
|
|||||||
it("should call hideBucketPolicy when close button is clicked", () => {
|
it("should call hideBucketPolicy when close button is clicked", () => {
|
||||||
const hideBucketPolicy = jest.fn()
|
const hideBucketPolicy = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<BucketPolicyModal hideBucketPolicy={hideBucketPolicy} policies={[]} />,
|
<BucketPolicyModal hideBucketPolicy={hideBucketPolicy} policies={[]} />
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click")
|
wrapper.find("i.close").simulate("click")
|
||||||
expect(hideBucketPolicy).toHaveBeenCalled()
|
expect(hideBucketPolicy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should include the PolicyInput and Policy components when there are any policies", () => {
|
it("should include the PolicyInput and Policy components when there are any policies", () => {
|
||||||
const wrapper = shallow(
|
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(PolicyInput)").length).toBe(1)
|
||||||
expect(wrapper.find("Connect(Policy)").length).toBe(1)
|
expect(wrapper.find("Connect(Policy)").length).toBe(1)
|
||||||
|
@ -28,8 +28,8 @@ describe("BucketSearch", () => {
|
|||||||
const wrapper = shallow(<BucketSearch onChange={onChange} />)
|
const wrapper = shallow(<BucketSearch onChange={onChange} />)
|
||||||
wrapper.find("input").simulate("change", {
|
wrapper.find("input").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test",
|
value: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
expect(onChange).toHaveBeenCalledWith("test")
|
expect(onChange).toHaveBeenCalledWith("test")
|
||||||
})
|
})
|
||||||
|
@ -26,24 +26,24 @@ describe("MakeBucketModal", () => {
|
|||||||
it("should call hideMakeBucketModal when close button is clicked", () => {
|
it("should call hideMakeBucketModal when close button is clicked", () => {
|
||||||
const hideMakeBucketModal = jest.fn()
|
const hideMakeBucketModal = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />,
|
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click")
|
wrapper.find("i.close").simulate("click")
|
||||||
expect(hideMakeBucketModal).toHaveBeenCalled()
|
expect(hideMakeBucketModal).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("bucketName should be cleared before hiding the modal", () => {
|
it("bucketName should be cleared before hiding the modal", () => {
|
||||||
const hideMakeBucketModal = jest.fn()
|
const hideMakeBucketModal = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />,
|
<MakeBucketModal hideMakeBucketModal={hideMakeBucketModal} />
|
||||||
)
|
)
|
||||||
wrapper.find("input").simulate("change", {
|
wrapper.find("input").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test",
|
value: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
expect(wrapper.state("bucketName")).toBe("test")
|
expect(wrapper.state("bucketName")).toBe("test")
|
||||||
wrapper.find("button").simulate("click")
|
wrapper.find("i.close").simulate("click")
|
||||||
expect(wrapper.state("bucketName")).toBe("")
|
expect(wrapper.state("bucketName")).toBe("")
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -54,15 +54,15 @@ describe("MakeBucketModal", () => {
|
|||||||
<MakeBucketModal
|
<MakeBucketModal
|
||||||
makeBucket={makeBucket}
|
makeBucket={makeBucket}
|
||||||
hideMakeBucketModal={hideMakeBucketModal}
|
hideMakeBucketModal={hideMakeBucketModal}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("input").simulate("change", {
|
wrapper.find("input").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test",
|
value: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("form").simulate("submit", {
|
wrapper.find("form").simulate("submit", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(makeBucket).toHaveBeenCalledWith("test")
|
expect(makeBucket).toHaveBeenCalledWith("test")
|
||||||
})
|
})
|
||||||
@ -74,15 +74,15 @@ describe("MakeBucketModal", () => {
|
|||||||
<MakeBucketModal
|
<MakeBucketModal
|
||||||
makeBucket={makeBucket}
|
makeBucket={makeBucket}
|
||||||
hideMakeBucketModal={hideMakeBucketModal}
|
hideMakeBucketModal={hideMakeBucketModal}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("input").simulate("change", {
|
wrapper.find("input").simulate("change", {
|
||||||
target: {
|
target: {
|
||||||
value: "test",
|
value: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("form").simulate("submit", {
|
wrapper.find("form").simulate("submit", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(hideMakeBucketModal).toHaveBeenCalled()
|
expect(hideMakeBucketModal).toHaveBeenCalled()
|
||||||
expect(wrapper.state("bucketName")).toBe("")
|
expect(wrapper.state("bucketName")).toBe("")
|
||||||
|
@ -23,13 +23,13 @@ import web from "../../web"
|
|||||||
jest.mock("../../web", () => ({
|
jest.mock("../../web", () => ({
|
||||||
SetBucketPolicy: jest.fn(() => {
|
SetBucketPolicy: jest.fn(() => {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}),
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("Policy", () => {
|
describe("Policy", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(
|
shallow(
|
||||||
<Policy currentBucket={"bucket"} prefix={"foo"} policy={READ_ONLY} />,
|
<Policy currentBucket={"bucket"} prefix={"foo"} policy={READ_ONLY} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -41,16 +41,16 @@ describe("Policy", () => {
|
|||||||
prefix={"foo"}
|
prefix={"foo"}
|
||||||
policy={READ_ONLY}
|
policy={READ_ONLY}
|
||||||
fetchPolicies={fetchPolicies}
|
fetchPolicies={fetchPolicies}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click", {
|
wrapper.find("button").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
||||||
bucketName: "bucket",
|
bucketName: "bucket",
|
||||||
prefix: "foo",
|
prefix: "foo",
|
||||||
policy: "none",
|
policy: "none"
|
||||||
})
|
})
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@ -60,13 +60,13 @@ describe("Policy", () => {
|
|||||||
|
|
||||||
it("should change the empty string to '*' while displaying prefixes", () => {
|
it("should change the empty string to '*' while displaying prefixes", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Policy currentBucket={"bucket"} prefix={""} policy={READ_ONLY} />,
|
<Policy currentBucket={"bucket"} prefix={""} policy={READ_ONLY} />
|
||||||
)
|
)
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find(".pmbl-item")
|
.find("input")
|
||||||
.at(0)
|
.at(0)
|
||||||
.text(),
|
.prop("value")
|
||||||
).toEqual("*")
|
).toEqual("*")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -23,21 +23,21 @@ import web from "../../web"
|
|||||||
jest.mock("../../web", () => ({
|
jest.mock("../../web", () => ({
|
||||||
SetBucketPolicy: jest.fn(() => {
|
SetBucketPolicy: jest.fn(() => {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}),
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("PolicyInput", () => {
|
describe("PolicyInput", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
const fetchPolicies = jest.fn()
|
const fetchPolicies = jest.fn()
|
||||||
shallow(
|
shallow(
|
||||||
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />,
|
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call fetchPolicies after the component has mounted", () => {
|
it("should call fetchPolicies after the component has mounted", () => {
|
||||||
const fetchPolicies = jest.fn()
|
const fetchPolicies = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />,
|
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />
|
||||||
)
|
)
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
expect(fetchPolicies).toHaveBeenCalled()
|
expect(fetchPolicies).toHaveBeenCalled()
|
||||||
@ -51,22 +51,22 @@ describe("PolicyInput", () => {
|
|||||||
currentBucket={"bucket"}
|
currentBucket={"bucket"}
|
||||||
policies={[]}
|
policies={[]}
|
||||||
fetchPolicies={fetchPolicies}
|
fetchPolicies={fetchPolicies}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.instance().prefix = {
|
wrapper.instance().prefix = {
|
||||||
value: "baz",
|
value: "baz"
|
||||||
}
|
}
|
||||||
wrapper.instance().policy = {
|
wrapper.instance().policy = {
|
||||||
value: READ_ONLY,
|
value: READ_ONLY
|
||||||
}
|
}
|
||||||
wrapper.find("button").simulate("click", {
|
wrapper.find("button").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
||||||
bucketName: "bucket",
|
bucketName: "bucket",
|
||||||
prefix: "baz",
|
prefix: "baz",
|
||||||
policy: READ_ONLY,
|
policy: READ_ONLY
|
||||||
})
|
})
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@ -81,21 +81,21 @@ describe("PolicyInput", () => {
|
|||||||
currentBucket={"bucket"}
|
currentBucket={"bucket"}
|
||||||
policies={[]}
|
policies={[]}
|
||||||
fetchPolicies={fetchPolicies}
|
fetchPolicies={fetchPolicies}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.instance().prefix = {
|
wrapper.instance().prefix = {
|
||||||
value: "*",
|
value: "*"
|
||||||
}
|
}
|
||||||
wrapper.instance().policy = {
|
wrapper.instance().policy = {
|
||||||
value: READ_ONLY,
|
value: READ_ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.find("button").simulate("click", {
|
wrapper.find("button").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(wrapper.instance().prefix).toEqual({
|
expect(wrapper.instance().prefix).toEqual({
|
||||||
value: "",
|
value: ""
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -24,12 +24,12 @@ jest.mock("../../web", () => ({
|
|||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
buckets: [
|
buckets: [
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
MakeBucket: jest.fn(() => {
|
MakeBucket: jest.fn(() => {
|
||||||
@ -37,11 +37,11 @@ jest.mock("../../web", () => ({
|
|||||||
}),
|
}),
|
||||||
DeleteBucket: jest.fn(() => {
|
DeleteBucket: jest.fn(() => {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}),
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
jest.mock("../../objects/actions", () => ({
|
jest.mock("../../objects/actions", () => ({
|
||||||
selectPrefix: () => dispatch => {},
|
selectPrefix: () => dispatch => {}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const middlewares = [thunk]
|
const middlewares = [thunk]
|
||||||
@ -53,12 +53,12 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SET_LIST",
|
type: "buckets/SET_LIST",
|
||||||
buckets: ["test1", "test2"],
|
buckets: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -72,12 +72,12 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SET_LIST",
|
type: "buckets/SET_LIST",
|
||||||
buckets: ["test1", "test2"],
|
buckets: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test2",
|
bucket: "test2"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
window.location
|
window.location
|
||||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||||
@ -92,12 +92,12 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SET_LIST",
|
type: "buckets/SET_LIST",
|
||||||
buckets: ["test1", "test2"],
|
buckets: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
window.location
|
window.location
|
||||||
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
|
||||||
@ -111,8 +111,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.selectBucket("test1"))
|
store.dispatch(actionsBuckets.selectBucket("test1"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -124,8 +124,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
||||||
show: true,
|
show: true
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.showMakeBucketModal())
|
store.dispatch(actionsBuckets.showMakeBucketModal())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -137,8 +137,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
|
||||||
show: false,
|
show: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.hideMakeBucketModal())
|
store.dispatch(actionsBuckets.hideMakeBucketModal())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -150,8 +150,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SHOW_BUCKET_POLICY",
|
type: "buckets/SHOW_BUCKET_POLICY",
|
||||||
show: true,
|
show: true
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.showBucketPolicy())
|
store.dispatch(actionsBuckets.showBucketPolicy())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -163,8 +163,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SHOW_BUCKET_POLICY",
|
type: "buckets/SHOW_BUCKET_POLICY",
|
||||||
show: false,
|
show: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.hideBucketPolicy())
|
store.dispatch(actionsBuckets.hideBucketPolicy())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -176,8 +176,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/SET_POLICIES",
|
type: "buckets/SET_POLICIES",
|
||||||
policies: ["test1", "test2"],
|
policies: ["test1", "test2"]
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.setPolicies(["test1", "test2"]))
|
store.dispatch(actionsBuckets.setPolicies(["test1", "test2"]))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -189,8 +189,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/ADD",
|
type: "buckets/ADD",
|
||||||
bucket: "test",
|
bucket: "test"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.addBucket("test"))
|
store.dispatch(actionsBuckets.addBucket("test"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -202,8 +202,8 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/REMOVE",
|
type: "buckets/REMOVE",
|
||||||
bucket: "test",
|
bucket: "test"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsBuckets.removeBucket("test"))
|
store.dispatch(actionsBuckets.removeBucket("test"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -215,12 +215,12 @@ describe("Buckets actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "buckets/ADD",
|
type: "buckets/ADD",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsBuckets.makeBucket("test1")).then(() => {
|
return store.dispatch(actionsBuckets.makeBucket("test1")).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -239,26 +239,26 @@ describe("Buckets actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
id: 0,
|
id: 0,
|
||||||
message: "Bucket 'test3' has been deleted.",
|
message: "Bucket 'test3' has been deleted.",
|
||||||
type: "info",
|
type: "info"
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/REMOVE",
|
type: "buckets/REMOVE",
|
||||||
bucket: "test3",
|
bucket: "test3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_LIST",
|
type: "buckets/SET_LIST",
|
||||||
buckets: ["test1", "test2"],
|
buckets: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "buckets/SET_CURRENT_BUCKET",
|
type: "buckets/SET_CURRENT_BUCKET",
|
||||||
bucket: "test1",
|
bucket: "test1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsBuckets.deleteBucket("test3")).then(() => {
|
return store.dispatch(actionsBuckets.deleteBucket("test3")).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
expect(actions).toEqual(expectedActions)
|
expect(actions).toEqual(expectedActions)
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -26,14 +26,14 @@ describe("buckets reducer", () => {
|
|||||||
filter: "",
|
filter: "",
|
||||||
currentBucket: "",
|
currentBucket: "",
|
||||||
showBucketPolicy: false,
|
showBucketPolicy: false,
|
||||||
showMakeBucketModal: false,
|
showMakeBucketModal: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle SET_LIST", () => {
|
it("should handle SET_LIST", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_LIST,
|
type: actions.SET_LIST,
|
||||||
buckets: ["bk1", "bk2"],
|
buckets: ["bk1", "bk2"]
|
||||||
})
|
})
|
||||||
expect(newState.list).toEqual(["bk1", "bk2"])
|
expect(newState.list).toEqual(["bk1", "bk2"])
|
||||||
})
|
})
|
||||||
@ -41,12 +41,12 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle ADD", () => {
|
it("should handle ADD", () => {
|
||||||
const newState = reducer(
|
const newState = reducer(
|
||||||
{
|
{
|
||||||
list: ["test1", "test2"],
|
list: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.ADD,
|
type: actions.ADD,
|
||||||
bucket: "test3",
|
bucket: "test3"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.list).toEqual(["test3", "test1", "test2"])
|
expect(newState.list).toEqual(["test3", "test1", "test2"])
|
||||||
})
|
})
|
||||||
@ -54,12 +54,12 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle REMOVE", () => {
|
it("should handle REMOVE", () => {
|
||||||
const newState = reducer(
|
const newState = reducer(
|
||||||
{
|
{
|
||||||
list: ["test1", "test2"],
|
list: ["test1", "test2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.REMOVE,
|
type: actions.REMOVE,
|
||||||
bucket: "test2",
|
bucket: "test2"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.list).toEqual(["test1"])
|
expect(newState.list).toEqual(["test1"])
|
||||||
})
|
})
|
||||||
@ -67,7 +67,7 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle SET_FILTER", () => {
|
it("should handle SET_FILTER", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_FILTER,
|
type: actions.SET_FILTER,
|
||||||
filter: "test",
|
filter: "test"
|
||||||
})
|
})
|
||||||
expect(newState.filter).toEqual("test")
|
expect(newState.filter).toEqual("test")
|
||||||
})
|
})
|
||||||
@ -75,7 +75,7 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle SET_CURRENT_BUCKET", () => {
|
it("should handle SET_CURRENT_BUCKET", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_CURRENT_BUCKET,
|
type: actions.SET_CURRENT_BUCKET,
|
||||||
bucket: "test",
|
bucket: "test"
|
||||||
})
|
})
|
||||||
expect(newState.currentBucket).toEqual("test")
|
expect(newState.currentBucket).toEqual("test")
|
||||||
})
|
})
|
||||||
@ -83,7 +83,7 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle SET_POLICIES", () => {
|
it("should handle SET_POLICIES", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_POLICIES,
|
type: actions.SET_POLICIES,
|
||||||
policies: ["test1", "test2"],
|
policies: ["test1", "test2"]
|
||||||
})
|
})
|
||||||
expect(newState.policies).toEqual(["test1", "test2"])
|
expect(newState.policies).toEqual(["test1", "test2"])
|
||||||
})
|
})
|
||||||
@ -91,7 +91,7 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle SHOW_BUCKET_POLICY", () => {
|
it("should handle SHOW_BUCKET_POLICY", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SHOW_BUCKET_POLICY,
|
type: actions.SHOW_BUCKET_POLICY,
|
||||||
show: true,
|
show: true
|
||||||
})
|
})
|
||||||
expect(newState.showBucketPolicy).toBeTruthy()
|
expect(newState.showBucketPolicy).toBeTruthy()
|
||||||
})
|
})
|
||||||
@ -99,7 +99,7 @@ describe("buckets reducer", () => {
|
|||||||
it("should handle SHOW_MAKE_BUCKET_MODAL", () => {
|
it("should handle SHOW_MAKE_BUCKET_MODAL", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SHOW_MAKE_BUCKET_MODAL,
|
type: actions.SHOW_MAKE_BUCKET_MODAL,
|
||||||
show: true,
|
show: true
|
||||||
})
|
})
|
||||||
expect(newState.showMakeBucketModal).toBeTruthy()
|
expect(newState.showMakeBucketModal).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
@ -52,14 +52,14 @@ export const fetchBuckets = () => {
|
|||||||
export const setList = buckets => {
|
export const setList = buckets => {
|
||||||
return {
|
return {
|
||||||
type: SET_LIST,
|
type: SET_LIST,
|
||||||
buckets,
|
buckets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setFilter = filter => {
|
export const setFilter = filter => {
|
||||||
return {
|
return {
|
||||||
type: SET_FILTER,
|
type: SET_FILTER,
|
||||||
filter,
|
filter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ export const selectBucket = (bucket, prefix) => {
|
|||||||
export const setCurrentBucket = bucket => {
|
export const setCurrentBucket = bucket => {
|
||||||
return {
|
return {
|
||||||
type: SET_CURRENT_BUCKET,
|
type: SET_CURRENT_BUCKET,
|
||||||
bucket,
|
bucket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export const makeBucket = bucket => {
|
|||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
return web
|
return web
|
||||||
.MakeBucket({
|
.MakeBucket({
|
||||||
bucketName: bucket,
|
bucketName: bucket
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(addBucket(bucket))
|
dispatch(addBucket(bucket))
|
||||||
@ -91,9 +91,9 @@ export const makeBucket = bucket => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,14 +102,14 @@ export const deleteBucket = bucket => {
|
|||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
return web
|
return web
|
||||||
.DeleteBucket({
|
.DeleteBucket({
|
||||||
bucketName: bucket,
|
bucketName: bucket
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "info",
|
type: "info",
|
||||||
message: "Bucket '" + bucket + "' has been deleted.",
|
message: "Bucket '" + bucket + "' has been deleted."
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
dispatch(removeBucket(bucket))
|
dispatch(removeBucket(bucket))
|
||||||
dispatch(fetchBuckets())
|
dispatch(fetchBuckets())
|
||||||
@ -118,8 +118,8 @@ export const deleteBucket = bucket => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -127,29 +127,29 @@ export const deleteBucket = bucket => {
|
|||||||
|
|
||||||
export const addBucket = bucket => ({
|
export const addBucket = bucket => ({
|
||||||
type: ADD,
|
type: ADD,
|
||||||
bucket,
|
bucket
|
||||||
})
|
})
|
||||||
|
|
||||||
export const removeBucket = bucket => ({
|
export const removeBucket = bucket => ({
|
||||||
type: REMOVE,
|
type: REMOVE,
|
||||||
bucket,
|
bucket
|
||||||
})
|
})
|
||||||
|
|
||||||
export const showMakeBucketModal = () => ({
|
export const showMakeBucketModal = () => ({
|
||||||
type: SHOW_MAKE_BUCKET_MODAL,
|
type: SHOW_MAKE_BUCKET_MODAL,
|
||||||
show: true,
|
show: true
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideMakeBucketModal = () => ({
|
export const hideMakeBucketModal = () => ({
|
||||||
type: SHOW_MAKE_BUCKET_MODAL,
|
type: SHOW_MAKE_BUCKET_MODAL,
|
||||||
show: false,
|
show: false
|
||||||
})
|
})
|
||||||
|
|
||||||
export const fetchPolicies = bucket => {
|
export const fetchPolicies = bucket => {
|
||||||
return function(dispatch) {
|
return function(dispatch) {
|
||||||
return web
|
return web
|
||||||
.ListAllBucketPolicies({
|
.ListAllBucketPolicies({
|
||||||
bucketName: bucket,
|
bucketName: bucket
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let policies = res.policies
|
let policies = res.policies
|
||||||
@ -160,8 +160,8 @@ export const fetchPolicies = bucket => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -169,15 +169,15 @@ export const fetchPolicies = bucket => {
|
|||||||
|
|
||||||
export const setPolicies = policies => ({
|
export const setPolicies = policies => ({
|
||||||
type: SET_POLICIES,
|
type: SET_POLICIES,
|
||||||
policies,
|
policies
|
||||||
})
|
})
|
||||||
|
|
||||||
export const showBucketPolicy = () => ({
|
export const showBucketPolicy = () => ({
|
||||||
type: SHOW_BUCKET_POLICY,
|
type: SHOW_BUCKET_POLICY,
|
||||||
show: true,
|
show: true
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideBucketPolicy = () => ({
|
export const hideBucketPolicy = () => ({
|
||||||
type: SHOW_BUCKET_POLICY,
|
type: SHOW_BUCKET_POLICY,
|
||||||
show: false,
|
show: false
|
||||||
})
|
})
|
||||||
|
@ -31,50 +31,50 @@ export default (
|
|||||||
currentBucket: "",
|
currentBucket: "",
|
||||||
showMakeBucketModal: false,
|
showMakeBucketModal: false,
|
||||||
policies: [],
|
policies: [],
|
||||||
showBucketPolicy: false,
|
showBucketPolicy: false
|
||||||
},
|
},
|
||||||
action,
|
action
|
||||||
) => {
|
) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actionsBuckets.SET_LIST:
|
case actionsBuckets.SET_LIST:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
list: action.buckets,
|
list: action.buckets
|
||||||
}
|
}
|
||||||
case actionsBuckets.ADD:
|
case actionsBuckets.ADD:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
list: [action.bucket, ...state.list],
|
list: [action.bucket, ...state.list]
|
||||||
}
|
}
|
||||||
case actionsBuckets.REMOVE:
|
case actionsBuckets.REMOVE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
list: removeBucket(state.list, action),
|
list: removeBucket(state.list, action)
|
||||||
}
|
}
|
||||||
case actionsBuckets.SET_FILTER:
|
case actionsBuckets.SET_FILTER:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
filter: action.filter,
|
filter: action.filter
|
||||||
}
|
}
|
||||||
case actionsBuckets.SET_CURRENT_BUCKET:
|
case actionsBuckets.SET_CURRENT_BUCKET:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
currentBucket: action.bucket,
|
currentBucket: action.bucket
|
||||||
}
|
}
|
||||||
case actionsBuckets.SHOW_MAKE_BUCKET_MODAL:
|
case actionsBuckets.SHOW_MAKE_BUCKET_MODAL:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
showMakeBucketModal: action.show,
|
showMakeBucketModal: action.show
|
||||||
}
|
}
|
||||||
case actionsBuckets.SET_POLICIES:
|
case actionsBuckets.SET_POLICIES:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
policies: action.policies,
|
policies: action.policies
|
||||||
}
|
}
|
||||||
case actionsBuckets.SHOW_BUCKET_POLICY:
|
case actionsBuckets.SHOW_BUCKET_POLICY:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
showBucketPolicy: action.show,
|
showBucketPolicy: action.show
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
@ -22,7 +22,7 @@ const bucketsFilterSelector = state => state.buckets.filter
|
|||||||
export const getFilteredBuckets = createSelector(
|
export const getFilteredBuckets = createSelector(
|
||||||
bucketsSelector,
|
bucketsSelector,
|
||||||
bucketsFilterSelector,
|
bucketsFilterSelector,
|
||||||
(buckets, filter) => buckets.filter(bucket => bucket.indexOf(filter) > -1),
|
(buckets, filter) => buckets.filter(bucket => bucket.indexOf(filter) > -1)
|
||||||
)
|
)
|
||||||
|
|
||||||
export const getCurrentBucket = state => state.buckets.currentBucket
|
export const getCurrentBucket = state => state.buckets.currentBucket
|
||||||
|
@ -45,6 +45,6 @@ let BrowserUpdate = ({ latestUiVersion }) => {
|
|||||||
|
|
||||||
export default connect(state => {
|
export default connect(state => {
|
||||||
return {
|
return {
|
||||||
latestUiVersion: state.latestUiVersion,
|
latestUiVersion: state.latestUiVersion
|
||||||
}
|
}
|
||||||
})(BrowserUpdate)
|
})(BrowserUpdate)
|
||||||
|
@ -18,7 +18,7 @@ import createHistory from "history/createBrowserHistory"
|
|||||||
import { minioBrowserPrefix } from "./constants"
|
import { minioBrowserPrefix } from "./constants"
|
||||||
|
|
||||||
const history = createHistory({
|
const history = createHistory({
|
||||||
basename: minioBrowserPrefix,
|
basename: minioBrowserPrefix
|
||||||
})
|
})
|
||||||
|
|
||||||
export default history
|
export default history
|
||||||
|
@ -19,5 +19,5 @@ import { configure } from "enzyme"
|
|||||||
import Adapter from "enzyme-adapter-react-16"
|
import Adapter from "enzyme-adapter-react-16"
|
||||||
|
|
||||||
configure({
|
configure({
|
||||||
adapter: new Adapter(),
|
adapter: new Adapter()
|
||||||
})
|
})
|
||||||
|
@ -63,7 +63,7 @@ export default class JSONrpc {
|
|||||||
id: options.id,
|
id: options.id,
|
||||||
jsonrpc: this.version,
|
jsonrpc: this.version,
|
||||||
params: options.params ? options.params : {},
|
params: options.params ? options.params : {},
|
||||||
method: this.namespace ? this.namespace + "." + method : method,
|
method: this.namespace ? this.namespace + "." + method : method
|
||||||
}
|
}
|
||||||
let requestParams = {
|
let requestParams = {
|
||||||
host: this.host,
|
host: this.host,
|
||||||
@ -76,8 +76,8 @@ export default class JSONrpc {
|
|||||||
"x-amz-date":
|
"x-amz-date":
|
||||||
Moment()
|
Moment()
|
||||||
.utc()
|
.utc()
|
||||||
.format("YYYYMMDDTHHmmss") + "Z",
|
.format("YYYYMMDDTHHmmss") + "Z"
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
|
@ -59,7 +59,7 @@ const isCode = (name, contentType) => {
|
|||||||
"scm",
|
"scm",
|
||||||
"lisp",
|
"lisp",
|
||||||
"asp",
|
"asp",
|
||||||
"aspx",
|
"aspx"
|
||||||
]
|
]
|
||||||
const ext = name.split(".").reverse()[0]
|
const ext = name.split(".").reverse()[0]
|
||||||
for (var i in codeExt) {
|
for (var i in codeExt) {
|
||||||
@ -121,7 +121,7 @@ export const getDataType = (name, contentType) => {
|
|||||||
["zip", isZip],
|
["zip", isZip],
|
||||||
["excel", isExcel],
|
["excel", isExcel],
|
||||||
["doc", isDoc],
|
["doc", isDoc],
|
||||||
["presentation", isPresentation],
|
["presentation", isPresentation]
|
||||||
]
|
]
|
||||||
for (var i in check) {
|
for (var i in check) {
|
||||||
if (check[i][1](name, contentType)) return check[i][0]
|
if (check[i][1](name, contentType)) return check[i][0]
|
||||||
|
@ -19,7 +19,7 @@ import ConfirmModal from "../browser/ConfirmModal"
|
|||||||
|
|
||||||
export const DeleteObjectConfirmModal = ({
|
export const DeleteObjectConfirmModal = ({
|
||||||
deleteObject,
|
deleteObject,
|
||||||
hideDeleteConfirmModal,
|
hideDeleteConfirmModal
|
||||||
}) => (
|
}) => (
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
show={true}
|
show={true}
|
||||||
|
@ -27,14 +27,14 @@ export const ObjectContainer = ({ object, downloadObject }) => {
|
|||||||
name: object.name,
|
name: object.name,
|
||||||
contentType: object.contentType,
|
contentType: object.contentType,
|
||||||
size: humanize.filesize(object.size),
|
size: humanize.filesize(object.size),
|
||||||
lastModified: Moment(object.lastModified).format("lll"),
|
lastModified: Moment(object.lastModified).format("lll")
|
||||||
}
|
}
|
||||||
return <ObjectItem {...props} onClick={() => downloadObject(object.name)} />
|
return <ObjectItem {...props} onClick={() => downloadObject(object.name)} />
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
downloadObject: object => dispatch(actionsObjects.downloadObject(object)),
|
downloadObject: object => dispatch(actionsObjects.downloadObject(object))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ export const ObjectItem = ({
|
|||||||
checked,
|
checked,
|
||||||
checkObject,
|
checkObject,
|
||||||
uncheckObject,
|
uncheckObject,
|
||||||
onClick,
|
onClick
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames({
|
className={classNames({
|
||||||
objects__row: true,
|
objects__row: true,
|
||||||
"objects__row--directory": getDataType(name, contentType) == "folder",
|
"objects__row--directory": getDataType(name, contentType) == "folder"
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -75,14 +75,14 @@ export const ObjectItem = ({
|
|||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
checked: getCheckedList(state).indexOf(ownProps.name) >= 0,
|
checked: getCheckedList(state).indexOf(ownProps.name) >= 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
checkObject: name => dispatch(actions.checkObject(name)),
|
checkObject: name => dispatch(actions.checkObject(name)),
|
||||||
uncheckObject: name => dispatch(actions.uncheckObject(name)),
|
uncheckObject: name => dispatch(actions.uncheckObject(name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export const ObjectsHeader = ({
|
|||||||
sortNameOrder,
|
sortNameOrder,
|
||||||
sortSizeOrder,
|
sortSizeOrder,
|
||||||
sortLastModifiedOrder,
|
sortLastModifiedOrder,
|
||||||
sortObjects,
|
sortObjects
|
||||||
}) => (
|
}) => (
|
||||||
<div className="objects__row objects__header hidden-xs">
|
<div className="objects__row objects__header hidden-xs">
|
||||||
<div
|
<div
|
||||||
@ -38,7 +38,7 @@ export const ObjectsHeader = ({
|
|||||||
objects__sort: true,
|
objects__sort: true,
|
||||||
zmdi: true,
|
zmdi: true,
|
||||||
"zmdi-sort-desc": sortNameOrder,
|
"zmdi-sort-desc": sortNameOrder,
|
||||||
"zmdi-sort-asc": !sortNameOrder,
|
"zmdi-sort-asc": !sortNameOrder
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -54,7 +54,7 @@ export const ObjectsHeader = ({
|
|||||||
objects__sort: true,
|
objects__sort: true,
|
||||||
zmdi: true,
|
zmdi: true,
|
||||||
"zmdi-sort-amount-desc": sortSizeOrder,
|
"zmdi-sort-amount-desc": sortSizeOrder,
|
||||||
"zmdi-sort-amount-asc": !sortSizeOrder,
|
"zmdi-sort-amount-asc": !sortSizeOrder
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -70,7 +70,7 @@ export const ObjectsHeader = ({
|
|||||||
objects__sort: true,
|
objects__sort: true,
|
||||||
zmdi: true,
|
zmdi: true,
|
||||||
"zmdi-sort-amount-desc": sortLastModifiedOrder,
|
"zmdi-sort-amount-desc": sortLastModifiedOrder,
|
||||||
"zmdi-sort-amount-asc": !sortLastModifiedOrder,
|
"zmdi-sort-amount-asc": !sortLastModifiedOrder
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -82,13 +82,13 @@ const mapStateToProps = state => {
|
|||||||
sortNameOrder: state.objects.sortBy == "name" && state.objects.sortOrder,
|
sortNameOrder: state.objects.sortBy == "name" && state.objects.sortOrder,
|
||||||
sortSizeOrder: state.objects.sortBy == "size" && state.objects.sortOrder,
|
sortSizeOrder: state.objects.sortBy == "size" && state.objects.sortOrder,
|
||||||
sortLastModifiedOrder:
|
sortLastModifiedOrder:
|
||||||
state.objects.sortBy == "last-modified" && state.objects.sortOrder,
|
state.objects.sortBy == "last-modified" && state.objects.sortOrder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
sortObjects: sortBy => dispatch(actionsObjects.sortObjects(sortBy)),
|
sortObjects: sortBy => dispatch(actionsObjects.sortObjects(sortBy))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,16 +54,16 @@ const mapStateToProps = state => {
|
|||||||
currentBucket: state.buckets.currentBucket,
|
currentBucket: state.buckets.currentBucket,
|
||||||
currentPrefix: state.objects.currentPrefix,
|
currentPrefix: state.objects.currentPrefix,
|
||||||
objects: state.objects.list,
|
objects: state.objects.list,
|
||||||
isTruncated: state.objects.isTruncated,
|
isTruncated: state.objects.isTruncated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
loadObjects: append => dispatch(actionsObjects.fetchObjects(append)),
|
loadObjects: append => dispatch(actionsObjects.fetchObjects(append))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(
|
export default connect(mapStateToProps, mapDispatchToProps)(
|
||||||
ObjectsListContainer,
|
ObjectsListContainer
|
||||||
)
|
)
|
||||||
|
@ -53,13 +53,13 @@ export const Path = ({ currentBucket, currentPrefix, selectPrefix }) => {
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
currentBucket: getCurrentBucket(state),
|
currentBucket: getCurrentBucket(state),
|
||||||
currentPrefix: state.objects.currentPrefix,
|
currentPrefix: state.objects.currentPrefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix)),
|
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export const PrefixContainer = ({ object, currentPrefix, selectPrefix }) => {
|
|||||||
const props = {
|
const props = {
|
||||||
name: object.name,
|
name: object.name,
|
||||||
contentType: object.contentType,
|
contentType: object.contentType,
|
||||||
onClick: () => selectPrefix(`${currentPrefix}${object.name}`),
|
onClick: () => selectPrefix(`${currentPrefix}${object.name}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return <ObjectItem {...props} />
|
return <ObjectItem {...props} />
|
||||||
@ -32,13 +32,13 @@ export const PrefixContainer = ({ object, currentPrefix, selectPrefix }) => {
|
|||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
object: ownProps.object,
|
object: ownProps.object,
|
||||||
currentPrefix: state.objects.currentPrefix,
|
currentPrefix: state.objects.currentPrefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix)),
|
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import * as alertActions from "../alert/actions"
|
|||||||
import {
|
import {
|
||||||
SHARE_OBJECT_EXPIRY_DAYS,
|
SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
SHARE_OBJECT_EXPIRY_HOURS,
|
SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
} from "../constants"
|
} from "../constants"
|
||||||
|
|
||||||
export class ShareObjectModal extends React.Component {
|
export class ShareObjectModal extends React.Component {
|
||||||
@ -34,22 +34,22 @@ export class ShareObjectModal extends React.Component {
|
|||||||
expiry: {
|
expiry: {
|
||||||
days: SHARE_OBJECT_EXPIRY_DAYS,
|
days: SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES,
|
minutes: SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
this.expiryRange = {
|
this.expiryRange = {
|
||||||
days: {
|
days: {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 7,
|
max: 7
|
||||||
},
|
},
|
||||||
hours: {
|
hours: {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 23,
|
max: 23
|
||||||
},
|
},
|
||||||
minutes: {
|
minutes: {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 59,
|
max: 59
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ export class ShareObjectModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
expiry,
|
expiry
|
||||||
})
|
})
|
||||||
|
|
||||||
const { shareObjectDetails: { object }, shareObject } = this.props
|
const { shareObjectDetails: { object }, shareObject } = this.props
|
||||||
@ -207,7 +207,7 @@ export class ShareObjectModal extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
shareObjectDetails: state.objects.shareObject,
|
shareObjectDetails: state.objects.shareObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,9 +220,9 @@ const mapDispatchToProps = dispatch => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: message,
|
message: message
|
||||||
}),
|
})
|
||||||
),
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ import * as objectsActions from "./actions"
|
|||||||
import {
|
import {
|
||||||
SHARE_OBJECT_EXPIRY_DAYS,
|
SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
SHARE_OBJECT_EXPIRY_HOURS,
|
SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
} from "../constants"
|
} from "../constants"
|
||||||
|
|
||||||
export class ObjectsBulkActions extends React.Component {
|
export class Toolbar extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
showDeleteConfirmation: false,
|
showDeleteConfirmation: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteChecked() {
|
deleteChecked() {
|
||||||
@ -45,7 +45,7 @@ export class ObjectsBulkActions extends React.Component {
|
|||||||
}
|
}
|
||||||
hideDeleteConfirmModal() {
|
hideDeleteConfirmModal() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showDeleteConfirmation: false,
|
showDeleteConfirmation: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
shareObject(e) {
|
shareObject(e) {
|
||||||
@ -59,7 +59,7 @@ export class ObjectsBulkActions extends React.Component {
|
|||||||
object,
|
object,
|
||||||
SHARE_OBJECT_EXPIRY_DAYS,
|
SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
SHARE_OBJECT_EXPIRY_HOURS,
|
SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ export class ObjectsBulkActions extends React.Component {
|
|||||||
checkedObjectsCount,
|
checkedObjectsCount,
|
||||||
downloadChecked,
|
downloadChecked,
|
||||||
object,
|
object,
|
||||||
showShareObjectModal,
|
showShareObjectModal
|
||||||
} = this.props
|
} = this.props
|
||||||
const loggedIn = web.LoggedIn()
|
const loggedIn = web.LoggedIn()
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ export class ObjectsBulkActions extends React.Component {
|
|||||||
className="toolbar__item zmdi zmdi-delete"
|
className="toolbar__item zmdi zmdi-delete"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
this.setState({
|
this.setState({
|
||||||
showDeleteConfirmation: true,
|
showDeleteConfirmation: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
disabled={!checkedObjectsCount}
|
disabled={!checkedObjectsCount}
|
||||||
@ -126,7 +126,7 @@ const mapStateToProps = state => {
|
|||||||
return {
|
return {
|
||||||
checkedObjects: getCheckedList(state),
|
checkedObjects: getCheckedList(state),
|
||||||
checkedObjectsCount: getCheckedList(state).length,
|
checkedObjectsCount: getCheckedList(state).length,
|
||||||
showShareObjectModal: state.objects.shareObject.show,
|
showShareObjectModal: state.objects.shareObject.show
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,8 +137,8 @@ const mapDispatchToProps = dispatch => {
|
|||||||
deleteChecked: () => dispatch(actions.deleteCheckedObjects()),
|
deleteChecked: () => dispatch(actions.deleteCheckedObjects()),
|
||||||
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
||||||
shareObject: (object, days, hours, minutes) =>
|
shareObject: (object, days, hours, minutes) =>
|
||||||
dispatch(objectsActions.shareObject(object, days, hours, minutes)),
|
dispatch(objectsActions.shareObject(object, days, hours, minutes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(ObjectsBulkActions)
|
export default connect(mapStateToProps, mapDispatchToProps)(Toolbar)
|
@ -26,7 +26,7 @@ describe("DeleteObjectConfirmModal", () => {
|
|||||||
it("should call deleteObject when Delete is clicked", () => {
|
it("should call deleteObject when Delete is clicked", () => {
|
||||||
const deleteObject = jest.fn()
|
const deleteObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<DeleteObjectConfirmModal deleteObject={deleteObject} />,
|
<DeleteObjectConfirmModal deleteObject={deleteObject} />
|
||||||
)
|
)
|
||||||
wrapper.find("ConfirmModal").prop("okHandler")()
|
wrapper.find("ConfirmModal").prop("okHandler")()
|
||||||
expect(deleteObject).toHaveBeenCalled()
|
expect(deleteObject).toHaveBeenCalled()
|
||||||
@ -37,7 +37,7 @@ describe("DeleteObjectConfirmModal", () => {
|
|||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<DeleteObjectConfirmModal
|
<DeleteObjectConfirmModal
|
||||||
hideDeleteConfirmModal={hideDeleteConfirmModal}
|
hideDeleteConfirmModal={hideDeleteConfirmModal}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("ConfirmModal").prop("cancelHandler")()
|
wrapper.find("ConfirmModal").prop("cancelHandler")()
|
||||||
expect(hideDeleteConfirmModal).toHaveBeenCalled()
|
expect(hideDeleteConfirmModal).toHaveBeenCalled()
|
||||||
|
@ -28,28 +28,4 @@ describe("ObjectContainer", () => {
|
|||||||
expect(wrapper.find("Connect(ObjectItem)").length).toBe(1)
|
expect(wrapper.find("Connect(ObjectItem)").length).toBe(1)
|
||||||
expect(wrapper.find("Connect(ObjectItem)").prop("name")).toBe("test1.jpg")
|
expect(wrapper.find("Connect(ObjectItem)").prop("name")).toBe("test1.jpg")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should pass actions to ObjectItem", () => {
|
|
||||||
const wrapper = shallow(
|
|
||||||
<ObjectContainer
|
|
||||||
object={{ name: "test1.jpg" }}
|
|
||||||
checkedObjectsCount={0}
|
|
||||||
/>,
|
|
||||||
)
|
|
||||||
expect(wrapper.find("Connect(ObjectItem)").prop("actionButtons")).not.toBe(
|
|
||||||
undefined,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should pass empty actions to ObjectItem when checkedObjectCount is more than 0", () => {
|
|
||||||
const wrapper = shallow(
|
|
||||||
<ObjectContainer
|
|
||||||
object={{ name: "test1.jpg" }}
|
|
||||||
checkedObjectsCount={1}
|
|
||||||
/>,
|
|
||||||
)
|
|
||||||
expect(wrapper.find("Connect(ObjectItem)").prop("actionButtons")).toBe(
|
|
||||||
undefined,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -25,14 +25,16 @@ describe("ObjectItem", () => {
|
|||||||
|
|
||||||
it("should render with content type", () => {
|
it("should render with content type", () => {
|
||||||
const wrapper = shallow(<ObjectItem name={"test.jpg"} contentType={""} />)
|
const wrapper = shallow(<ObjectItem name={"test.jpg"} contentType={""} />)
|
||||||
expect(wrapper.prop("data-type")).toBe("image")
|
expect(
|
||||||
|
wrapper.find(".objects__column--select").prop("data-object-type")
|
||||||
|
).toBe("image")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call onClick when the object isclicked", () => {
|
it("should call onClick when the object isclicked", () => {
|
||||||
const onClick = jest.fn()
|
const onClick = jest.fn()
|
||||||
const wrapper = shallow(<ObjectItem name={"test"} onClick={onClick} />)
|
const wrapper = shallow(<ObjectItem name={"test"} onClick={onClick} />)
|
||||||
wrapper.find("a").simulate("click", {
|
wrapper.find("a").simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(onClick).toHaveBeenCalled()
|
expect(onClick).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -40,7 +42,7 @@ describe("ObjectItem", () => {
|
|||||||
it("should call checkObject when the object/prefix is checked", () => {
|
it("should call checkObject when the object/prefix is checked", () => {
|
||||||
const checkObject = jest.fn()
|
const checkObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectItem name={"test"} checked={false} checkObject={checkObject} />,
|
<ObjectItem name={"test"} checked={false} checkObject={checkObject} />
|
||||||
)
|
)
|
||||||
wrapper.find("input[type='checkbox']").simulate("change")
|
wrapper.find("input[type='checkbox']").simulate("change")
|
||||||
expect(checkObject).toHaveBeenCalledWith("test")
|
expect(checkObject).toHaveBeenCalledWith("test")
|
||||||
@ -54,7 +56,7 @@ describe("ObjectItem", () => {
|
|||||||
it("should call uncheckObject when the object/prefix is unchecked", () => {
|
it("should call uncheckObject when the object/prefix is unchecked", () => {
|
||||||
const uncheckObject = jest.fn()
|
const uncheckObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectItem name={"test"} checked={true} uncheckObject={uncheckObject} />,
|
<ObjectItem name={"test"} checked={true} uncheckObject={uncheckObject} />
|
||||||
)
|
)
|
||||||
wrapper.find("input[type='checkbox']").simulate("change")
|
wrapper.find("input[type='checkbox']").simulate("change")
|
||||||
expect(uncheckObject).toHaveBeenCalledWith("test")
|
expect(uncheckObject).toHaveBeenCalledWith("test")
|
||||||
|
@ -28,43 +28,43 @@ describe("ObjectsHeader", () => {
|
|||||||
const sortObjects = jest.fn()
|
const sortObjects = jest.fn()
|
||||||
const wrapper = shallow(<ObjectsHeader sortObjects={sortObjects} />)
|
const wrapper = shallow(<ObjectsHeader sortObjects={sortObjects} />)
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-asc"),
|
wrapper.find("#sort-by-name i").hasClass("zmdi-sort-asc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-asc"),
|
wrapper.find("#sort-by-size i").hasClass("zmdi-sort-amount-asc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-asc"),
|
wrapper.find("#sort-by-last-modified i").hasClass("zmdi-sort-amount-asc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render name column with desc class when objects are sorted by name", () => {
|
it("should render name column with desc class when objects are sorted by name", () => {
|
||||||
const sortObjects = jest.fn()
|
const sortObjects = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsHeader sortObjects={sortObjects} sortNameOrder={true} />,
|
<ObjectsHeader sortObjects={sortObjects} sortNameOrder={true} />
|
||||||
)
|
)
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-desc"),
|
wrapper.find("#sort-by-name i").hasClass("zmdi-sort-desc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render size column with desc class when objects are sorted by size", () => {
|
it("should render size column with desc class when objects are sorted by size", () => {
|
||||||
const sortObjects = jest.fn()
|
const sortObjects = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsHeader sortObjects={sortObjects} sortSizeOrder={true} />,
|
<ObjectsHeader sortObjects={sortObjects} sortSizeOrder={true} />
|
||||||
)
|
)
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-desc"),
|
wrapper.find("#sort-by-size i").hasClass("zmdi-sort-amount-desc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render last modified column with desc class when objects are sorted by last modified", () => {
|
it("should render last modified column with desc class when objects are sorted by last modified", () => {
|
||||||
const sortObjects = jest.fn()
|
const sortObjects = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsHeader sortObjects={sortObjects} sortLastModifiedOrder={true} />,
|
<ObjectsHeader sortObjects={sortObjects} sortLastModifiedOrder={true} />
|
||||||
)
|
)
|
||||||
expect(
|
expect(
|
||||||
wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-desc"),
|
wrapper.find("#sort-by-last-modified i").hasClass("zmdi-sort-amount-desc")
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ describe("ObjectsList", () => {
|
|||||||
|
|
||||||
it("should render ObjectContainer for every object", () => {
|
it("should render ObjectContainer for every object", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsList objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]} />,
|
<ObjectsList objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]} />
|
||||||
)
|
)
|
||||||
expect(wrapper.find("Connect(ObjectContainer)").length).toBe(2)
|
expect(wrapper.find("Connect(ObjectContainer)").length).toBe(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render PrefixContainer for every prefix", () => {
|
it("should render PrefixContainer for every prefix", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsList objects={[{ name: "abc/" }, { name: "xyz/" }]} />,
|
<ObjectsList objects={[{ name: "abc/" }, { name: "xyz/" }]} />
|
||||||
)
|
)
|
||||||
expect(wrapper.find("Connect(PrefixContainer)").length).toBe(2)
|
expect(wrapper.find("Connect(PrefixContainer)").length).toBe(2)
|
||||||
})
|
})
|
||||||
|
@ -28,26 +28,26 @@ describe("ObjectsList", () => {
|
|||||||
<ObjectsListContainer
|
<ObjectsListContainer
|
||||||
objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]}
|
objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]}
|
||||||
loadObjects={jest.fn()}
|
loadObjects={jest.fn()}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(wrapper.find("ObjectsList").length).toBe(1)
|
expect(wrapper.find("ObjectsList").length).toBe(1)
|
||||||
expect(wrapper.find("ObjectsList").prop("objects")).toEqual([
|
expect(wrapper.find("ObjectsList").prop("objects")).toEqual([
|
||||||
{
|
{
|
||||||
name: "test1.jpg",
|
name: "test1.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2.jpg",
|
name: "test2.jpg"
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should show the loading indicator at the bottom if there are more elements to display", () => {
|
it("should show the loading indicator at the bottom if there are more elements to display", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsListContainer currentBucket="test1" isTruncated={true} />,
|
<ObjectsListContainer currentBucket="test1" isTruncated={true} />
|
||||||
)
|
)
|
||||||
expect(wrapper.find(".text-center").prop("style")).toHaveProperty(
|
expect(wrapper.find(".text-center").prop("style")).toHaveProperty(
|
||||||
"display",
|
"display",
|
||||||
"block",
|
"block"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -25,32 +25,32 @@ describe("Path", () => {
|
|||||||
|
|
||||||
it("should render only bucket if there is no prefix", () => {
|
it("should render only bucket if there is no prefix", () => {
|
||||||
const wrapper = shallow(<Path currentBucket={"test1"} currentPrefix={""} />)
|
const wrapper = shallow(<Path currentBucket={"test1"} currentPrefix={""} />)
|
||||||
expect(wrapper.find("span").length).toBe(1)
|
expect(wrapper.find("a").length).toBe(1)
|
||||||
expect(wrapper.text()).toBe("test1")
|
expect(wrapper.text()).toBe("test1")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should render bucket and prefix", () => {
|
it("should render bucket and prefix", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Path currentBucket={"test1"} currentPrefix={"a/b/"} />,
|
<Path currentBucket={"test1"} currentPrefix={"a/b/"} />
|
||||||
)
|
)
|
||||||
expect(wrapper.find("span").length).toBe(3)
|
expect(wrapper.find("a").length).toBe(3)
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find("span")
|
.find("a")
|
||||||
.at(0)
|
.at(0)
|
||||||
.text(),
|
.text()
|
||||||
).toBe("test1")
|
).toBe("test1")
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find("span")
|
.find("a")
|
||||||
.at(1)
|
.at(1)
|
||||||
.text(),
|
.text()
|
||||||
).toBe("a")
|
).toBe("a")
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find("span")
|
.find("a")
|
||||||
.at(2)
|
.at(2)
|
||||||
.text(),
|
.text()
|
||||||
).toBe("b")
|
).toBe("b")
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ describe("Path", () => {
|
|||||||
currentBucket={"test1"}
|
currentBucket={"test1"}
|
||||||
currentPrefix={"a/b/"}
|
currentPrefix={"a/b/"}
|
||||||
selectPrefix={selectPrefix}
|
selectPrefix={selectPrefix}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper
|
wrapper
|
||||||
.find("a")
|
.find("a")
|
||||||
.at(2)
|
.at(2)
|
||||||
.simulate("click", {
|
.simulate("click", {
|
||||||
preventDefault: jest.fn(),
|
preventDefault: jest.fn()
|
||||||
})
|
})
|
||||||
expect(selectPrefix).toHaveBeenCalledWith("a/b/")
|
expect(selectPrefix).toHaveBeenCalledWith("a/b/")
|
||||||
})
|
})
|
||||||
|
@ -36,7 +36,7 @@ describe("PrefixContainer", () => {
|
|||||||
object={{ name: "abc/" }}
|
object={{ name: "abc/" }}
|
||||||
currentPrefix={"xyz/"}
|
currentPrefix={"xyz/"}
|
||||||
selectPrefix={selectPrefix}
|
selectPrefix={selectPrefix}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("Connect(ObjectItem)").prop("onClick")()
|
wrapper.find("Connect(ObjectItem)").prop("onClick")()
|
||||||
expect(selectPrefix).toHaveBeenCalledWith("xyz/abc/")
|
expect(selectPrefix).toHaveBeenCalledWith("xyz/abc/")
|
||||||
|
@ -20,13 +20,13 @@ import { ShareObjectModal } from "../ShareObjectModal"
|
|||||||
import {
|
import {
|
||||||
SHARE_OBJECT_EXPIRY_DAYS,
|
SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
SHARE_OBJECT_EXPIRY_HOURS,
|
SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
} from "../../constants"
|
} from "../../constants"
|
||||||
|
|
||||||
jest.mock("../../web", () => ({
|
jest.mock("../../web", () => ({
|
||||||
LoggedIn: jest.fn(() => {
|
LoggedIn: jest.fn(() => {
|
||||||
return true
|
return true
|
||||||
}),
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe("ShareObjectModal", () => {
|
describe("ShareObjectModal", () => {
|
||||||
@ -35,7 +35,7 @@ describe("ShareObjectModal", () => {
|
|||||||
<ShareObjectModal
|
<ShareObjectModal
|
||||||
object={{ name: "obj1" }}
|
object={{ name: "obj1" }}
|
||||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ describe("ShareObjectModal", () => {
|
|||||||
object={{ name: "obj1" }}
|
object={{ name: "obj1" }}
|
||||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||||
hideShareObject={hideShareObject}
|
hideShareObject={hideShareObject}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper
|
wrapper
|
||||||
.find("button")
|
.find("button")
|
||||||
@ -60,13 +60,13 @@ describe("ShareObjectModal", () => {
|
|||||||
<ShareObjectModal
|
<ShareObjectModal
|
||||||
object={{ name: "obj1" }}
|
object={{ name: "obj1" }}
|
||||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find("input")
|
.find("input")
|
||||||
.first()
|
.first()
|
||||||
.prop("value"),
|
.prop("value")
|
||||||
).toBe(`${window.location.protocol}//test`)
|
).toBe(`${window.location.protocol}//test`)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ describe("ShareObjectModal", () => {
|
|||||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||||
hideShareObject={hideShareObject}
|
hideShareObject={hideShareObject}
|
||||||
showCopyAlert={showCopyAlert}
|
showCopyAlert={showCopyAlert}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("CopyToClipboard").prop("onCopy")()
|
wrapper.find("CopyToClipboard").prop("onCopy")()
|
||||||
expect(showCopyAlert).toHaveBeenCalledWith("Link copied to clipboard!")
|
expect(showCopyAlert).toHaveBeenCalledWith("Link copied to clipboard!")
|
||||||
@ -89,40 +89,40 @@ describe("ShareObjectModal", () => {
|
|||||||
describe("Update expiry values", () => {
|
describe("Update expiry values", () => {
|
||||||
const props = {
|
const props = {
|
||||||
object: {
|
object: {
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
shareObjectDetails: {
|
shareObjectDetails: {
|
||||||
show: true,
|
show: true,
|
||||||
object: "obj1",
|
object: "obj1",
|
||||||
url: "test",
|
url: "test"
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
it("should have default expiry values", () => {
|
it("should have default expiry values", () => {
|
||||||
const wrapper = shallow(<ShareObjectModal {...props} />)
|
const wrapper = shallow(<ShareObjectModal {...props} />)
|
||||||
expect(wrapper.state("expiry")).toEqual({
|
expect(wrapper.state("expiry")).toEqual({
|
||||||
days: SHARE_OBJECT_EXPIRY_DAYS,
|
days: SHARE_OBJECT_EXPIRY_DAYS,
|
||||||
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
||||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES,
|
minutes: SHARE_OBJECT_EXPIRY_MINUTES
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not allow any increments when days is already max", () => {
|
it("should not allow any increments when days is already max", () => {
|
||||||
const shareObject = jest.fn()
|
const shareObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||||
)
|
)
|
||||||
wrapper.setState({
|
wrapper.setState({
|
||||||
expiry: {
|
expiry: {
|
||||||
days: 7,
|
days: 7,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#increase-hours").simulate("click")
|
wrapper.find("#increase-hours").simulate("click")
|
||||||
expect(wrapper.state("expiry")).toEqual({
|
expect(wrapper.state("expiry")).toEqual({
|
||||||
days: 7,
|
days: 7,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
})
|
})
|
||||||
expect(shareObject).not.toHaveBeenCalled()
|
expect(shareObject).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -130,14 +130,14 @@ describe("ShareObjectModal", () => {
|
|||||||
it("should not allow expiry values less than minimum value", () => {
|
it("should not allow expiry values less than minimum value", () => {
|
||||||
const shareObject = jest.fn()
|
const shareObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||||
)
|
)
|
||||||
wrapper.setState({
|
wrapper.setState({
|
||||||
expiry: {
|
expiry: {
|
||||||
days: 5,
|
days: 5,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#decrease-hours").simulate("click")
|
wrapper.find("#decrease-hours").simulate("click")
|
||||||
expect(wrapper.state("expiry").hours).toBe(0)
|
expect(wrapper.state("expiry").hours).toBe(0)
|
||||||
@ -149,14 +149,14 @@ describe("ShareObjectModal", () => {
|
|||||||
it("should not allow expiry values more than maximum value", () => {
|
it("should not allow expiry values more than maximum value", () => {
|
||||||
const shareObject = jest.fn()
|
const shareObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||||
)
|
)
|
||||||
wrapper.setState({
|
wrapper.setState({
|
||||||
expiry: {
|
expiry: {
|
||||||
days: 1,
|
days: 1,
|
||||||
hours: 23,
|
hours: 23,
|
||||||
minutes: 59,
|
minutes: 59
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#increase-hours").simulate("click")
|
wrapper.find("#increase-hours").simulate("click")
|
||||||
expect(wrapper.state("expiry").hours).toBe(23)
|
expect(wrapper.state("expiry").hours).toBe(23)
|
||||||
@ -168,20 +168,20 @@ describe("ShareObjectModal", () => {
|
|||||||
it("should set hours and minutes to 0 when days reaches max", () => {
|
it("should set hours and minutes to 0 when days reaches max", () => {
|
||||||
const shareObject = jest.fn()
|
const shareObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||||
)
|
)
|
||||||
wrapper.setState({
|
wrapper.setState({
|
||||||
expiry: {
|
expiry: {
|
||||||
days: 6,
|
days: 6,
|
||||||
hours: 5,
|
hours: 5,
|
||||||
minutes: 30,
|
minutes: 30
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#increase-days").simulate("click")
|
wrapper.find("#increase-days").simulate("click")
|
||||||
expect(wrapper.state("expiry")).toEqual({
|
expect(wrapper.state("expiry")).toEqual({
|
||||||
days: 7,
|
days: 7,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
})
|
})
|
||||||
expect(shareObject).toHaveBeenCalled()
|
expect(shareObject).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -189,20 +189,20 @@ describe("ShareObjectModal", () => {
|
|||||||
it("should set days to MAX when all of them becomes 0", () => {
|
it("should set days to MAX when all of them becomes 0", () => {
|
||||||
const shareObject = jest.fn()
|
const shareObject = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||||
)
|
)
|
||||||
wrapper.setState({
|
wrapper.setState({
|
||||||
expiry: {
|
expiry: {
|
||||||
days: 0,
|
days: 0,
|
||||||
hours: 1,
|
hours: 1,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
wrapper.find("#decrease-hours").simulate("click")
|
wrapper.find("#decrease-hours").simulate("click")
|
||||||
expect(wrapper.state("expiry")).toEqual({
|
expect(wrapper.state("expiry")).toEqual({
|
||||||
days: 7,
|
days: 7,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0
|
||||||
})
|
})
|
||||||
expect(shareObject).toHaveBeenCalledWith("obj1", 7, 0, 0)
|
expect(shareObject).toHaveBeenCalledWith("obj1", 7, 0, 0)
|
||||||
})
|
})
|
||||||
|
@ -16,45 +16,38 @@
|
|||||||
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { shallow } from "enzyme"
|
import { shallow } from "enzyme"
|
||||||
import { ObjectsBulkActions } from "../ObjectsBulkActions"
|
import { Toolbar } from "../Toolbar"
|
||||||
|
|
||||||
describe("ObjectsBulkActions", () => {
|
jest.mock("../../web", () => ({
|
||||||
|
LoggedIn: jest
|
||||||
|
.fn(() => true)
|
||||||
|
.mockReturnValueOnce(true)
|
||||||
|
.mockReturnValueOnce(false)
|
||||||
|
}))
|
||||||
|
|
||||||
|
describe("Toolbar", () => {
|
||||||
it("should render without crashing", () => {
|
it("should render without crashing", () => {
|
||||||
shallow(<ObjectsBulkActions checkedObjectsCount={0} />)
|
shallow(<Toolbar checkedObjectsCount={0} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should show actions when checkObjectsCount is more than 0", () => {
|
it("should render Login button when the user has not LoggedIn", () => {
|
||||||
const wrapper = shallow(<ObjectsBulkActions checkedObjectsCount={1} />)
|
const wrapper = shallow(<Toolbar checkedObjectsCount={0} />)
|
||||||
expect(wrapper.hasClass("list-actions-toggled")).toBeTruthy()
|
expect(wrapper.find("a").text()).toBe("Login")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call downloadChecked when download button is clicked", () => {
|
it("should render StorageInfo and BrowserDropdown when the user has LoggedIn", () => {
|
||||||
const downloadChecked = jest.fn()
|
const wrapper = shallow(<Toolbar checkedObjectsCount={0} />)
|
||||||
const wrapper = shallow(
|
expect(wrapper.find("Connect(BrowserDropdown)").length).toBe(1)
|
||||||
<ObjectsBulkActions
|
|
||||||
checkedObjectsCount={1}
|
|
||||||
downloadChecked={downloadChecked}
|
|
||||||
/>,
|
|
||||||
)
|
|
||||||
wrapper.find("#download-checked").simulate("click")
|
|
||||||
expect(downloadChecked).toHaveBeenCalled()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call clearChecked when close button is clicked", () => {
|
it("should enable delete action when checkObjectsCount is more than 0", () => {
|
||||||
const clearChecked = jest.fn()
|
const wrapper = shallow(<Toolbar checkedObjectsCount={1} />)
|
||||||
const wrapper = shallow(
|
expect(wrapper.find(".zmdi-delete").prop("disabled")).toBeFalsy()
|
||||||
<ObjectsBulkActions
|
|
||||||
checkedObjectsCount={1}
|
|
||||||
clearChecked={clearChecked}
|
|
||||||
/>,
|
|
||||||
)
|
|
||||||
wrapper.find("#close-bulk-actions").simulate("click")
|
|
||||||
expect(clearChecked).toHaveBeenCalled()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("shoud show DeleteObjectConfirmModal when delete-checked button is clicked", () => {
|
it("shoud show DeleteObjectConfirmModal when delete button is clicked", () => {
|
||||||
const wrapper = shallow(<ObjectsBulkActions checkedObjectsCount={1} />)
|
const wrapper = shallow(<Toolbar checkedObjectsCount={1} />)
|
||||||
wrapper.find("#delete-checked").simulate("click")
|
wrapper.find("button.zmdi-delete").simulate("click")
|
||||||
wrapper.update()
|
wrapper.update()
|
||||||
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(1)
|
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(1)
|
||||||
})
|
})
|
||||||
@ -62,16 +55,22 @@ describe("ObjectsBulkActions", () => {
|
|||||||
it("shoud call deleteChecked when Delete is clicked on confirmation modal", () => {
|
it("shoud call deleteChecked when Delete is clicked on confirmation modal", () => {
|
||||||
const deleteChecked = jest.fn()
|
const deleteChecked = jest.fn()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ObjectsBulkActions
|
<Toolbar checkedObjectsCount={1} deleteChecked={deleteChecked} />
|
||||||
checkedObjectsCount={1}
|
|
||||||
deleteChecked={deleteChecked}
|
|
||||||
/>,
|
|
||||||
)
|
)
|
||||||
wrapper.find("#delete-checked").simulate("click")
|
wrapper.find("button.zmdi-delete").simulate("click")
|
||||||
wrapper.update()
|
wrapper.update()
|
||||||
wrapper.find("DeleteObjectConfirmModal").prop("deleteObject")()
|
wrapper.find("DeleteObjectConfirmModal").prop("deleteObject")()
|
||||||
expect(deleteChecked).toHaveBeenCalled()
|
expect(deleteChecked).toHaveBeenCalled()
|
||||||
wrapper.update()
|
wrapper.update()
|
||||||
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(0)
|
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should call downloadChecked when download button is clicked", () => {
|
||||||
|
const downloadChecked = jest.fn()
|
||||||
|
const wrapper = shallow(
|
||||||
|
<Toolbar checkedObjectsCount={1} downloadChecked={downloadChecked} />
|
||||||
|
)
|
||||||
|
wrapper.find("button.zmdi-download").simulate("click")
|
||||||
|
expect(downloadChecked).toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
@ -26,21 +26,21 @@ jest.mock("../../web", () => ({
|
|||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
istruncated: false,
|
istruncated: false,
|
||||||
nextmarker: "test2",
|
nextmarker: "test2",
|
||||||
writable: false,
|
writable: false
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
RemoveObject: jest.fn(({ bucketName, objects }) => {
|
RemoveObject: jest.fn(({ bucketName, objects }) => {
|
||||||
if (!bucketName) {
|
if (!bucketName) {
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
message: "Invalid bucket",
|
message: "Invalid bucket"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
@ -48,30 +48,30 @@ jest.mock("../../web", () => ({
|
|||||||
PresignedGet: jest.fn(({ bucket, object }) => {
|
PresignedGet: jest.fn(({ bucket, object }) => {
|
||||||
if (!bucket) {
|
if (!bucket) {
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
message: "Invalid bucket",
|
message: "Invalid bucket"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
url: "https://test.com/bk1/pre1/b.txt",
|
url: "https://test.com/bk1/pre1/b.txt"
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
CreateURLToken: jest
|
CreateURLToken: jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockImplementationOnce(() => {
|
.mockImplementationOnce(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
token: "test",
|
token: "test"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.mockImplementationOnce(() => {
|
.mockImplementationOnce(() => {
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
message: "Error in creating token",
|
message: "Error in creating token"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.mockImplementationOnce(() => {
|
.mockImplementationOnce(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
token: "test",
|
token: "test"
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}),
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const middlewares = [thunk]
|
const middlewares = [thunk]
|
||||||
@ -85,29 +85,29 @@ describe("Objects actions", () => {
|
|||||||
type: "objects/SET_LIST",
|
type: "objects/SET_LIST",
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
marker: "test2",
|
marker: "test2"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
actionsObjects.setList(
|
actionsObjects.setList(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
"test2",
|
"test2",
|
||||||
false,
|
false
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
expect(actions).toEqual(expectedActions)
|
expect(actions).toEqual(expectedActions)
|
||||||
@ -118,8 +118,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_BY",
|
type: "objects/SET_SORT_BY",
|
||||||
sortBy: "name",
|
sortBy: "name"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.setSortBy("name"))
|
store.dispatch(actionsObjects.setSortBy("name"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -131,8 +131,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_ORDER",
|
type: "objects/SET_SORT_ORDER",
|
||||||
sortOrder: true,
|
sortOrder: true
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.setSortOrder(true))
|
store.dispatch(actionsObjects.setSortOrder(true))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -142,38 +142,38 @@ describe("Objects actions", () => {
|
|||||||
it("creates objects/SET_LIST after fetching the objects", () => {
|
it("creates objects/SET_LIST after fetching the objects", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "",
|
currentPrefix: ""
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_LIST",
|
type: "objects/SET_LIST",
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
marker: "test2",
|
marker: "test2",
|
||||||
isTruncated: false,
|
isTruncated: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_BY",
|
type: "objects/SET_SORT_BY",
|
||||||
sortBy: "",
|
sortBy: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_ORDER",
|
type: "objects/SET_SORT_ORDER",
|
||||||
sortOrder: false,
|
sortOrder: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_PREFIX_WRITABLE",
|
type: "objects/SET_PREFIX_WRITABLE",
|
||||||
prefixWritable: false,
|
prefixWritable: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsObjects.fetchObjects()).then(() => {
|
return store.dispatch(actionsObjects.fetchObjects()).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -184,30 +184,30 @@ describe("Objects actions", () => {
|
|||||||
it("creates objects/APPEND_LIST after fetching more objects", () => {
|
it("creates objects/APPEND_LIST after fetching more objects", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "",
|
currentPrefix: ""
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/APPEND_LIST",
|
type: "objects/APPEND_LIST",
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
marker: "test2",
|
marker: "test2",
|
||||||
isTruncated: false,
|
isTruncated: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_PREFIX_WRITABLE",
|
type: "objects/SET_PREFIX_WRITABLE",
|
||||||
prefixWritable: false,
|
prefixWritable: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsObjects.fetchObjects(true)).then(() => {
|
return store.dispatch(actionsObjects.fetchObjects(true)).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -222,24 +222,24 @@ describe("Objects actions", () => {
|
|||||||
sortBy: "",
|
sortBy: "",
|
||||||
sortOrder: false,
|
sortOrder: false,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
marker: "",
|
marker: ""
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_BY",
|
type: "objects/SET_SORT_BY",
|
||||||
sortBy: "name",
|
sortBy: "name"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_SORT_ORDER",
|
type: "objects/SET_SORT_ORDER",
|
||||||
sortOrder: true,
|
sortOrder: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/SET_LIST",
|
type: "objects/SET_LIST",
|
||||||
objects: [],
|
objects: [],
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
marker: "",
|
marker: ""
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.sortObjects("name"))
|
store.dispatch(actionsObjects.sortObjects("name"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -249,20 +249,20 @@ describe("Objects actions", () => {
|
|||||||
it("should update browser url and creates objects/SET_CURRENT_PREFIX and objects/CHECKED_LIST_RESET actions when selectPrefix is called", () => {
|
it("should update browser url and creates objects/SET_CURRENT_PREFIX and objects/CHECKED_LIST_RESET actions when selectPrefix is called", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "test",
|
currentBucket: "test"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "",
|
currentPrefix: ""
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_CURRENT_PREFIX",
|
type: "objects/SET_CURRENT_PREFIX",
|
||||||
prefix: "abc/",
|
prefix: "abc/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "objects/CHECKED_LIST_RESET",
|
type: "objects/CHECKED_LIST_RESET"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.selectPrefix("abc/"))
|
store.dispatch(actionsObjects.selectPrefix("abc/"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -275,8 +275,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_PREFIX_WRITABLE",
|
type: "objects/SET_PREFIX_WRITABLE",
|
||||||
prefixWritable: true,
|
prefixWritable: true
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.setPrefixWritable(true))
|
store.dispatch(actionsObjects.setPrefixWritable(true))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -288,8 +288,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/REMOVE",
|
type: "objects/REMOVE",
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.removeObject("obj1"))
|
store.dispatch(actionsObjects.removeObject("obj1"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -299,17 +299,17 @@ describe("Objects actions", () => {
|
|||||||
it("creates objects/REMOVE action when object is deleted", () => {
|
it("creates objects/REMOVE action when object is deleted", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "test",
|
currentBucket: "test"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/REMOVE",
|
type: "objects/REMOVE",
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -320,11 +320,11 @@ describe("Objects actions", () => {
|
|||||||
it("creates alert/SET action when invalid bucket is provided", () => {
|
it("creates alert/SET action when invalid bucket is provided", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "",
|
currentBucket: ""
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
@ -332,9 +332,9 @@ describe("Objects actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Invalid bucket",
|
message: "Invalid bucket",
|
||||||
id: 0,
|
id: 0
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
return store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -349,8 +349,8 @@ describe("Objects actions", () => {
|
|||||||
type: "objects/SET_SHARE_OBJECT",
|
type: "objects/SET_SHARE_OBJECT",
|
||||||
show: true,
|
show: true,
|
||||||
object: "b.txt",
|
object: "b.txt",
|
||||||
url: "test",
|
url: "test"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.showShareObject("b.txt", "test"))
|
store.dispatch(actionsObjects.showShareObject("b.txt", "test"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -364,8 +364,8 @@ describe("Objects actions", () => {
|
|||||||
type: "objects/SET_SHARE_OBJECT",
|
type: "objects/SET_SHARE_OBJECT",
|
||||||
show: false,
|
show: false,
|
||||||
object: "",
|
object: "",
|
||||||
url: "",
|
url: ""
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.hideShareObject())
|
store.dispatch(actionsObjects.hideShareObject())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -375,27 +375,27 @@ describe("Objects actions", () => {
|
|||||||
it("creates objects/SET_SHARE_OBJECT when object is shared", () => {
|
it("creates objects/SET_SHARE_OBJECT when object is shared", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/SET_SHARE_OBJECT",
|
type: "objects/SET_SHARE_OBJECT",
|
||||||
show: true,
|
show: true,
|
||||||
object: "a.txt",
|
object: "a.txt",
|
||||||
url: "https://test.com/bk1/pre1/b.txt",
|
url: "https://test.com/bk1/pre1/b.txt"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "alert/SET",
|
type: "alert/SET",
|
||||||
alert: {
|
alert: {
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "Object shared. Expires in 1 days 0 hours 0 minutes",
|
message: "Object shared. Expires in 1 days 0 hours 0 minutes",
|
||||||
id: alertActions.alertId,
|
id: alertActions.alertId
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store
|
return store
|
||||||
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
||||||
@ -408,11 +408,11 @@ describe("Objects actions", () => {
|
|||||||
it("creates alert/SET when shareObject is failed", () => {
|
it("creates alert/SET when shareObject is failed", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "",
|
currentBucket: ""
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
@ -420,9 +420,9 @@ describe("Objects actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Invalid bucket",
|
message: "Invalid bucket",
|
||||||
id: alertActions.alertId,
|
id: alertActions.alertId
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store
|
return store
|
||||||
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
||||||
@ -438,15 +438,15 @@ describe("Objects actions", () => {
|
|||||||
Object.defineProperty(window, "location", {
|
Object.defineProperty(window, "location", {
|
||||||
set(url) {
|
set(url) {
|
||||||
setLocation(url)
|
setLocation(url)
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
store.dispatch(actionsObjects.downloadObject("obj1"))
|
store.dispatch(actionsObjects.downloadObject("obj1"))
|
||||||
const url = `${
|
const url = `${
|
||||||
@ -460,21 +460,21 @@ describe("Objects actions", () => {
|
|||||||
Object.defineProperty(window, "location", {
|
Object.defineProperty(window, "location", {
|
||||||
set(url) {
|
set(url) {
|
||||||
setLocation(url)
|
setLocation(url)
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
||||||
const url = `${
|
const url = `${
|
||||||
window.location.origin
|
window.location.origin
|
||||||
}${minioBrowserPrefix}/download/bk1/${encodeURI(
|
}${minioBrowserPrefix}/download/bk1/${encodeURI(
|
||||||
"pre1/obj1",
|
"pre1/obj1"
|
||||||
)}?token=test`
|
)}?token=test`
|
||||||
expect(setLocation).toHaveBeenCalledWith(url)
|
expect(setLocation).toHaveBeenCalledWith(url)
|
||||||
})
|
})
|
||||||
@ -483,11 +483,11 @@ describe("Objects actions", () => {
|
|||||||
it("create alert/SET action when CreateUrlToken fails", () => {
|
it("create alert/SET action when CreateUrlToken fails", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
@ -495,9 +495,9 @@ describe("Objects actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Error in creating token",
|
message: "Error in creating token",
|
||||||
id: alertActions.alertId,
|
id: alertActions.alertId
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -511,8 +511,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/CHECKED_LIST_ADD",
|
type: "objects/CHECKED_LIST_ADD",
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.checkObject("obj1"))
|
store.dispatch(actionsObjects.checkObject("obj1"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -524,8 +524,8 @@ describe("Objects actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/CHECKED_LIST_REMOVE",
|
type: "objects/CHECKED_LIST_REMOVE",
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.uncheckObject("obj1"))
|
store.dispatch(actionsObjects.uncheckObject("obj1"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -536,8 +536,8 @@ describe("Objects actions", () => {
|
|||||||
const store = mockStore()
|
const store = mockStore()
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "objects/CHECKED_LIST_RESET",
|
type: "objects/CHECKED_LIST_RESET"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(actionsObjects.resetCheckedList())
|
store.dispatch(actionsObjects.resetCheckedList())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -549,18 +549,18 @@ describe("Objects actions", () => {
|
|||||||
const send = jest.fn()
|
const send = jest.fn()
|
||||||
const xhrMockClass = () => ({
|
const xhrMockClass = () => ({
|
||||||
open: open,
|
open: open,
|
||||||
send: send,
|
send: send
|
||||||
})
|
})
|
||||||
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
|
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
|
||||||
|
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "bk1",
|
currentBucket: "bk1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/",
|
||||||
checkedList: ["obj1"],
|
checkedList: ["obj1"]
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
return store.dispatch(actionsObjects.downloadCheckedObjects()).then(() => {
|
return store.dispatch(actionsObjects.downloadCheckedObjects()).then(() => {
|
||||||
const requestUrl = `${
|
const requestUrl = `${
|
||||||
@ -571,8 +571,8 @@ describe("Objects actions", () => {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
bucketName: "bk1",
|
bucketName: "bk1",
|
||||||
prefix: "pre1/",
|
prefix: "pre1/",
|
||||||
objects: ["obj1"],
|
objects: ["obj1"]
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -31,9 +31,9 @@ describe("objects reducer", () => {
|
|||||||
shareObject: {
|
shareObject: {
|
||||||
show: false,
|
show: false,
|
||||||
object: "",
|
object: "",
|
||||||
url: "",
|
url: ""
|
||||||
},
|
},
|
||||||
checkedList: [],
|
checkedList: []
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -42,22 +42,22 @@ describe("objects reducer", () => {
|
|||||||
type: actions.SET_LIST,
|
type: actions.SET_LIST,
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
marker: "obj2",
|
marker: "obj2",
|
||||||
isTruncated: false,
|
isTruncated: false
|
||||||
})
|
})
|
||||||
expect(newState.list).toEqual([
|
expect(newState.list).toEqual([
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
expect(newState.marker).toBe("obj2")
|
expect(newState.marker).toBe("obj2")
|
||||||
expect(newState.isTruncated).toBeFalsy()
|
expect(newState.isTruncated).toBeFalsy()
|
||||||
@ -68,42 +68,42 @@ describe("objects reducer", () => {
|
|||||||
{
|
{
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
marker: "obj2",
|
marker: "obj2",
|
||||||
isTruncated: true,
|
isTruncated: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.APPEND_LIST,
|
type: actions.APPEND_LIST,
|
||||||
objects: [
|
objects: [
|
||||||
{
|
{
|
||||||
name: "obj3",
|
name: "obj3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj4",
|
name: "obj4"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
marker: "obj4",
|
marker: "obj4",
|
||||||
isTruncated: false,
|
isTruncated: false
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.list).toEqual([
|
expect(newState.list).toEqual([
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj3",
|
name: "obj3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj4",
|
name: "obj4"
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
expect(newState.marker).toBe("obj4")
|
expect(newState.marker).toBe("obj4")
|
||||||
expect(newState.isTruncated).toBeFalsy()
|
expect(newState.isTruncated).toBeFalsy()
|
||||||
@ -114,22 +114,22 @@ describe("objects reducer", () => {
|
|||||||
{
|
{
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.REMOVE,
|
type: actions.REMOVE,
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.list).toEqual([
|
expect(newState.list).toEqual([
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -138,32 +138,32 @@ describe("objects reducer", () => {
|
|||||||
{
|
{
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.REMOVE,
|
type: actions.REMOVE,
|
||||||
object: "obj3",
|
object: "obj3"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.list).toEqual([
|
expect(newState.list).toEqual([
|
||||||
{
|
{
|
||||||
name: "obj1",
|
name: "obj1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "obj2",
|
name: "obj2"
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle SET_SORT_BY", () => {
|
it("should handle SET_SORT_BY", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_SORT_BY,
|
type: actions.SET_SORT_BY,
|
||||||
sortBy: "name",
|
sortBy: "name"
|
||||||
})
|
})
|
||||||
expect(newState.sortBy).toEqual("name")
|
expect(newState.sortBy).toEqual("name")
|
||||||
})
|
})
|
||||||
@ -171,7 +171,7 @@ describe("objects reducer", () => {
|
|||||||
it("should handle SET_SORT_ORDER", () => {
|
it("should handle SET_SORT_ORDER", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_SORT_ORDER,
|
type: actions.SET_SORT_ORDER,
|
||||||
sortOrder: true,
|
sortOrder: true
|
||||||
})
|
})
|
||||||
expect(newState.sortOrder).toEqual(true)
|
expect(newState.sortOrder).toEqual(true)
|
||||||
})
|
})
|
||||||
@ -181,12 +181,12 @@ describe("objects reducer", () => {
|
|||||||
{
|
{
|
||||||
currentPrefix: "test1/",
|
currentPrefix: "test1/",
|
||||||
marker: "abc",
|
marker: "abc",
|
||||||
isTruncated: true,
|
isTruncated: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.SET_CURRENT_PREFIX,
|
type: actions.SET_CURRENT_PREFIX,
|
||||||
prefix: "test2/",
|
prefix: "test2/"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.currentPrefix).toEqual("test2/")
|
expect(newState.currentPrefix).toEqual("test2/")
|
||||||
expect(newState.marker).toEqual("")
|
expect(newState.marker).toEqual("")
|
||||||
@ -196,7 +196,7 @@ describe("objects reducer", () => {
|
|||||||
it("should handle SET_PREFIX_WRITABLE", () => {
|
it("should handle SET_PREFIX_WRITABLE", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.SET_PREFIX_WRITABLE,
|
type: actions.SET_PREFIX_WRITABLE,
|
||||||
prefixWritable: true,
|
prefixWritable: true
|
||||||
})
|
})
|
||||||
expect(newState.prefixWritable).toBeTruthy()
|
expect(newState.prefixWritable).toBeTruthy()
|
||||||
})
|
})
|
||||||
@ -206,19 +206,19 @@ describe("objects reducer", () => {
|
|||||||
type: actions.SET_SHARE_OBJECT,
|
type: actions.SET_SHARE_OBJECT,
|
||||||
show: true,
|
show: true,
|
||||||
object: "a.txt",
|
object: "a.txt",
|
||||||
url: "test",
|
url: "test"
|
||||||
})
|
})
|
||||||
expect(newState.shareObject).toEqual({
|
expect(newState.shareObject).toEqual({
|
||||||
show: true,
|
show: true,
|
||||||
object: "a.txt",
|
object: "a.txt",
|
||||||
url: "test",
|
url: "test"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle CHECKED_LIST_ADD", () => {
|
it("should handle CHECKED_LIST_ADD", () => {
|
||||||
const newState = reducer(undefined, {
|
const newState = reducer(undefined, {
|
||||||
type: actions.CHECKED_LIST_ADD,
|
type: actions.CHECKED_LIST_ADD,
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
})
|
})
|
||||||
expect(newState.checkedList).toEqual(["obj1"])
|
expect(newState.checkedList).toEqual(["obj1"])
|
||||||
})
|
})
|
||||||
@ -226,12 +226,12 @@ describe("objects reducer", () => {
|
|||||||
it("should handle SELECTED_LIST_REMOVE", () => {
|
it("should handle SELECTED_LIST_REMOVE", () => {
|
||||||
const newState = reducer(
|
const newState = reducer(
|
||||||
{
|
{
|
||||||
checkedList: ["obj1", "obj2"],
|
checkedList: ["obj1", "obj2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.CHECKED_LIST_REMOVE,
|
type: actions.CHECKED_LIST_REMOVE,
|
||||||
object: "obj1",
|
object: "obj1"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.checkedList).toEqual(["obj2"])
|
expect(newState.checkedList).toEqual(["obj2"])
|
||||||
})
|
})
|
||||||
@ -239,11 +239,11 @@ describe("objects reducer", () => {
|
|||||||
it("should handle CHECKED_LIST_RESET", () => {
|
it("should handle CHECKED_LIST_RESET", () => {
|
||||||
const newState = reducer(
|
const newState = reducer(
|
||||||
{
|
{
|
||||||
checkedList: ["obj1", "obj2"],
|
checkedList: ["obj1", "obj2"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.CHECKED_LIST_RESET,
|
type: actions.CHECKED_LIST_RESET
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.checkedList).toEqual([])
|
expect(newState.checkedList).toEqual([])
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ import history from "../history"
|
|||||||
import {
|
import {
|
||||||
sortObjectsByName,
|
sortObjectsByName,
|
||||||
sortObjectsBySize,
|
sortObjectsBySize,
|
||||||
sortObjectsByDate,
|
sortObjectsByDate
|
||||||
} from "../utils"
|
} from "../utils"
|
||||||
import { getCurrentBucket } from "../buckets/selectors"
|
import { getCurrentBucket } from "../buckets/selectors"
|
||||||
import { getCurrentPrefix, getCheckedList } from "./selectors"
|
import { getCurrentPrefix, getCheckedList } from "./selectors"
|
||||||
@ -42,28 +42,28 @@ export const setList = (objects, marker, isTruncated) => ({
|
|||||||
type: SET_LIST,
|
type: SET_LIST,
|
||||||
objects,
|
objects,
|
||||||
marker,
|
marker,
|
||||||
isTruncated,
|
isTruncated
|
||||||
})
|
})
|
||||||
|
|
||||||
export const appendList = (objects, marker, isTruncated) => ({
|
export const appendList = (objects, marker, isTruncated) => ({
|
||||||
type: APPEND_LIST,
|
type: APPEND_LIST,
|
||||||
objects,
|
objects,
|
||||||
marker,
|
marker,
|
||||||
isTruncated,
|
isTruncated
|
||||||
})
|
})
|
||||||
|
|
||||||
export const fetchObjects = append => {
|
export const fetchObjects = append => {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const {
|
const {
|
||||||
buckets: { currentBucket },
|
buckets: { currentBucket },
|
||||||
objects: { currentPrefix, marker },
|
objects: { currentPrefix, marker }
|
||||||
} = getState()
|
} = getState()
|
||||||
if (currentBucket) {
|
if (currentBucket) {
|
||||||
return web
|
return web
|
||||||
.ListObjects({
|
.ListObjects({
|
||||||
bucketName: currentBucket,
|
bucketName: currentBucket,
|
||||||
prefix: currentPrefix,
|
prefix: currentPrefix,
|
||||||
marker: append ? marker : "",
|
marker: append ? marker : ""
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let objects = []
|
let objects = []
|
||||||
@ -71,7 +71,7 @@ export const fetchObjects = append => {
|
|||||||
objects = res.objects.map(object => {
|
objects = res.objects.map(object => {
|
||||||
return {
|
return {
|
||||||
...object,
|
...object,
|
||||||
name: object.name.replace(currentPrefix, ""),
|
name: object.name.replace(currentPrefix, "")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -88,8 +88,8 @@ export const fetchObjects = append => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
history.push("/login")
|
history.push("/login")
|
||||||
})
|
})
|
||||||
@ -124,12 +124,12 @@ export const sortObjects = sortBy => {
|
|||||||
|
|
||||||
export const setSortBy = sortBy => ({
|
export const setSortBy = sortBy => ({
|
||||||
type: SET_SORT_BY,
|
type: SET_SORT_BY,
|
||||||
sortBy,
|
sortBy
|
||||||
})
|
})
|
||||||
|
|
||||||
export const setSortOrder = sortOrder => ({
|
export const setSortOrder = sortOrder => ({
|
||||||
type: SET_SORT_ORDER,
|
type: SET_SORT_ORDER,
|
||||||
sortOrder,
|
sortOrder
|
||||||
})
|
})
|
||||||
|
|
||||||
export const selectPrefix = prefix => {
|
export const selectPrefix = prefix => {
|
||||||
@ -145,13 +145,13 @@ export const selectPrefix = prefix => {
|
|||||||
export const setCurrentPrefix = prefix => {
|
export const setCurrentPrefix = prefix => {
|
||||||
return {
|
return {
|
||||||
type: SET_CURRENT_PREFIX,
|
type: SET_CURRENT_PREFIX,
|
||||||
prefix,
|
prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setPrefixWritable = prefixWritable => ({
|
export const setPrefixWritable = prefixWritable => ({
|
||||||
type: SET_PREFIX_WRITABLE,
|
type: SET_PREFIX_WRITABLE,
|
||||||
prefixWritable,
|
prefixWritable
|
||||||
})
|
})
|
||||||
|
|
||||||
export const deleteObject = object => {
|
export const deleteObject = object => {
|
||||||
@ -162,7 +162,7 @@ export const deleteObject = object => {
|
|||||||
return web
|
return web
|
||||||
.RemoveObject({
|
.RemoveObject({
|
||||||
bucketName: currentBucket,
|
bucketName: currentBucket,
|
||||||
objects: [objectName],
|
objects: [objectName]
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(removeObject(object))
|
dispatch(removeObject(object))
|
||||||
@ -171,8 +171,8 @@ export const deleteObject = object => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: e.message,
|
message: e.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ export const deleteObject = object => {
|
|||||||
|
|
||||||
export const removeObject = object => ({
|
export const removeObject = object => ({
|
||||||
type: REMOVE,
|
type: REMOVE,
|
||||||
object,
|
object
|
||||||
})
|
})
|
||||||
|
|
||||||
export const deleteCheckedObjects = () => {
|
export const deleteCheckedObjects = () => {
|
||||||
@ -204,23 +204,23 @@ export const shareObject = (object, days, hours, minutes) => {
|
|||||||
host: location.host,
|
host: location.host,
|
||||||
bucket: currentBucket,
|
bucket: currentBucket,
|
||||||
object: objectName,
|
object: objectName,
|
||||||
expiry,
|
expiry
|
||||||
})
|
})
|
||||||
.then(obj => {
|
.then(obj => {
|
||||||
dispatch(showShareObject(object, obj.url))
|
dispatch(showShareObject(object, obj.url))
|
||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: `Object shared. Expires in ${days} days ${hours} hours ${minutes} minutes`,
|
message: `Object shared. Expires in ${days} days ${hours} hours ${minutes} minutes`
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -230,14 +230,14 @@ export const showShareObject = (object, url) => ({
|
|||||||
type: SET_SHARE_OBJECT,
|
type: SET_SHARE_OBJECT,
|
||||||
show: true,
|
show: true,
|
||||||
object,
|
object,
|
||||||
url,
|
url
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideShareObject = (object, url) => ({
|
export const hideShareObject = (object, url) => ({
|
||||||
type: SET_SHARE_OBJECT,
|
type: SET_SHARE_OBJECT,
|
||||||
show: false,
|
show: false,
|
||||||
object: "",
|
object: "",
|
||||||
url: "",
|
url: ""
|
||||||
})
|
})
|
||||||
|
|
||||||
export const downloadObject = object => {
|
export const downloadObject = object => {
|
||||||
@ -261,8 +261,8 @@ export const downloadObject = object => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -276,16 +276,16 @@ export const downloadObject = object => {
|
|||||||
|
|
||||||
export const checkObject = object => ({
|
export const checkObject = object => ({
|
||||||
type: CHECKED_LIST_ADD,
|
type: CHECKED_LIST_ADD,
|
||||||
object,
|
object
|
||||||
})
|
})
|
||||||
|
|
||||||
export const uncheckObject = object => ({
|
export const uncheckObject = object => ({
|
||||||
type: CHECKED_LIST_REMOVE,
|
type: CHECKED_LIST_REMOVE,
|
||||||
object,
|
object
|
||||||
})
|
})
|
||||||
|
|
||||||
export const resetCheckedList = () => ({
|
export const resetCheckedList = () => ({
|
||||||
type: CHECKED_LIST_RESET,
|
type: CHECKED_LIST_RESET
|
||||||
})
|
})
|
||||||
|
|
||||||
export const downloadCheckedObjects = () => {
|
export const downloadCheckedObjects = () => {
|
||||||
@ -294,7 +294,7 @@ export const downloadCheckedObjects = () => {
|
|||||||
const req = {
|
const req = {
|
||||||
bucketName: getCurrentBucket(state),
|
bucketName: getCurrentBucket(state),
|
||||||
prefix: getCurrentPrefix(state),
|
prefix: getCurrentPrefix(state),
|
||||||
objects: getCheckedList(state),
|
objects: getCheckedList(state)
|
||||||
}
|
}
|
||||||
if (!web.LoggedIn()) {
|
if (!web.LoggedIn()) {
|
||||||
const requestUrl = location.origin + "/minio/zip?token=''"
|
const requestUrl = location.origin + "/minio/zip?token=''"
|
||||||
@ -312,9 +312,9 @@ export const downloadCheckedObjects = () => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: err.message,
|
message: err.message
|
||||||
}),
|
})
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ const downloadZip = (url, req, dispatch) => {
|
|||||||
if (this.status == 200) {
|
if (this.status == 200) {
|
||||||
dispatch(resetCheckedList())
|
dispatch(resetCheckedList())
|
||||||
var blob = new Blob([this.response], {
|
var blob = new Blob([this.response], {
|
||||||
type: "octet/stream",
|
type: "octet/stream"
|
||||||
})
|
})
|
||||||
var blobUrl = window.URL.createObjectURL(blob)
|
var blobUrl = window.URL.createObjectURL(blob)
|
||||||
var separator = req.prefix.length > 1 ? "-" : ""
|
var separator = req.prefix.length > 1 ? "-" : ""
|
||||||
|
@ -36,11 +36,11 @@ export default (
|
|||||||
shareObject: {
|
shareObject: {
|
||||||
show: false,
|
show: false,
|
||||||
object: "",
|
object: "",
|
||||||
url: "",
|
url: ""
|
||||||
},
|
},
|
||||||
checkedList: [],
|
checkedList: []
|
||||||
},
|
},
|
||||||
action,
|
action
|
||||||
) => {
|
) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actionsObjects.SET_LIST:
|
case actionsObjects.SET_LIST:
|
||||||
@ -48,41 +48,41 @@ export default (
|
|||||||
...state,
|
...state,
|
||||||
list: action.objects,
|
list: action.objects,
|
||||||
marker: action.marker,
|
marker: action.marker,
|
||||||
isTruncated: action.isTruncated,
|
isTruncated: action.isTruncated
|
||||||
}
|
}
|
||||||
case actionsObjects.APPEND_LIST:
|
case actionsObjects.APPEND_LIST:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
list: [...state.list, ...action.objects],
|
list: [...state.list, ...action.objects],
|
||||||
marker: action.marker,
|
marker: action.marker,
|
||||||
isTruncated: action.isTruncated,
|
isTruncated: action.isTruncated
|
||||||
}
|
}
|
||||||
case actionsObjects.REMOVE:
|
case actionsObjects.REMOVE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
list: removeObject(state.list, action.object, object => object.name),
|
list: removeObject(state.list, action.object, object => object.name)
|
||||||
}
|
}
|
||||||
case actionsObjects.SET_SORT_BY:
|
case actionsObjects.SET_SORT_BY:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
sortBy: action.sortBy,
|
sortBy: action.sortBy
|
||||||
}
|
}
|
||||||
case actionsObjects.SET_SORT_ORDER:
|
case actionsObjects.SET_SORT_ORDER:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
sortOrder: action.sortOrder,
|
sortOrder: action.sortOrder
|
||||||
}
|
}
|
||||||
case actionsObjects.SET_CURRENT_PREFIX:
|
case actionsObjects.SET_CURRENT_PREFIX:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
currentPrefix: action.prefix,
|
currentPrefix: action.prefix,
|
||||||
marker: "",
|
marker: "",
|
||||||
isTruncated: false,
|
isTruncated: false
|
||||||
}
|
}
|
||||||
case actionsObjects.SET_PREFIX_WRITABLE:
|
case actionsObjects.SET_PREFIX_WRITABLE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
prefixWritable: action.prefixWritable,
|
prefixWritable: action.prefixWritable
|
||||||
}
|
}
|
||||||
case actionsObjects.SET_SHARE_OBJECT:
|
case actionsObjects.SET_SHARE_OBJECT:
|
||||||
return {
|
return {
|
||||||
@ -90,13 +90,13 @@ export default (
|
|||||||
shareObject: {
|
shareObject: {
|
||||||
show: action.show,
|
show: action.show,
|
||||||
object: action.object,
|
object: action.object,
|
||||||
url: action.url,
|
url: action.url
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
case actionsObjects.CHECKED_LIST_ADD:
|
case actionsObjects.CHECKED_LIST_ADD:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
checkedList: [...state.checkedList, action.object],
|
checkedList: [...state.checkedList, action.object]
|
||||||
}
|
}
|
||||||
case actionsObjects.CHECKED_LIST_REMOVE:
|
case actionsObjects.CHECKED_LIST_REMOVE:
|
||||||
return {
|
return {
|
||||||
@ -104,13 +104,13 @@ export default (
|
|||||||
checkedList: removeObject(
|
checkedList: removeObject(
|
||||||
state.checkedList,
|
state.checkedList,
|
||||||
action.object,
|
action.object,
|
||||||
object => object,
|
object => object
|
||||||
),
|
)
|
||||||
}
|
}
|
||||||
case actionsObjects.CHECKED_LIST_RESET:
|
case actionsObjects.CHECKED_LIST_RESET:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
checkedList: [],
|
checkedList: []
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
@ -26,7 +26,7 @@ const rootReducer = combineReducers({
|
|||||||
alert,
|
alert,
|
||||||
buckets,
|
buckets,
|
||||||
objects,
|
objects,
|
||||||
uploads,
|
uploads
|
||||||
})
|
})
|
||||||
|
|
||||||
export default rootReducer
|
export default rootReducer
|
||||||
|
@ -30,15 +30,15 @@ export class AbortConfirmModal extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const { hideAbort } = this.props
|
const { hideAbort } = this.props
|
||||||
let baseClass = classNames({
|
let baseClass = classNames({
|
||||||
"abort-upload": true,
|
"abort-upload": true
|
||||||
})
|
})
|
||||||
let okIcon = classNames({
|
let okIcon = classNames({
|
||||||
fa: true,
|
fa: true,
|
||||||
"fa-times": true,
|
"fa-times": true
|
||||||
})
|
})
|
||||||
let cancelIcon = classNames({
|
let cancelIcon = classNames({
|
||||||
fa: true,
|
fa: true,
|
||||||
"fa-cloud-upload": true,
|
"fa-cloud-upload": true
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -61,14 +61,14 @@ export class AbortConfirmModal extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
uploads: state.uploads.files,
|
uploads: state.uploads.files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
abort: slug => dispatch(uploadsActions.abortUpload(slug)),
|
abort: slug => dispatch(uploadsActions.abortUpload(slug)),
|
||||||
hideAbort: () => dispatch(uploadsActions.hideAbortModal()),
|
hideAbort: () => dispatch(uploadsActions.hideAbortModal())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export class Dropzone extends React.Component {
|
|||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
uploadFile: file => dispatch(actions.uploadFile(file)),
|
uploadFile: file => dispatch(actions.uploadFile(file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ export class UploadModal extends React.Component {
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
uploads: state.uploads.files,
|
uploads: state.uploads.files,
|
||||||
showAbort: state.uploads.showAbortModal,
|
showAbort: state.uploads.showAbortModal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
showAbortModal: () => dispatch(uploadsActions.showAbortModal()),
|
showAbortModal: () => dispatch(uploadsActions.showAbortModal())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ describe("AbortConfirmModal", () => {
|
|||||||
<AbortConfirmModal
|
<AbortConfirmModal
|
||||||
uploads={{
|
uploads={{
|
||||||
"a-b/-test1": { size: 100, loaded: 50, name: "test1" },
|
"a-b/-test1": { size: 100, loaded: 50, name: "test1" },
|
||||||
"a-b/-test2": { size: 100, loaded: 50, name: "test2" },
|
"a-b/-test2": { size: 100, loaded: 50, name: "test2" }
|
||||||
}}
|
}}
|
||||||
abort={abort}
|
abort={abort}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.instance().abortUploads()
|
wrapper.instance().abortUploads()
|
||||||
expect(abort.mock.calls.length).toBe(2)
|
expect(abort.mock.calls.length).toBe(2)
|
||||||
|
@ -27,10 +27,10 @@ describe("Dropzone", () => {
|
|||||||
const uploadFile = jest.fn()
|
const uploadFile = jest.fn()
|
||||||
const wrapper = shallow(<Dropzone uploadFile={uploadFile} />)
|
const wrapper = shallow(<Dropzone uploadFile={uploadFile} />)
|
||||||
const file1 = new Blob(["file content1"], {
|
const file1 = new Blob(["file content1"], {
|
||||||
type: "text/plain",
|
type: "text/plain"
|
||||||
})
|
})
|
||||||
const file2 = new Blob(["file content2"], {
|
const file2 = new Blob(["file content2"], {
|
||||||
type: "text/plain",
|
type: "text/plain"
|
||||||
})
|
})
|
||||||
wrapper.first().prop("onDrop")([file1, file2])
|
wrapper.first().prop("onDrop")([file1, file2])
|
||||||
expect(uploadFile.mock.calls).toEqual([[file1], [file2]])
|
expect(uploadFile.mock.calls).toEqual([[file1], [file2]])
|
||||||
|
@ -37,7 +37,7 @@ describe("UploadModal", () => {
|
|||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<UploadModal
|
<UploadModal
|
||||||
uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }}
|
uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
expect(wrapper.find("ProgressBar").length).toBe(1)
|
expect(wrapper.find("ProgressBar").length).toBe(1)
|
||||||
})
|
})
|
||||||
@ -48,7 +48,7 @@ describe("UploadModal", () => {
|
|||||||
<UploadModal
|
<UploadModal
|
||||||
uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }}
|
uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }}
|
||||||
showAbortModal={showAbortModal}
|
showAbortModal={showAbortModal}
|
||||||
/>,
|
/>
|
||||||
)
|
)
|
||||||
wrapper.find("button").simulate("click")
|
wrapper.find("button").simulate("click")
|
||||||
expect(showAbortModal).toHaveBeenCalled()
|
expect(showAbortModal).toHaveBeenCalled()
|
||||||
|
@ -29,8 +29,8 @@ describe("Uploads actions", () => {
|
|||||||
type: "uploads/ADD",
|
type: "uploads/ADD",
|
||||||
slug: "a-b-c",
|
slug: "a-b-c",
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test",
|
name: "test"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.add("a-b-c", 100, "test"))
|
store.dispatch(uploadsActions.add("a-b-c", 100, "test"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -43,8 +43,8 @@ describe("Uploads actions", () => {
|
|||||||
{
|
{
|
||||||
type: "uploads/UPDATE_PROGRESS",
|
type: "uploads/UPDATE_PROGRESS",
|
||||||
slug: "a-b-c",
|
slug: "a-b-c",
|
||||||
loaded: 50,
|
loaded: 50
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.updateProgress("a-b-c", 50))
|
store.dispatch(uploadsActions.updateProgress("a-b-c", 50))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -56,8 +56,8 @@ describe("Uploads actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "uploads/STOP",
|
type: "uploads/STOP",
|
||||||
slug: "a-b-c",
|
slug: "a-b-c"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.stop("a-b-c"))
|
store.dispatch(uploadsActions.stop("a-b-c"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -69,8 +69,8 @@ describe("Uploads actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "uploads/SHOW_ABORT_MODAL",
|
type: "uploads/SHOW_ABORT_MODAL",
|
||||||
show: true,
|
show: true
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.showAbortModal())
|
store.dispatch(uploadsActions.showAbortModal())
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -79,15 +79,15 @@ describe("Uploads actions", () => {
|
|||||||
|
|
||||||
describe("uploadFile", () => {
|
describe("uploadFile", () => {
|
||||||
const file = new Blob(["file content"], {
|
const file = new Blob(["file content"], {
|
||||||
type: "text/plain",
|
type: "text/plain"
|
||||||
})
|
})
|
||||||
file.name = "file1"
|
file.name = "file1"
|
||||||
|
|
||||||
it("creates alerts/SET action when currentBucket is not present", () => {
|
it("creates alerts/SET action when currentBucket is not present", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "",
|
currentBucket: ""
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
@ -95,12 +95,12 @@ describe("Uploads actions", () => {
|
|||||||
alert: {
|
alert: {
|
||||||
id: 0,
|
id: 0,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Please choose a bucket before trying to upload files.",
|
message: "Please choose a bucket before trying to upload files."
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
const file = new Blob(["file content"], {
|
const file = new Blob(["file content"], {
|
||||||
type: "text/plain",
|
type: "text/plain"
|
||||||
})
|
})
|
||||||
store.dispatch(uploadsActions.uploadFile(file))
|
store.dispatch(uploadsActions.uploadFile(file))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -110,19 +110,19 @@ describe("Uploads actions", () => {
|
|||||||
it("creates uploads/ADD action before uploading the file", () => {
|
it("creates uploads/ADD action before uploading the file", () => {
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "test1",
|
currentBucket: "test1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "uploads/ADD",
|
type: "uploads/ADD",
|
||||||
slug: "test1-pre1/-file1",
|
slug: "test1-pre1/-file1",
|
||||||
size: file.size,
|
size: file.size,
|
||||||
name: file.name,
|
name: file.name
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.uploadFile(file))
|
store.dispatch(uploadsActions.uploadFile(file))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
@ -137,23 +137,23 @@ describe("Uploads actions", () => {
|
|||||||
send: send,
|
send: send,
|
||||||
setRequestHeader: jest.fn(),
|
setRequestHeader: jest.fn(),
|
||||||
upload: {
|
upload: {
|
||||||
addEventListener: jest.fn(),
|
addEventListener: jest.fn()
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
|
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
|
||||||
const store = mockStore({
|
const store = mockStore({
|
||||||
buckets: {
|
buckets: {
|
||||||
currentBucket: "test1",
|
currentBucket: "test1"
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
currentPrefix: "pre1/",
|
currentPrefix: "pre1/"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
store.dispatch(uploadsActions.uploadFile(file))
|
store.dispatch(uploadsActions.uploadFile(file))
|
||||||
expect(open).toHaveBeenCalledWith(
|
expect(open).toHaveBeenCalledWith(
|
||||||
"PUT",
|
"PUT",
|
||||||
"https://localhost:8080/upload/test1/pre1/file1",
|
"https://localhost:8080/upload/test1/pre1/file1",
|
||||||
true,
|
true
|
||||||
)
|
)
|
||||||
expect(send).toHaveBeenCalledWith(file)
|
expect(send).toHaveBeenCalledWith(file)
|
||||||
})
|
})
|
||||||
@ -164,12 +164,12 @@ describe("Uploads actions", () => {
|
|||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{
|
{
|
||||||
type: "uploads/STOP",
|
type: "uploads/STOP",
|
||||||
slug: "a-b/-c",
|
slug: "a-b/-c"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "uploads/SHOW_ABORT_MODAL",
|
type: "uploads/SHOW_ABORT_MODAL",
|
||||||
show: false,
|
show: false
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
store.dispatch(uploadsActions.abortUpload("a-b/-c"))
|
store.dispatch(uploadsActions.abortUpload("a-b/-c"))
|
||||||
const actions = store.getActions()
|
const actions = store.getActions()
|
||||||
|
@ -22,7 +22,7 @@ describe("uploads reducer", () => {
|
|||||||
const initialState = reducer(undefined, {})
|
const initialState = reducer(undefined, {})
|
||||||
expect(initialState).toEqual({
|
expect(initialState).toEqual({
|
||||||
files: {},
|
files: {},
|
||||||
showAbortModal: false,
|
showAbortModal: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ describe("uploads reducer", () => {
|
|||||||
type: actions.ADD,
|
type: actions.ADD,
|
||||||
slug: "a-b-c",
|
slug: "a-b-c",
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test",
|
name: "test"
|
||||||
})
|
})
|
||||||
expect(newState.files).toEqual({
|
expect(newState.files).toEqual({
|
||||||
"a-b-c": {
|
"a-b-c": {
|
||||||
loaded: 0,
|
loaded: 0,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test",
|
name: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -49,22 +49,22 @@ describe("uploads reducer", () => {
|
|||||||
"a-b-c": {
|
"a-b-c": {
|
||||||
loaded: 0,
|
loaded: 0,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test",
|
name: "test"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.UPDATE_PROGRESS,
|
type: actions.UPDATE_PROGRESS,
|
||||||
slug: "a-b-c",
|
slug: "a-b-c",
|
||||||
loaded: 50,
|
loaded: 50
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.files).toEqual({
|
expect(newState.files).toEqual({
|
||||||
"a-b-c": {
|
"a-b-c": {
|
||||||
loaded: 50,
|
loaded: 50,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test",
|
name: "test"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -75,38 +75,38 @@ describe("uploads reducer", () => {
|
|||||||
"a-b-c": {
|
"a-b-c": {
|
||||||
loaded: 70,
|
loaded: 70,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test1",
|
name: "test1"
|
||||||
},
|
},
|
||||||
"x-y-z": {
|
"x-y-z": {
|
||||||
loaded: 50,
|
loaded: 50,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.STOP,
|
type: actions.STOP,
|
||||||
slug: "a-b-c",
|
slug: "a-b-c"
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.files).toEqual({
|
expect(newState.files).toEqual({
|
||||||
"x-y-z": {
|
"x-y-z": {
|
||||||
loaded: 50,
|
loaded: 50,
|
||||||
size: 100,
|
size: 100,
|
||||||
name: "test2",
|
name: "test2"
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle SHOW_ABORT_MODAL", () => {
|
it("should handle SHOW_ABORT_MODAL", () => {
|
||||||
const newState = reducer(
|
const newState = reducer(
|
||||||
{
|
{
|
||||||
showAbortModal: false,
|
showAbortModal: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: actions.SHOW_ABORT_MODAL,
|
type: actions.SHOW_ABORT_MODAL,
|
||||||
show: true,
|
show: true
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
expect(newState.showAbortModal).toBeTruthy()
|
expect(newState.showAbortModal).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
@ -31,28 +31,28 @@ export const add = (slug, size, name) => ({
|
|||||||
type: ADD,
|
type: ADD,
|
||||||
slug,
|
slug,
|
||||||
size,
|
size,
|
||||||
name,
|
name
|
||||||
})
|
})
|
||||||
|
|
||||||
export const updateProgress = (slug, loaded) => ({
|
export const updateProgress = (slug, loaded) => ({
|
||||||
type: UPDATE_PROGRESS,
|
type: UPDATE_PROGRESS,
|
||||||
slug,
|
slug,
|
||||||
loaded,
|
loaded
|
||||||
})
|
})
|
||||||
|
|
||||||
export const stop = slug => ({
|
export const stop = slug => ({
|
||||||
type: STOP,
|
type: STOP,
|
||||||
slug,
|
slug
|
||||||
})
|
})
|
||||||
|
|
||||||
export const showAbortModal = () => ({
|
export const showAbortModal = () => ({
|
||||||
type: SHOW_ABORT_MODAL,
|
type: SHOW_ABORT_MODAL,
|
||||||
show: true,
|
show: true
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideAbortModal = () => ({
|
export const hideAbortModal = () => ({
|
||||||
type: SHOW_ABORT_MODAL,
|
type: SHOW_ABORT_MODAL,
|
||||||
show: false,
|
show: false
|
||||||
})
|
})
|
||||||
|
|
||||||
let requests = {}
|
let requests = {}
|
||||||
@ -83,8 +83,8 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Please choose a bucket before trying to upload files.",
|
message: "Please choose a bucket before trying to upload files."
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -102,14 +102,14 @@ export const uploadFile = file => {
|
|||||||
if (token) {
|
if (token) {
|
||||||
xhr.setRequestHeader(
|
xhr.setRequestHeader(
|
||||||
"Authorization",
|
"Authorization",
|
||||||
"Bearer " + storage.getItem("token"),
|
"Bearer " + storage.getItem("token")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
xhr.setRequestHeader(
|
xhr.setRequestHeader(
|
||||||
"x-amz-date",
|
"x-amz-date",
|
||||||
Moment()
|
Moment()
|
||||||
.utc()
|
.utc()
|
||||||
.format("YYYYMMDDTHHmmss") + "Z",
|
.format("YYYYMMDDTHHmmss") + "Z"
|
||||||
)
|
)
|
||||||
|
|
||||||
dispatch(addUpload(xhr, slug, file.size, file.name))
|
dispatch(addUpload(xhr, slug, file.size, file.name))
|
||||||
@ -121,8 +121,8 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Unauthorized request.",
|
message: "Unauthorized request."
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (xhr.status == 500) {
|
if (xhr.status == 500) {
|
||||||
@ -131,8 +131,8 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: xhr.responseText,
|
message: xhr.responseText
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
@ -141,8 +141,8 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "File '" + file.name + "' uploaded successfully.",
|
message: "File '" + file.name + "' uploaded successfully."
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
dispatch(objectsActions.selectPrefix(currentPrefix))
|
dispatch(objectsActions.selectPrefix(currentPrefix))
|
||||||
}
|
}
|
||||||
@ -153,8 +153,8 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Error occurred uploading '" + file.name + "'.",
|
message: "Error occurred uploading '" + file.name + "'."
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ const add = (files, action) => ({
|
|||||||
[action.slug]: {
|
[action.slug]: {
|
||||||
loaded: 0,
|
loaded: 0,
|
||||||
size: action.size,
|
size: action.size,
|
||||||
name: action.name,
|
name: action.name
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateProgress = (files, action) => ({
|
const updateProgress = (files, action) => ({
|
||||||
...files,
|
...files,
|
||||||
[action.slug]: {
|
[action.slug]: {
|
||||||
...files[action.slug],
|
...files[action.slug],
|
||||||
loaded: action.loaded,
|
loaded: action.loaded
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const stop = (files, action) => {
|
const stop = (files, action) => {
|
||||||
@ -42,30 +42,30 @@ const stop = (files, action) => {
|
|||||||
export default (
|
export default (
|
||||||
state = {
|
state = {
|
||||||
files: {},
|
files: {},
|
||||||
showAbortModal: false,
|
showAbortModal: false
|
||||||
},
|
},
|
||||||
action,
|
action
|
||||||
) => {
|
) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case uploadsActions.ADD:
|
case uploadsActions.ADD:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
files: add(state.files, action),
|
files: add(state.files, action)
|
||||||
}
|
}
|
||||||
case uploadsActions.UPDATE_PROGRESS:
|
case uploadsActions.UPDATE_PROGRESS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
files: updateProgress(state.files, action),
|
files: updateProgress(state.files, action)
|
||||||
}
|
}
|
||||||
case uploadsActions.STOP:
|
case uploadsActions.STOP:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
files: stop(state.files, action),
|
files: stop(state.files, action)
|
||||||
}
|
}
|
||||||
case uploadsActions.SHOW_ABORT_MODAL:
|
case uploadsActions.SHOW_ABORT_MODAL:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
showAbortModal: action.show,
|
showAbortModal: action.show
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
@ -49,7 +49,7 @@ export const sortObjectsByDate = (objects, order) => {
|
|||||||
let files = objects.filter(object => !object.name.endsWith("/"))
|
let files = objects.filter(object => !object.name.endsWith("/"))
|
||||||
files = files.sort(
|
files = files.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(a.lastModified).getTime() - new Date(b.lastModified).getTime(),
|
new Date(a.lastModified).getTime() - new Date(b.lastModified).getTime()
|
||||||
)
|
)
|
||||||
if (order) files = files.reverse()
|
if (order) files = files.reverse()
|
||||||
return [...folders, ...files]
|
return [...folders, ...files]
|
||||||
@ -62,21 +62,21 @@ export const pathSlice = path => {
|
|||||||
if (!path)
|
if (!path)
|
||||||
return {
|
return {
|
||||||
bucket,
|
bucket,
|
||||||
prefix,
|
prefix
|
||||||
}
|
}
|
||||||
let objectIndex = path.indexOf("/", 1)
|
let objectIndex = path.indexOf("/", 1)
|
||||||
if (objectIndex == -1) {
|
if (objectIndex == -1) {
|
||||||
bucket = path.slice(1)
|
bucket = path.slice(1)
|
||||||
return {
|
return {
|
||||||
bucket,
|
bucket,
|
||||||
prefix,
|
prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bucket = path.slice(1, objectIndex)
|
bucket = path.slice(1, objectIndex)
|
||||||
prefix = path.slice(objectIndex + 1)
|
prefix = path.slice(objectIndex + 1)
|
||||||
return {
|
return {
|
||||||
bucket,
|
bucket,
|
||||||
prefix,
|
prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,16 +24,16 @@ class Web {
|
|||||||
const namespace = "Web"
|
const namespace = "Web"
|
||||||
this.JSONrpc = new JSONrpc({
|
this.JSONrpc = new JSONrpc({
|
||||||
endpoint,
|
endpoint,
|
||||||
namespace,
|
namespace
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
makeCall(method, options) {
|
makeCall(method, options) {
|
||||||
return this.JSONrpc.call(
|
return this.JSONrpc.call(
|
||||||
method,
|
method,
|
||||||
{
|
{
|
||||||
params: options,
|
params: options
|
||||||
},
|
},
|
||||||
storage.getItem("token"),
|
storage.getItem("token")
|
||||||
)
|
)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.status === 401) {
|
if (err.status === 401) {
|
||||||
@ -132,7 +132,7 @@ class Web {
|
|||||||
const web = new Web(
|
const web = new Web(
|
||||||
`${window.location.protocol}//${
|
`${window.location.protocol}//${
|
||||||
window.location.host
|
window.location.host
|
||||||
}${minioBrowserPrefix}/webrpc`,
|
}${minioBrowserPrefix}/webrpc`
|
||||||
)
|
)
|
||||||
|
|
||||||
export default web
|
export default web
|
||||||
|
Loading…
Reference in New Issue
Block a user