fix success alert not shown after object is uploaded (#6500)

This commit is contained in:
Kanagaraj M 2018-09-20 22:54:09 +05:30 committed by Nitish Tiwari
parent b62ed5dc90
commit 7c339e248a
4 changed files with 64 additions and 69 deletions

View File

@ -22,7 +22,7 @@ export let alertId = 0
export const set = alert => {
const id = alertId++
return (dispatch, getState) => {
if (alert.type !== "danger") {
if (alert.type !== "danger" || alert.autoClear) {
setTimeout(() => {
dispatch({
type: CLEAR,

View File

@ -123,9 +123,6 @@ describe("Objects actions", () => {
objects: { currentPrefix: "" }
})
const expectedActions = [
{
type: "alert/CLEAR"
},
{
type: "objects/SET_LIST",
objects: [{ name: "test1" }, { name: "test2" }],
@ -157,9 +154,6 @@ describe("Objects actions", () => {
objects: { currentPrefix: "" }
})
const expectedActions = [
{
type: "alert/CLEAR"
},
{
type: "objects/APPEND_LIST",
objects: [{ name: "test1" }, { name: "test2" }],
@ -183,15 +177,13 @@ describe("Objects actions", () => {
objects: { currentPrefix: "" }
})
const expectedActions = [
{
type: "alert/CLEAR"
},
{
type: "alert/SET",
alert: {
type: "danger",
message: "listobjects is denied",
id: alertActions.alertId
id: alertActions.alertId,
autoClear: true
}
},
{
@ -252,7 +244,6 @@ describe("Objects actions", () => {
})
const expectedActions = [
{ type: "objects/SET_CURRENT_PREFIX", prefix: "abc/" },
{ type: "alert/CLEAR" },
{ type: "objects/CHECKED_LIST_RESET" }
]
store.dispatch(actionsObjects.selectPrefix("abc/"))

View File

@ -64,7 +64,6 @@ export const fetchObjects = append => {
buckets: { currentBucket },
objects: { currentPrefix, marker }
} = getState()
dispatch(alertActions.clear())
if (currentBucket) {
return web
.ListObjects({
@ -93,10 +92,15 @@ export const fetchObjects = append => {
})
.catch(err => {
if (web.LoggedIn()) {
dispatch(alertActions.set({ type: "danger", message: err.message }))
dispatch(
alertActions.set({
type: "danger",
message: err.message,
autoClear: true
})
)
dispatch(resetList())
}
else {
} else {
history.push("/login")
}
})

File diff suppressed because one or more lines are too long