feat(navigation): add support for account services

This commit is contained in:
Sérgio Ramos 2018-04-06 14:44:08 +01:00 committed by Joao Tiago
parent c413677b0e
commit 95e420c419
8 changed files with 214 additions and 39 deletions

20
bundle/data/account.js Normal file
View File

@ -0,0 +1,20 @@
module.exports = [
{
name: 'Logout',
slug: 'logout',
description: 'Do the daggum logout',
url: '/logout'
},
{
name: 'Change Password',
slug: 'change-password',
description: 'Change yer own password',
url: '/password'
},
{
name: 'Account',
slug: 'account',
description: 'Your account information',
url: '/account'
}
];

View File

@ -12,7 +12,7 @@ const Fs = require('fs');
const { PORT = 4000 } = process.env;
const ROOT = Path.join(__dirname, 'src');
const calcPort = (i) => Number(PORT) + Number(i) + 1;
const calcPort = i => Number(PORT) + Number(i) + 1;
const namespaces = Fs.readdirSync(ROOT)
.filter(filename => /.js$/.test(filename))

View File

@ -22,7 +22,7 @@
"h2o2": "^8.0.1",
"hapi": "^17.3.1",
"hapi-triton-auth": "^2.0.1",
"hapi-webconsole-nav": "^1.1.1",
"hapi-webconsole-nav": "^1.2.0",
"inert": "^5.1.0",
"my-joy-images": "*",
"my-joy-instances": "*",

View File

