New WRN/Naming scheme changes.

This commit is contained in:
Ashwin Phatak 2020-07-27 15:09:26 +05:30
parent 9c2528c3f8
commit c760a55ae6
3 changed files with 28 additions and 23 deletions

View File

@ -23,7 +23,7 @@ const PackageLink = ({ config, type, pkg, text }) => {
// eslint-disable-next-line default-case // eslint-disable-next-line default-case
switch (type) { switch (type) {
case 'wrn:bot': { case 'bot': {
const packageLinks = []; const packageLinks = [];
Object.keys(pkg).forEach((platform, i) => { Object.keys(pkg).forEach((platform, i) => {
Object.keys(pkg[platform]).forEach(arch => { Object.keys(pkg[platform]).forEach(arch => {

View File

@ -11,10 +11,9 @@ import { getServiceUrl } from '../util/config';
const QUERY = ` const QUERY = `
query { query {
queryRecords(attributes: [{ key: "name", value: { string: "%NAME%" } }]) { getRecordsByIds([ "%ID%" ]) {
id id
type names
name
bondId bondId
createTime createTime
expiryTime expiryTime
@ -33,13 +32,13 @@ const QUERY = `
/** /**
* Render link to record in WNS. * Render link to record in WNS.
* @param {Object} config * @param {Object} config
* @param {string} name * @param {string} id
* @param {string} [text] * @param {string} [text]
* @param {boolean} icon * @param {boolean} icon
*/ */
const QueryLink = ({ config, name, text, icon = false }) => { const QueryLink = ({ config, id, text, icon = false }) => {
const baseURL = getServiceUrl(config, 'wns.webui'); const baseURL = getServiceUrl(config, 'wns.webui');
const query = QUERY.replace('%NAME%', name); const query = QUERY.replace('%ID%', id);
// NOTE: Playground bug opens two tabs. // NOTE: Playground bug opens two tabs.
const fullURL = encodeURI(`${baseURL}?query=${query}`); const fullURL = encodeURI(`${baseURL}?query=${query}`);
@ -50,7 +49,7 @@ const QueryLink = ({ config, name, text, icon = false }) => {
<LinkIcon /> <LinkIcon />
)} )}
{!icon && ( {!icon && (
text || name text || id
)} )}
</Link> </Link>
); );

View File

@ -25,13 +25,13 @@ import AppLink from '../../../components/AppLink';
const types = [ const types = [
{ key: null, label: 'ALL' }, { key: null, label: 'ALL' },
{ key: 'wrn:kube', label: 'Kube' }, { key: 'kube', label: 'Kube' },
{ key: 'wrn:resource', label: 'Resource' }, { key: 'resource', label: 'Resource' },
{ key: 'wrn:service', label: 'Service' }, { key: 'service', label: 'Service' },
{ key: 'wrn:app', label: 'App' }, { key: 'app', label: 'App' },
{ key: 'wrn:bot', label: 'Bot' }, { key: 'bot', label: 'Bot' },
{ key: 'wrn:bot-factory', label: 'Bot Factory' }, { key: 'bot-factory', label: 'Bot Factory' },
{ key: 'wrn:type', label: 'Type' } { key: 'type', label: 'Type' }
]; ];
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
@ -95,29 +95,35 @@ const WNSRecords = ({ type }) => {
<TableBody> <TableBody>
{records.sort(sorter) {records.sort(sorter)
.map((record) => { .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 pkgLink;
let appLink; let appLinks;
let verLink;
if (pkg) { if (pkg) {
pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />); pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />);
} }
if (type === 'wrn:app') { if (type === 'app') {
appLink = (<AppLink config={config} name={name} />); appLinks = (
verLink = (<AppLink config={config} name={name} version={version} text={version} />); <>
{names.map(name => <>
<AppLink config={config} name={name} />
<br />
</>
)}
</>
);
} }
return ( return (
<TableRow key={id} size='small'> <TableRow key={id} size='small'>
<TableCell monospace>{type}</TableCell> <TableCell monospace>{type}</TableCell>
<TableCell monospace> <TableCell monospace>
{appLink || name} {appLinks || names}
</TableCell> </TableCell>
<TableCell monospace> <TableCell monospace>
{verLink || version} {version}
</TableCell> </TableCell>
<TableCell> <TableCell>
{displayName || service || description} {displayName || service || description}