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
switch (type) {
case 'wrn:bot': {
case 'bot': {
const packageLinks = [];
Object.keys(pkg).forEach((platform, i) => {
Object.keys(pkg[platform]).forEach(arch => {

View File

@ -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 }) => {
<LinkIcon />
)}
{!icon && (
text || name
text || id
)}
</Link>
);

View File

@ -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 }) => {
<TableBody>
{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 = (<PackageLink config={config} type={type} pkg={pkg} />);
}
if (type === 'wrn:app') {
appLink = (<AppLink config={config} name={name} />);
verLink = (<AppLink config={config} name={name} version={version} text={version} />);
if (type === 'app') {
appLinks = (
<>
{names.map(name => <>
<AppLink config={config} name={name} />
<br />
</>
)}
</>
);
}
return (
<TableRow key={id} size='small'>
<TableCell monospace>{type}</TableCell>
<TableCell monospace>
{appLink || name}
{appLinks || names}
</TableCell>
<TableCell monospace>
{verLink || version}
{version}
</TableCell>
<TableCell>
{displayName || service || description}