Rename addons => extensions (#59)

UX sidebar
This commit is contained in:
Rich Burdon 2020-12-10 14:03:15 -05:00 committed by GitHub
parent ce9a90ec84
commit f3a50b4aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 19 deletions

View File

@ -13,8 +13,9 @@ import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemIcon from '@material-ui/core/ListItemIcon';
import LinkIcon from '@material-ui/icons/ExitToApp'; import LinkIcon from '@material-ui/icons/ExitToApp';
import ListItemText from '@material-ui/core/ListItemText'; import ListItemText from '@material-ui/core/ListItemText';
import EXTENSIONS from '../gql/extensions.graphql';
import { useQueryStatusReducer } from '../hooks'; import { useQueryStatusReducer } from '../hooks';
import ADDON_LIST from '../gql/addon_list.graphql';
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
root: { root: {
@ -35,6 +36,10 @@ const useStyles = makeStyles(theme => ({
selected: { selected: {
color: theme.palette.primary.main color: theme.palette.primary.main
},
expand: {
flex: 1
} }
})); }));
@ -43,12 +48,8 @@ const Sidebar = ({ modules: { services, settings } }) => {
const history = useHistory(); const history = useHistory();
const { module } = useParams(); const { module } = useParams();
const { data: addonResponse } = useQueryStatusReducer(useQuery(ADDON_LIST)); const { data: extensionsData } = useQueryStatusReducer(useQuery(EXTENSIONS));
console.log(addonResponse); const extensions = extensionsData ? JSON.parse(extensionsData.extensions.json) : [];
if (!addonResponse) {
return null;
}
const addons = JSON.parse(addonResponse.addon_list.json);
const isSelected = path => path === `/${module}`; const isSelected = path => path === `/${module}`;
@ -65,9 +66,9 @@ const Sidebar = ({ modules: { services, settings } }) => {
</List> </List>
); );
const Addons = ({ addons }) => ( const Extensions = ({ extensions }) => (
<List aria-label='items' className={classes.list}> <List aria-label='items' className={classes.list}>
{addons.map(({ url, title }) => ( {extensions.map(({ url, title }) => (
<ListItem button key={url} onClick={() => { window.location = url; return true; }}> <ListItem button key={url} onClick={() => { window.location = url; return true; }}>
<ListItemIcon classes={{ root: classes.icon }}> <ListItemIcon classes={{ root: classes.icon }}>
<LinkIcon className={clsx(classes.icon)} /> <LinkIcon className={clsx(classes.icon)} />
@ -81,7 +82,8 @@ const Sidebar = ({ modules: { services, settings } }) => {
return ( return (
<div className={classes.root}> <div className={classes.root}>
<Modules modules={services} /> <Modules modules={services} />
<Addons addons={addons} /> <Extensions extensions={extensions} />
<div className={classes.expand} />
<Modules modules={settings} /> <Modules modules={settings} />
</div> </div>
); );

View File

@ -3,7 +3,7 @@
# #
query { query {
addon_list { extensions {
json json
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"build": { "build": {
"name": "@dxos/console-app", "name": "@dxos/console-app",
"buildDate": "2020-12-10T09:59:41.380Z", "buildDate": "2020-12-10T18:33:21.012Z",
"version": "1.2.6-alpha.1" "version": "1.2.6-alpha.2"
} }
} }

View File

@ -22,7 +22,7 @@ type Query {
system_status: JSONResult! system_status: JSONResult!
wns_status: JSONResult! wns_status: JSONResult!
bot_list: JSONResult! bot_list: JSONResult!
addon_list: JSONResult! extensions: JSONResult!
} }
type Mutation { type Mutation {

View File

@ -9,7 +9,10 @@ const ifRadicle = () => {
try { try {
const result = childProcess.execSync('docker ps -f "ancestor=dxos/radicle-seed-node" -q'); const result = childProcess.execSync('docker ps -f "ancestor=dxos/radicle-seed-node" -q');
if (result && result.toString()) { if (result && result.toString()) {
return { title: 'Radicle', url: '/radicle/' }; return {
title: 'Radicle',
url: '/radicle/'
};
} }
} catch (e) {} } catch (e) {}
}; };
@ -22,9 +25,9 @@ const ifSentry = () => {
}; };
}; };
export const addonResolvers = { export const extensionResolvers = {
Query: { Query: {
addon_list: async (_, __, { config }) => { extensions: async (_, __, { config }) => {
return { return {
timestamp: new Date().toUTCString(), timestamp: new Date().toUTCString(),
json: JSON.stringify([ json: JSON.stringify([

View File

@ -5,7 +5,7 @@
import debug from 'debug'; import debug from 'debug';
import defaultsDeep from 'lodash.defaultsdeep'; import defaultsDeep from 'lodash.defaultsdeep';
import { addonResolvers } from './addons'; import { extensionResolvers } from './extensions';
import { ipfsResolvers } from './ipfs'; import { ipfsResolvers } from './ipfs';
import { systemResolvers } from './system'; import { systemResolvers } from './system';
import { logResolvers } from './log'; import { logResolvers } from './log';
@ -23,4 +23,4 @@ export const resolvers = defaultsDeep({
// TODO(burdon): Auth. // TODO(burdon): Auth.
// https://www.apollographql.com/docs/apollo-server/data/errors/#codes // https://www.apollographql.com/docs/apollo-server/data/errors/#codes
}, ipfsResolvers, systemResolvers, logResolvers, botsResolvers, addonResolvers); }, ipfsResolvers, systemResolvers, logResolvers, botsResolvers, extensionResolvers);