From f3a50b4aaf182764c626448e814aae6205cca671 Mon Sep 17 00:00:00 2001 From: Rich Burdon Date: Thu, 10 Dec 2020 14:03:15 -0500 Subject: [PATCH] Rename addons => extensions (#59) UX sidebar --- .../console-app/src/components/Sidebar.js | 22 ++++++++++--------- ...{addon_list.graphql => extensions.graphql} | 2 +- packages/console-app/src/version.json | 4 ++-- packages/console-server/src/gql/api.graphql | 2 +- .../resolvers/{addons.js => extensions.js} | 9 +++++--- .../console-server/src/resolvers/index.js | 4 ++-- 6 files changed, 24 insertions(+), 19 deletions(-) rename packages/console-app/src/gql/{addon_list.graphql => extensions.graphql} (78%) rename packages/console-server/src/resolvers/{addons.js => extensions.js} (80%) diff --git a/packages/console-app/src/components/Sidebar.js b/packages/console-app/src/components/Sidebar.js index 80a9337..663662b 100644 --- a/packages/console-app/src/components/Sidebar.js +++ b/packages/console-app/src/components/Sidebar.js @@ -13,8 +13,9 @@ import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import LinkIcon from '@material-ui/icons/ExitToApp'; import ListItemText from '@material-ui/core/ListItemText'; + +import EXTENSIONS from '../gql/extensions.graphql'; import { useQueryStatusReducer } from '../hooks'; -import ADDON_LIST from '../gql/addon_list.graphql'; const useStyles = makeStyles(theme => ({ root: { @@ -35,6 +36,10 @@ const useStyles = makeStyles(theme => ({ selected: { color: theme.palette.primary.main + }, + + expand: { + flex: 1 } })); @@ -43,12 +48,8 @@ const Sidebar = ({ modules: { services, settings } }) => { const history = useHistory(); const { module } = useParams(); - const { data: addonResponse } = useQueryStatusReducer(useQuery(ADDON_LIST)); - console.log(addonResponse); - if (!addonResponse) { - return null; - } - const addons = JSON.parse(addonResponse.addon_list.json); + const { data: extensionsData } = useQueryStatusReducer(useQuery(EXTENSIONS)); + const extensions = extensionsData ? JSON.parse(extensionsData.extensions.json) : []; const isSelected = path => path === `/${module}`; @@ -65,9 +66,9 @@ const Sidebar = ({ modules: { services, settings } }) => { ); - const Addons = ({ addons }) => ( + const Extensions = ({ extensions }) => ( - {addons.map(({ url, title }) => ( + {extensions.map(({ url, title }) => ( { window.location = url; return true; }}> @@ -81,7 +82,8 @@ const Sidebar = ({ modules: { services, settings } }) => { return (
- + +
); diff --git a/packages/console-app/src/gql/addon_list.graphql b/packages/console-app/src/gql/extensions.graphql similarity index 78% rename from packages/console-app/src/gql/addon_list.graphql rename to packages/console-app/src/gql/extensions.graphql index 3079e1c..d6c1594 100644 --- a/packages/console-app/src/gql/addon_list.graphql +++ b/packages/console-app/src/gql/extensions.graphql @@ -3,7 +3,7 @@ # query { - addon_list { + extensions { json } } diff --git a/packages/console-app/src/version.json b/packages/console-app/src/version.json index 3d6b114..316e61c 100644 --- a/packages/console-app/src/version.json +++ b/packages/console-app/src/version.json @@ -1,7 +1,7 @@ { "build": { "name": "@dxos/console-app", - "buildDate": "2020-12-10T09:59:41.380Z", - "version": "1.2.6-alpha.1" + "buildDate": "2020-12-10T18:33:21.012Z", + "version": "1.2.6-alpha.2" } } diff --git a/packages/console-server/src/gql/api.graphql b/packages/console-server/src/gql/api.graphql index 4f844b2..056a011 100644 --- a/packages/console-server/src/gql/api.graphql +++ b/packages/console-server/src/gql/api.graphql @@ -22,7 +22,7 @@ type Query { system_status: JSONResult! wns_status: JSONResult! bot_list: JSONResult! - addon_list: JSONResult! + extensions: JSONResult! } type Mutation { diff --git a/packages/console-server/src/resolvers/addons.js b/packages/console-server/src/resolvers/extensions.js similarity index 80% rename from packages/console-server/src/resolvers/addons.js rename to packages/console-server/src/resolvers/extensions.js index 775a695..75c1118 100644 --- a/packages/console-server/src/resolvers/addons.js +++ b/packages/console-server/src/resolvers/extensions.js @@ -9,7 +9,10 @@ const ifRadicle = () => { try { const result = childProcess.execSync('docker ps -f "ancestor=dxos/radicle-seed-node" -q'); if (result && result.toString()) { - return { title: 'Radicle', url: '/radicle/' }; + return { + title: 'Radicle', + url: '/radicle/' + }; } } catch (e) {} }; @@ -22,9 +25,9 @@ const ifSentry = () => { }; }; -export const addonResolvers = { +export const extensionResolvers = { Query: { - addon_list: async (_, __, { config }) => { + extensions: async (_, __, { config }) => { return { timestamp: new Date().toUTCString(), json: JSON.stringify([ diff --git a/packages/console-server/src/resolvers/index.js b/packages/console-server/src/resolvers/index.js index 05f31bd..6866832 100644 --- a/packages/console-server/src/resolvers/index.js +++ b/packages/console-server/src/resolvers/index.js @@ -5,7 +5,7 @@ import debug from 'debug'; import defaultsDeep from 'lodash.defaultsdeep'; -import { addonResolvers } from './addons'; +import { extensionResolvers } from './extensions'; import { ipfsResolvers } from './ipfs'; import { systemResolvers } from './system'; import { logResolvers } from './log'; @@ -23,4 +23,4 @@ export const resolvers = defaultsDeep({ // TODO(burdon): Auth. // https://www.apollographql.com/docs/apollo-server/data/errors/#codes -}, ipfsResolvers, systemResolvers, logResolvers, botsResolvers, addonResolvers); +}, ipfsResolvers, systemResolvers, logResolvers, botsResolvers, extensionResolvers);