Merge pull request #42 from dxos/ashwinp-wrn-naming-changes

WRN & Naming changes
This commit is contained in:
Ashwin Phatak 2020-08-06 14:34:55 +05:30 committed by GitHub
commit ba4de7d1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 42 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(ids: [ "%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,7 +25,7 @@ const AppRecords = () => {
const [sorter, sortBy] = useSorter('createTime', false);
const appResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
pollInterval: config.api.intervalQuery,
variables: { attributes: { type: 'wrn:app' } }
variables: { attributes: { type: 'app' } }
}));
// TODO(telackey): Does this also need an interval?
@ -42,22 +42,26 @@ const AppRecords = () => {
<Table>
<TableHead>
<TableRow>
<TableCell onClick={sortBy('name')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell>
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell size='icon' />
</TableRow>
</TableHead>
<TableBody>
{appData.sort(sorter).map(({ id, name, version, createTime, attributes: { displayName, package: hash } }) => {
{appData.sort(sorter).map(({ id, names, createTime, attributes: { name: displayName, version, package: hash } }) => {
return (
<TableRow key={id} size='small'>
<TableCell monospace>
<AppLink config={config} name={name} />
{names.map(name => <>
<AppLink config={config} name={name} />
<br />
</>
)}
</TableCell>
<TableCell monospace>
<AppLink config={config} name={name} version={version} text={version} />
{version}
</TableCell>
<TableCell>
{displayName}

View File

@ -22,7 +22,7 @@ const BotRecords = () => {
const [sorter, sortBy] = useSorter('createTime', false);
const data = useQueryStatusReducer(useQuery(WNS_RECORDS, {
pollInterval: config.api.intervalQuery,
variables: { attributes: { type: 'wrn:bot' } }
variables: { attributes: { type: 'bot' } }
}));
if (!data) {
@ -35,18 +35,18 @@ const BotRecords = () => {
<Table>
<TableHead>
<TableRow>
<TableCell onClick={sortBy('name')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell>
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell size='icon' />
</TableRow>
</TableHead>
<TableBody>
{records.sort(sorter).map(({ id, name, version, createTime, attributes: { displayName } }) => {
{records.sort(sorter).map(({ id, names, createTime, attributes: { name: displayName, version } }) => {
return (
<TableRow key={id} size='small'>
<TableCell monospace>{name}</TableCell>
<TableCell monospace>{names}</TableCell>
<TableCell monospace>{version}</TableCell>
<TableCell>{displayName}</TableCell>
<TableCell>{moment.utc(createTime).fromNow()}</TableCell>

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 => ({
@ -83,41 +83,47 @@ const WNSRecords = ({ type }) => {
<Table>
<TableHead>
<TableRow>
<TableCell onClick={sortBy('type')} size='medium'>Type</TableCell>
<TableCell onClick={sortBy('name')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell>
<TableCell onClick={sortBy('attributes.type')} size='medium'>Type</TableCell>
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell onClick={sortBy('package')}>Package</TableCell>
<TableCell onClick={sortBy('attributes.package')}>Package</TableCell>
<TableCell size='icon' />
</TableRow>
</TableHead>
<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}
@ -129,7 +135,7 @@ const WNSRecords = ({ type }) => {
{pkgLink}
</TableCell>
<TableCell>
<QueryLink config={config} name={name} icon />
<QueryLink config={config} id={id} icon />
</TableCell>
</TableRow>
);