@ -5,6 +5,7 @@ const Server = require('./server');
const Regions = require('../data/regions');
const Categories = require('../data/categories');
const Account = require('../data/account');
const {
PORT = 4001,
@ -38,6 +39,7 @@ Main(async () => {
dcName,
baseUrl,
regions: Regions,
accountServices: Account,
categories: Categories
},
routes: {

View File

@ -46,14 +46,7 @@
"resolutions": {
"axios": "0.16.2",
"follow-redirects": "1.4.1",
"debug": "3.1.0",
"chalk": "2.1.0",
"minimist": "1.2.0",
"node-fetch": "2.1.1",
"ansi-styles": "3.2.1",
"strip-ansi": "4.0.0",
"supports-color": "4.5.0",
"ansi-regex": "3.0.0",
"core-js": "2.5.4",
"regenerator-runtime": "0.11.1",
"pify": "3.0.0",
@ -63,13 +56,7 @@
"react": "16.3.1",
"breeze-nexttick": "0.2.1",
"isarray": "1.0.0",
"boom": "7.2.0",
"lru-cache": "4.1.2",
"uuid": "3.0.1",
"extsprintf": "1.0.1"
"uuid": "3.0.1"
},
"workspaces": [
"packages/*",
"bundle"
]
"workspaces": ["packages/*", "bundle"]
}

View File

@ -1,11 +1,49 @@
import React from 'react';
import get from 'lodash.get';
import emotion from 'preact-emotion';
import { graphql, compose } from 'react-apollo';
import gql from 'graphql-tag';
import { Anchor, Popover } from '../components';
const Account = ({ expanded }) =>
expanded ? (
<Popover>
<Anchor href="/navigation/logout">Log Out</Anchor>
</Popover>
) : null;
const Ul = emotion('ul')`
list-style-type: none;
padding: 0;
margin: 0;
`;
export default Account;
const GetAccountServices = gql`
{
account {
services {
name
url
}
}
}
`;
const Account = ({ expanded, services = [] }) => {
return !expanded ? null : (
<Popover>
<Ul>
{services.map(({ name, url }) => (
<li>
<Anchor href={url}>{name}</Anchor>
</li>
))}
</Ul>
</Popover>
);
};
export default compose(
graphql(GetAccountServices, {
options: () => ({
ssr: false
}),
props: ({ data }) => ({
services: get(data, 'account.services', [])
})
})
)(Account);

View File

@ -6,6 +6,7 @@ import remcalc from 'remcalc';
import groupBy from 'lodash.groupby';
import { Grid, Row, Col } from 'preact-emotion-flexboxgrid';
import {
DatacenterPlace,
DatacenterRegion,

157
yarn.lock
View File

@ -480,11 +480,19 @@ ansi-html@0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
ansi-regex@3.0.0, ansi-regex@^2.0.0, ansi-regex@^2.1.1, ansi-regex@^3.0.0:
ansi-regex@^2.0.0, ansi-regex@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
ansi-styles@3.2.1, ansi-styles@^3.0.0, ansi-styles@^3.1.0, ansi-styles@^3.2.0:
ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
ansi-styles@^3.0.0, ansi-styles@^3.1.0, ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
dependencies:
@ -1963,7 +1971,37 @@ boolbase@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
boom@2.x.x, boom@4.x.x, boom@5.x.x, boom@6.x.x, boom@7.1.x, boom@7.2.0, boom@7.x.x:
boom@2.x.x:
version "2.10.1"
resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f"
dependencies:
hoek "2.x.x"
boom@4.x.x:
version "4.3.1"
resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31"
dependencies:
hoek "4.x.x"
boom@5.x.x:
version "5.2.0"
resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02"
dependencies:
hoek "4.x.x"
boom@6.x.x:
version "6.0.0"
resolved "https://registry.yarnpkg.com/boom/-/boom-6.0.0.tgz#9b36c52a12afab3f0e55536131b7fd5021aad0cc"
dependencies:
hoek "5.x.x"
boom@7.1.x:
version "7.1.1"
resolved "https://registry.yarnpkg.com/boom/-/boom-7.1.1.tgz#50392a4e3417e971f1ad28622c20e832275260bb"
dependencies:
hoek "5.x.x"
boom@7.x.x:
version "7.2.0"
resolved "https://registry.yarnpkg.com/boom/-/boom-7.2.0.tgz#2bff24a55565767fde869ec808317eb10c48e966"
dependencies:
@ -2375,7 +2413,17 @@ center-align@^0.1.1:
align-text "^0.1.3"
lazy-cache "^1.0.3"
chalk@1.1.3, chalk@2.1.0, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2:
chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
dependencies:
ansi-styles "^2.2.1"
escape-string-regexp "^1.0.2"
has-ansi "^2.0.0"
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@2.1.0, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
dependencies:
@ -2383,6 +2431,14 @@ chalk@1.1.3, chalk@2.1.0, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"
chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
character-entities-html4@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/character-entities-html4/-/character-entities-html4-1.1.1.tgz#359a2a4a0f7e29d3dc2ac99bdbe21ee39438ea50"
@ -3366,7 +3422,13 @@ dateformat@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
debug@2.6.9, debug@3.1.0, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9, debug@^3.0.0, debug@^3.0.1, debug@^3.1.0:
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"
debug@^3.0.0, debug@^3.0.1, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
@ -3894,7 +3956,7 @@ escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5:
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@ -4413,10 +4475,22 @@ extract-zip@^1.6.5:
mkdirp "0.5.0"
yauzl "2.4.1"
extsprintf@1.0.0, extsprintf@1.0.1, extsprintf@1.3.0, extsprintf@^1.2.0:
extsprintf@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.0.tgz#4d58b815ace5bebfc4ebf03cf98b0a7604a99b86"
extsprintf@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.1.tgz#590e147d5c59e2180b3366f7bc21acabaf69a185"
extsprintf@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
extsprintf@^1.2.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
facet@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/facet/-/facet-0.3.0.tgz#1bf949d8a112e2045dda84259407def3deb62c1b"
@ -5158,13 +5232,14 @@ hapi-triton-auth@^2.0.1:
hoek "5.0.x"
wreck "14.0.x"
hapi-webconsole-nav@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/hapi-webconsole-nav/-/hapi-webconsole-nav-1.1.1.tgz#d84b16b3e2f0ec746e4071987327ac773b0a9e31"
hapi-webconsole-nav@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/hapi-webconsole-nav/-/hapi-webconsole-nav-1.2.0.tgz#aad402a75c24754944c77ead534e8ad488c61237"
dependencies:
boom "7.x.x"
bounce "1.x.x"
graphi "5.5.x"
webconsole-cloudapi-client "1.x.x"
wreck "14.x.x"
hapi@^17.3.1:
@ -5211,7 +5286,13 @@ har-validator@~5.0.3:
ajv "^5.1.0"
har-schema "^2.0.0"
has-flag@2.0.0, has-flag@^2.0.0:
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
dependencies:
ansi-regex "^2.0.0"
has-flag@2.0.0, has-flag@^1.0.0, has-flag@^2.0.0, has-flag@^3.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"
@ -7059,13 +7140,17 @@ lowercase-keys@^1.0.0, lowercase-keys@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f"
lru-cache@4.1.2, lru-cache@4.1.x, lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@~2.2.1:
lru-cache@4.1.x, lru-cache@^4.0.1, lru-cache@^4.1.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.2.tgz#45234b2e6e2f2b33da125624c4664929a0224c3f"
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
lru-cache@~2.2.1:
version "2.2.4"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d"
lunr@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.1.6.tgz#671d2321c4c5bc4c522914953d1c54d612f60aa7"
@ -7333,10 +7418,22 @@ minimist-options@^3.0.1:
arrify "^1.0.1"
is-plain-obj "^1.1.0"
minimist@0.0.8, minimist@1.2.0, minimist@^0.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@~0.0.1:
minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
minimist@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.1.0.tgz#99df657a52574c21c9057497df742790b2b4c0de"
minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
mississippi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-2.0.0.tgz#3442a508fafc28500486feea99409676e4ee5a6f"
@ -10255,7 +10352,13 @@ stringstream@~0.0.4, stringstream@~0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878"
strip-ansi@3.0.1, strip-ansi@4.0.0, strip-ansi@^3.0.0, strip-ansi@^3.0.1, strip-ansi@^4.0.0:
strip-ansi@3.0.1, strip-ansi@^3.0.0, strip-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
dependencies:
ansi-regex "^2.0.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
dependencies:
@ -10367,12 +10470,28 @@ subtext@6.x.x:
pez "4.x.x"
wreck "14.x.x"
supports-color@4.5.0, supports-color@^3.1.2, supports-color@^3.2.3, supports-color@^4.0.0, supports-color@^4.2.1, supports-color@^5.1.0, supports-color@^5.3.0:
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
supports-color@^3.1.2, supports-color@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
dependencies:
has-flag "^1.0.0"
supports-color@^4.0.0, supports-color@^4.2.1:
version "4.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b"
dependencies:
has-flag "^2.0.0"
supports-color@^5.1.0, supports-color@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0"
dependencies:
has-flag "^3.0.0"
svgo@^0.7.0:
version "0.7.2"
resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5"
@ -11201,6 +11320,14 @@ wcwidth@^1.0.0, wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"
webconsole-cloudapi-client@1.x.x:
version "1.0.0"
resolved "https://registry.yarnpkg.com/webconsole-cloudapi-client/-/webconsole-cloudapi-client-1.0.0.tgz#af14eaf103c71435fa65ea81e5a0562cbc3faf3f"
dependencies:
boom "7.x.x"
bounce "1.2.x"
wreck "14.x.x"
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"