Skip to content

Commit

Permalink
cleanups for creating/deleting resources
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Jan 2, 2018
1 parent 24f2689 commit 2321bbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions pkg/ui/src/state/actions/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function putResource(newResource, isNew) {
}
selectAllForResource(dispatch, resources, resource, pods)
}
return resources[newResource.key]
}
}
}
Expand Down Expand Up @@ -654,12 +655,9 @@ async function createResourceFromContents(dispatch, getState, contents) {
if (!resp.ok) {
if (resp.status === 401) {
dispatch(invalidateSession())
} else {
dispatch(addError(null,'error',`Failed to create resource: ${resp.statusText}`))
}
} else {
return resp.json()
}
return resp.json()
}).then(json => {
if (!!json) {
if (json.code) {
Expand All @@ -668,7 +666,8 @@ async function createResourceFromContents(dispatch, getState, contents) {
let resource = json
resource.key = keyForResource(resource)
dispatch(putResource(resource, true))
return getState().resources.resources[resource.key]
resource = getState().resources.resources[resource.key]
return resource
}
}
})
Expand Down Expand Up @@ -711,7 +710,7 @@ async function removeResources(dispatch, getState, resources) {
let results = await Promise.all(requests)
for (let i=0, len=results.length; i < len; ++i) {
let result = results[i]
if (result.status && result.status !== 404) {
if (result.code && result.code !== 404) {
dispatch(addError(result,'error',`${result.code} ${result.reason}; ${result.message}`))
} else {
dispatch({
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/src/state/reducers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function doUpdateResource(state, resource, isNew, kubeKinds) {
resource.key = keyForResource(resource)
if (resource.key in state.resources) {
let existing = state.resources[resource.key]
if (existing.isDeleted) {
if (existing.isDeleted && !isNew) {
return state
}
} else if (!isNew && resource.kind !== 'Pod') {
Expand Down

0 comments on commit 2321bbc

Please sign in to comment.