Skip to content

Commit

Permalink
fix fetchByNamespace bug
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Oct 26, 2017
1 parent ef9627d commit 7ff3e8d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/ui/src/state/actions/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ async function fetchResources(dispatch, getState, force, filter) {
dispatch(updatePermissionsForKind(kind, {
namespaced: true
}))
return fetchResourcesByNamespace(dispatch, getState, kubeKinds[kind], kind)
return fetchResourcesByNamespace(dispatch, getState, kubeKinds[kind])
} else if (resp.status !== 404) {
dispatch(addError(resp,'error',`Failed to fetch ${url}: ${resp.statusText}`,
'Try Again', () => { dispatch(requestResources()) } ))
Expand All @@ -457,9 +457,9 @@ async function fetchResources(dispatch, getState, force, filter) {
}
}

async function fetchResourcesByNamespace(dispatch, getState, kind, kubeKind) {
async function fetchResourcesByNamespace(dispatch, getState, kubeKind) {
let namespaces = getState().resources.namespaces
let urls = namespaces.map(ns => [kind, `/proxy/${kubeKind.base}/namespaces/${ns}/${kubeKind.plural}`, ns])
let urls = namespaces.map(ns => [kubeKind.name, `/proxy/${kubeKind.base}/namespaces/${ns}/${kubeKind.plural}`, ns])
let requests = urls.map(([kind,url,ns],index) => fetch(url, defaultFetchParams
).then(resp => {
if (!resp.ok) {
Expand Down Expand Up @@ -587,6 +587,9 @@ function watchResources(dispatch, getState) {
if (!objectEmpty(watches)) {
// Update/reset any existing watches
for (let kind in kubeKinds) {
if (kind in excludedKinds) {
continue
}
watchableNamespaces = accessEvaluator.getWatchableNamespaces(kind)
if (watchableNamespaces.length > 0) {
let watch = watches[kind]
Expand All @@ -605,6 +608,9 @@ function watchResources(dispatch, getState) {
}
} else {
for (let kind in kubeKinds) {
if (kind in excludedKinds) {
continue
}
watchableNamespaces = accessEvaluator.getWatchableNamespaces(kind)
if (watchableNamespaces.length > 0) {
watches[kind] = new ResourceKindWatcher({
Expand Down

0 comments on commit 7ff3e8d

Please sign in to comment.