This commit is contained in:
Thomas E Lackey 2020-06-09 22:39:04 -05:00
parent 432c061952
commit b21da7b831
5 changed files with 43 additions and 45 deletions

View File

@ -35,7 +35,7 @@ const getAppUrl = (config, { name, version, text }) => {
* @param {string} [version] * @param {string} [version]
*/ */
const AppLink = ({ config, name, version, text }) => { const AppLink = ({ config, name, version, text }) => {
const fullURL = getAppUrl(config, {name, version}); const fullURL = getAppUrl(config, { name, version });
return <Link href={fullURL} target={name}>{text || name}</Link>; return <Link href={fullURL} target={name}>{text || name}</Link>;
}; };

View File

@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import Link from '@material-ui/core/Link'; import Link from '@material-ui/core/Link';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import { getServiceUrl } from '../util/config'; import { getServiceUrl } from '../util/config';

View File

@ -22,15 +22,17 @@ const QUERY = `{
* @param {string} name * @param {string} name
* @param {string} [text] * @param {string} [text]
*/ */
const QueryLink = ({ config, name, text, icon = false}) => { const QueryLink = ({ config, name, 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('%NAME%', name);
const fullURL= encodeURI(`${baseURL}?query=${query}`); const fullURL = encodeURI(`${baseURL}?query=${query}`);
if (icon) { if (icon) {
return <Link href={fullURL} target='wns'> return (
<Link href={fullURL} target='wns'>
<ExitToApp /> <ExitToApp />
</Link> </Link>
);
} }
return <Link href={fullURL} target='wns'>{text || name}</Link>; return <Link href={fullURL} target='wns'>{text || name}</Link>;
}; };

View File

@ -6,7 +6,6 @@ import React, { useContext } from 'react';
import moment from 'moment'; import moment from 'moment';
import { useQuery } from '@apollo/react-hooks'; import { useQuery } from '@apollo/react-hooks';
import Link from '@material-ui/core/Link';
import TableHead from '@material-ui/core/TableHead'; import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow'; import TableRow from '@material-ui/core/TableRow';
import TableBody from '@material-ui/core/TableBody'; import TableBody from '@material-ui/core/TableBody';
@ -19,8 +18,7 @@ import { ConsoleContext, useQueryStatusReducer, useSorter } from '../../../hooks
import { BooleanIcon } from '../../../components/BooleanIcon'; import { BooleanIcon } from '../../../components/BooleanIcon';
import Table from '../../../components/Table'; import Table from '../../../components/Table';
import TableCell from '../../../components/TableCell'; import TableCell from '../../../components/TableCell';
import { getServiceUrl } from '../../../util/config'; import AppLink from '../../../components/AppLink';
import AppLink from "../../../components/AppLink";
const AppRecords = () => { const AppRecords = () => {
const { config } = useContext(ConsoleContext); const { config } = useContext(ConsoleContext);

View File

@ -11,7 +11,6 @@ import Button from '@material-ui/core/Button';
import TableHead from '@material-ui/core/TableHead'; import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow'; import TableRow from '@material-ui/core/TableRow';
import TableBody from '@material-ui/core/TableBody'; import TableBody from '@material-ui/core/TableBody';
import Tooltip from '@material-ui/core/Tooltip';
import WNS_RECORDS from '../../../gql/wns_records.graphql'; import WNS_RECORDS from '../../../gql/wns_records.graphql';
@ -21,8 +20,8 @@ import Table from '../../../components/Table';
import TableCell from '../../../components/TableCell'; import TableCell from '../../../components/TableCell';
import PackageLink from '../../../components/PackageLink'; import PackageLink from '../../../components/PackageLink';
import QueryLink from "../../../components/QueryLink"; import QueryLink from '../../../components/QueryLink';
import AppLink from "../../../components/AppLink"; import AppLink from '../../../components/AppLink';
const types = [ const types = [
{ key: null, label: 'ALL' }, { key: null, label: 'ALL' },
@ -97,30 +96,31 @@ const WNSRecords = ({ type }) => {
.map((record) => { .map((record) => {
const { id, type, name, version, createTime, attributes: { displayName, description, service, package: pkg } } = record; const { id, type, name, version, createTime, attributes: { displayName, description, service, package: pkg } } = record;
let pkgLink = undefined; let pkgLink;
let appLink = undefined; let appLink;
let verLink = undefined; 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 === 'wrn:app') {
appLink = (<AppLink config={config} name={name}/>); appLink = (<AppLink config={config} name={name} />);
verLink = (<AppLink config={config} name={name} version={version} text={version}/>); verLink = (<AppLink config={config} name={name} version={version} text={version} />);
} }
return (<TableRow key={id} size='small'> return (
<TableRow key={id} size='small'>
<TableCell monospace>{type}</TableCell> <TableCell monospace>{type}</TableCell>
<TableCell monospace> <TableCell monospace>
{appLink && appLink || name} {appLink || name}
</TableCell> </TableCell>
<TableCell> <TableCell>
<QueryLink config={config} name={name} icon={true}/> <QueryLink config={config} name={name} icon />
</TableCell> </TableCell>
<TableCell>{displayName || service || description}</TableCell> <TableCell>{displayName || service || description}</TableCell>
<TableCell monospace> <TableCell monospace>
{verLink && verLink || version} {verLink || version}
</TableCell> </TableCell>
<TableCell>{moment.utc(createTime).fromNow()}</TableCell> <TableCell>{moment.utc(createTime).fromNow()}</TableCell>
<TableCell monospace> <TableCell monospace>