fix: Bot updates. (#58)

* fix: update running bot tab.

* fix: add version link to bots records.
This commit is contained in:
Egor Gripasov 2020-12-10 14:01:19 +03:00 committed by GitHub
parent 4056042078
commit 1fed8f4de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import { ConsoleContext, useQueryStatusReducer, useSorter } from '../../../hooks
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 Link from '@material-ui/core/Link';
import Table from '../../../components/Table'; import Table from '../../../components/Table';
import TableCell from '../../../components/TableCell'; import TableCell from '../../../components/TableCell';
@ -38,17 +39,32 @@ const BotRecords = () => {
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell> <TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell> <TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.name')}>Name</TableCell> <TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('attributes.repository')}>Repository</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell> <TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell size='icon' /> <TableCell size='icon' />
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{records.sort(sorter).map(({ id, names, createTime, attributes: { name: displayName, version } }) => { {records.sort(sorter).map(({
id, names, createTime, attributes: { name: displayName, version, versionUrl, repositoryVersion, repository, homepage }
}) => {
const url = repository || homepage;
if (!versionUrl && repository && repositoryVersion && repository.includes('github')) {
versionUrl = `${repository}/tree/${repositoryVersion}`.replace('-dirty', '');
}
return ( return (
<TableRow key={id} size='small'> <TableRow key={id} size='small'>
<TableCell monospace>{names.map(name => <div key={name}>{name}</div>)}</TableCell> <TableCell monospace>{names.map(name => <div key={name}>{name}</div>)}</TableCell>
<TableCell monospace>{version}</TableCell> <TableCell monospace>
{versionUrl
? <Link href={versionUrl}>{version}</Link>
: version}
</TableCell>
<TableCell>{displayName}</TableCell> <TableCell>{displayName}</TableCell>
<TableCell>
{url &&
<Link href={url} target={url}>{url}</Link>}
</TableCell>
<TableCell>{moment.utc(createTime).fromNow()}</TableCell> <TableCell>{moment.utc(createTime).fromNow()}</TableCell>
<TableCell /> <TableCell />
</TableRow> </TableRow>

View File

@ -33,8 +33,8 @@ const Bots = () => {
<Toolbar> <Toolbar>
<Tabs value={tab} onChange={(_, value) => setTab(value)}> <Tabs value={tab} onChange={(_, value) => setTab(value)}>
<Tab value={TAB_RECORDS} label='Records' /> <Tab value={TAB_RECORDS} label='Records' />
<Tab value={TAB_LOG} label='Log' />
<Tab value={TAB_DATA} label='Running Bots' /> <Tab value={TAB_DATA} label='Running Bots' />
<Tab value={TAB_LOG} label='Log' />
</Tabs> </Tabs>
</Toolbar> </Toolbar>
} }

View File

@ -53,22 +53,22 @@ const RunningBots = () => {
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell onClick={sortBy('id')}>Identifier</TableCell> <TableCell onClick={sortBy('recordName')}>Identifier</TableCell>
<TableCell onClick={sortBy('botId')} size='small'>Bot Id</TableCell> <TableCell onClick={sortBy('botId')} size='small'>Bot Id</TableCell>
<TableCell onClick={sortBy('started')}>Started</TableCell> <TableCell onClick={sortBy('started')}>Started</TableCell>
<TableCell onClick={sortBy('stopped')}>Stopped</TableCell> <TableCell onClick={sortBy('stopped')}>Running</TableCell>
<TableCell onClick={sortBy('parties')} size='small'>Parties</TableCell> <TableCell onClick={sortBy('parties')} size='small'>Parties</TableCell>
<TableCell size='icon' /> <TableCell size='icon' />
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{botList.sort(sorter).map(({ id, botId, started, stopped, parties }) => { {botList.sort(sorter).map(({ recordName, botId, started, stopped, parties }) => {
return ( return (
<TableRow key={botId} size='small'> <TableRow key={botId} size='small'>
<TableCell monospace>{id}</TableCell> <TableCell monospace>{recordName}</TableCell>
<TableCell monospace>{botId}</TableCell> <TableCell monospace>{botId}</TableCell>
<TableCell>{moment.utc(started).fromNow()}</TableCell> <TableCell>{moment.utc(started).fromNow()}</TableCell>
<TableCell monospace>{String(stopped)}</TableCell> <TableCell monospace>{String(!stopped)}</TableCell>
<TableCell monospace>{parties && parties.map(partyId => <div key={partyId}>{partyId}</div>)}</TableCell> <TableCell monospace>{parties && parties.map(partyId => <div key={partyId}>{partyId}</div>)}</TableCell>
<TableCell monospace> <TableCell monospace>
<BotControls onStop={() => onKillBot(botId)} /> <BotControls onStop={() => onKillBot(botId)} />

View File

@ -1,7 +1,7 @@
{ {
"build": { "build": {
"name": "@dxos/console-app", "name": "@dxos/console-app",
"buildDate": "2020-12-09T23:25:12.047Z", "buildDate": "2020-12-10T09:59:41.380Z",
"version": "1.2.6-alpha.0" "version": "1.2.6-alpha.1"
} }
} }