From d257337a5a6bb4fd54548f17b878bd0b199a56ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=9Awi=C4=99cicki?= Date: Fri, 8 Mar 2019 19:44:28 +0100 Subject: [PATCH] Add filter by namespace #160 (#215) --- app/src/app.js | 19 +++++++++++++++---- docs/user-guide.rst | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/app.js b/app/src/app.js index 7b38260..42c7264 100644 --- a/app/src/app.js +++ b/app/src/app.js @@ -74,11 +74,22 @@ export default class App { return labels && labels[name] === value } + namespaceMatches(pod, value) { + return pod.namespace === value + } + createMatchesFunctionForQuery(query) { - if (query.includes('=')) { - const labelAndValue = query.split('=', 2) - return pod => this.labelMatches(pod, labelAndValue[0], labelAndValue[1]) - } else { + if (query.startsWith('namespace=')) { + // filter by namespace + const value = query.split('namespace=', 2)[1] + return pod => this.namespaceMatches(pod, value) + } else if (query.includes('=')) { + // filter by label + const [label, value] = query.split('=', 2) + return pod => this.labelMatches(pod, label, value) + } + else { + // filter by name return pod => this.nameMatches(pod, query) } } diff --git a/docs/user-guide.rst b/docs/user-guide.rst index 46ea1aa..ceac838 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -35,6 +35,7 @@ You can filter by: * name * labels - when query includes ``=``, e.g. ``env=prod`` +* namespace - when query starts with ``namespace``, e.g. ``namespace=default`` The pod filter is persisted in the location bar (``#q=..`` query parameter) which allows to conveniently send the filtered view to other users (e.g. for troubleshooting).