From c760a55ae628e42112ec2ce86662bd6b5a74b4dd Mon Sep 17 00:00:00 2001 From: Ashwin Phatak Date: Mon, 27 Jul 2020 15:09:26 +0530 Subject: [PATCH] New WRN/Naming scheme changes. --- .../console-app/src/components/PackageLink.js | 2 +- .../console-app/src/components/QueryLink.js | 13 ++++--- .../src/containers/panels/wns/WNSRecords.js | 36 +++++++++++-------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/console-app/src/components/PackageLink.js b/packages/console-app/src/components/PackageLink.js index 4b6ffb8..93aee9f 100644 --- a/packages/console-app/src/components/PackageLink.js +++ b/packages/console-app/src/components/PackageLink.js @@ -23,7 +23,7 @@ const PackageLink = ({ config, type, pkg, text }) => { // eslint-disable-next-line default-case switch (type) { - case 'wrn:bot': { + case 'bot': { const packageLinks = []; Object.keys(pkg).forEach((platform, i) => { Object.keys(pkg[platform]).forEach(arch => { diff --git a/packages/console-app/src/components/QueryLink.js b/packages/console-app/src/components/QueryLink.js index 92199a4..6cf6dfa 100644 --- a/packages/console-app/src/components/QueryLink.js +++ b/packages/console-app/src/components/QueryLink.js @@ -11,10 +11,9 @@ import { getServiceUrl } from '../util/config'; const QUERY = ` query { - queryRecords(attributes: [{ key: "name", value: { string: "%NAME%" } }]) { + getRecordsByIds([ "%ID%" ]) { id - type - name + names bondId createTime expiryTime @@ -33,13 +32,13 @@ const QUERY = ` /** * Render link to record in WNS. * @param {Object} config - * @param {string} name + * @param {string} id * @param {string} [text] * @param {boolean} icon */ -const QueryLink = ({ config, name, text, icon = false }) => { +const QueryLink = ({ config, id, text, icon = false }) => { const baseURL = getServiceUrl(config, 'wns.webui'); - const query = QUERY.replace('%NAME%', name); + const query = QUERY.replace('%ID%', id); // NOTE: Playground bug opens two tabs. const fullURL = encodeURI(`${baseURL}?query=${query}`); @@ -50,7 +49,7 @@ const QueryLink = ({ config, name, text, icon = false }) => { )} {!icon && ( - text || name + text || id )} ); diff --git a/packages/console-app/src/containers/panels/wns/WNSRecords.js b/packages/console-app/src/containers/panels/wns/WNSRecords.js index d13cdc9..f36b260 100644 --- a/packages/console-app/src/containers/panels/wns/WNSRecords.js +++ b/packages/console-app/src/containers/panels/wns/WNSRecords.js @@ -25,13 +25,13 @@ import AppLink from '../../../components/AppLink'; const types = [ { key: null, label: 'ALL' }, - { key: 'wrn:kube', label: 'Kube' }, - { key: 'wrn:resource', label: 'Resource' }, - { key: 'wrn:service', label: 'Service' }, - { key: 'wrn:app', label: 'App' }, - { key: 'wrn:bot', label: 'Bot' }, - { key: 'wrn:bot-factory', label: 'Bot Factory' }, - { key: 'wrn:type', label: 'Type' } + { key: 'kube', label: 'Kube' }, + { key: 'resource', label: 'Resource' }, + { key: 'service', label: 'Service' }, + { key: 'app', label: 'App' }, + { key: 'bot', label: 'Bot' }, + { key: 'bot-factory', label: 'Bot Factory' }, + { key: 'type', label: 'Type' } ]; const useStyles = makeStyles(theme => ({ @@ -95,29 +95,35 @@ const WNSRecords = ({ type }) => { {records.sort(sorter) .map((record) => { - const { id, type, name, version, createTime, attributes: { displayName, description, service, package: pkg } } = record; + const { id, names, createTime, attributes: { type, name: displayName, version, description, service, package: pkg } } = record; let pkgLink; - let appLink; - let verLink; + let appLinks; if (pkg) { pkgLink = (); } - if (type === 'wrn:app') { - appLink = (); - verLink = (); + if (type === 'app') { + appLinks = ( + <> + {names.map(name => <> + +
+ + )} + + ); } return ( {type} - {appLink || name} + {appLinks || names} - {verLink || version} + {version} {displayName || service || description}