Skip to content

Commit

Permalink
Fix Swagger-related bug, tweak sidebar styles for better readability
Browse files Browse the repository at this point in the history
Also, make `/admin` a proper redirect to `/admin/apis` instead of
letting it just be an alias.
  • Loading branch information
amazon-meaisiah committed Mar 5, 2020
1 parent 18d4de4 commit 7bf1f77
Show file tree
Hide file tree
Showing 13 changed files with 32,699 additions and 84 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dev-portal/node_modules/swagger-ui/dist/swagger-ui.css

Large diffs are not rendered by default.

32,630 changes: 32,626 additions & 4 deletions dev-portal/node_modules/swagger-ui/dist/swagger-ui.js

Large diffs are not rendered by default.

31 changes: 12 additions & 19 deletions dev-portal/node_modules/swagger-ui/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 4 additions & 37 deletions dev-portal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react-router-dom": "^4.3.1",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.87.3",
"swagger-ui": "git@github.com:amazon-meaisiah/swagger-ui.git#a70073c0df9bb3919ce77b64c94fe49f0171775e",
"swagger-ui": "git@github.com:amazon-meaisiah/swagger-ui.git#66cbe58352bc2455ea80ff99573fe06dee273f56",
"yamljs": "^0.3.0"
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions dev-portal/src/components/ApisMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default observer(function ApisMenu (props) {

function GenericApiSubsection ({ title, listOfApis, selectedApiId }) {
return (
<>
<Menu inverted vertical borderless attached style={{ flex: '0 0 auto', width: 'auto' }}>
<Menu.Header
style={{
padding: '13px 5px 13px 16px',
Expand All @@ -78,13 +78,13 @@ function GenericApiSubsection ({ title, listOfApis, selectedApiId }) {
{api.swagger.info.title}
</Menu.Item>
))}
</>
</Menu>
)
}

function ApiSubsection ({ title, listOfApis, selectedApiId, selectedStage = false }) {
return (
<>
<Menu inverted vertical borderless attached style={{ flex: '0 0 auto', width: 'auto' }}>
<Menu.Header
style={{
padding: '13px 5px 13px 16px',
Expand All @@ -103,6 +103,6 @@ function ApiSubsection ({ title, listOfApis, selectedApiId, selectedStage = fals
{api.swagger.info.title}
</Menu.Item>
))}
</>
</Menu>
)
}
2 changes: 1 addition & 1 deletion dev-portal/src/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const NavBar = observer(
return isAuthenticated() ? (
<Menu.Menu position='right'>
{isAdmin() && (
<Menu.Item as={Link} to='/admin'>
<Menu.Item as={Link} to='/admin/apis'>
Admin Panel
</Menu.Item>
)}
Expand Down
9 changes: 9 additions & 0 deletions dev-portal/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ h1, h2, h3, h4, h5 {
0px 0px 0px 1px #E0B4B4 inset,
0px 2px 4px 0px rgba(34, 36, 38, 0.12),
0px 2px 10px 0px rgba(34, 36, 38, 0.15)
}

.ui.vertical.menu .menu .item {
font-size: 0.9em;
}

.ui.vertical.menu .menu .menu .item {
margin-left: 1em;
font-size: 1em;
}
8 changes: 6 additions & 2 deletions dev-portal/src/pages/Admin/Admin.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { BrowserRouter as Router } from 'react-router-dom'
import { BrowserRouter as Router, Redirect } from 'react-router-dom'

import { ApiManagement, SideNav } from './'
import { AdminRoute } from './../../'
Expand All @@ -10,13 +10,17 @@ import AdminAccounts from 'pages/Admin/Accounts/AdminAccounts'
import PendingInvites from 'pages/Admin/Accounts/PendingInvites'
import PendingRequests from 'pages/Admin/Accounts/PendingRequests'

function RedirectToApiManagement() {
return <Redirect to='/admin/apis' />
}

export class Admin extends Component {
render () {
return (
<Router>
<PageWithSidebar sidebarContent={<SideNav />}>
<>
<AdminRoute exact path='/admin' component={ApiManagement} />
<AdminRoute exact from='/admin' component={RedirectToApiManagement} />
<AdminRoute path='/admin/apis' component={ApiManagement} />
<AdminRoute exact path='/admin/accounts' component={RegisteredAccounts} />
<AdminRoute exact path='/admin/accounts/admins' component={AdminAccounts} />
Expand Down
15 changes: 12 additions & 3 deletions dev-portal/src/pages/Admin/SideNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ import { Menu } from 'semantic-ui-react'
export const SideNav = observer(() => (
isAdmin() &&
(<Menu inverted vertical borderless attached style={{ flex: '0 0 auto' }}>
<Menu.Item as={Link} to='/admin/apis'>APIs</Menu.Item>
<Menu.Item as={Link} to='/admin/accounts'>
Accounts
<Menu.Header
style={{
padding: '13px 5px 13px 16px',
color: 'lightsteelblue'
}
}>
Admin
</Menu.Header>
{/* The class name here is to avoid a selector precedence issue */}
<Menu.Item className='link' as={Link} to='/admin/apis'>APIs</Menu.Item>
<Menu.Item className='link'>
<Link to='/admin/accounts' style={{ color: 'inherit' }}>Accounts</Link>
<Menu.Menu>
<Menu.Item as={Link} to='/admin/accounts/admins'>
Admins
Expand Down
10 changes: 7 additions & 3 deletions dev-portal/src/pages/Apis.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@ import { store } from 'services/state.js'
import { observer } from 'mobx-react'

export default observer(class ApisPage extends React.Component {
containerRef = React.createRef()
removed = false

componentDidMount () { this.updateApi().then(() => updateUsagePlansAndApisList(true)) }
componentDidUpdate () { this.updateApi() }
componentWillUnmount () { this.removed = true }

updateApi () {
return getApi(this.props.match.params.apiId || 'ANY', true, this.props.match.params.stage)
.then(api => {
if (api) {
if (api && !this.removed) {
const cell = {
shouldPreauthorizeApiKey: false,
preauthorizeApiKey: () => {
cell.shouldPreauthorizeApiKey = true
}
}
const swaggerUiConfig = {
dom_id: '#swagger-ui-container',
domNode: this.containerRef.current,
plugins: [SwaggerLayoutPlugin],
supportedSubmitMethods: [],
spec: api.swagger,
Expand Down Expand Up @@ -80,7 +84,7 @@ export default observer(class ApisPage extends React.Component {
sidebarContent={<ApisMenu path={this.props.match} />}
SidebarPusherProps={{ className: 'swagger-section' }}
>
<div className='swagger-ui-wrap' id='swagger-ui-container' style={{ padding: '0 20px' }}>
<div className='swagger-ui-wrap' ref={this.containerRef} style={{ padding: '0 20px' }}>
{errorHeader && errorBody && (
<>
<Header as='h2' icon textAlign='center' style={{ padding: '40px 0px' }}>
Expand Down

0 comments on commit 7bf1f77

Please sign in to comment.