Skip to content

Commit

Permalink
Merge pull request #357 from awslabs/meaisiah-stage-names
Browse files Browse the repository at this point in the history
Show stage names with APIs
  • Loading branch information
amazon-meaisiah authored Mar 6, 2020
2 parents 56c8e05 + 3a877c3 commit a7ae0c6
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions dev-portal/src/components/ApisMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,30 @@ function GenericApiSubsection ({ title, listOfApis, selectedApiId }) {
>
{title}
</Menu.Header>
{listOfApis.map(api => (
{_.toPairs(_.groupBy(listOfApis, api => api.apiId || api.id)).map(([id, apis]) => (
<Menu.Item
key={api.id}
as={Link}
to={`/apis/${api.id}`}
active={isActive(api.id.toString(), selectedApiId.toString())}
key={id}
className='link'
active={apis.some(api => isActive(`${api.id}`, `${selectedApiId}`))}
>
{api.swagger.info.title}
{apis[0].swagger.info.title}
{apis.length === 1 ? (
apis[0].stage != null ? ` (${apis[0].stage})` : null
) : (
<Menu.Menu>
{apis.map(api => (
<Menu.Item
key={api.id}
as={Link}
to={`/apis/${api.id}`}
active={isActive(api.id, `${selectedApiId}`)}
style={{ 'font-weight': '400' }}
>
{api.stage}
</Menu.Item>
))}
</Menu.Menu>
)}
</Menu.Item>
))}
</Menu>
Expand All @@ -93,14 +109,28 @@ function ApiSubsection ({ title, listOfApis, selectedApiId, selectedStage = fals
>
{title}
</Menu.Header>
{listOfApis.map(api => (
{_.toPairs(_.groupBy(listOfApis, "id")).map(([id, apis]) => (
<Menu.Item
key={`${api.id}_${api.stage}`}
as={Link}
to={`/apis/${api.id}/${api.stage}`}
active={isActive(api.id.toString(), selectedApiId.toString(), api.stage.toString(), selectedStage)}
key={id}
className='link'
active={isActive(id, `${selectedApiId}`)}
>
{api.swagger.info.title}
{apis[0].swagger.info.title}
{apis.length === 1 ? ` (${apis[0].stage})` : (
<Menu.Menu>
{apis.map(api => (
<Menu.Item
key={`${id}_${api.stage}`}
as={Link}
to={`/apis/${id}/${api.stage}`}
active={isActive(id, `${selectedApiId}`, `${api.stage}`, selectedStage)}
style={{ 'font-weight': '400' }}
>
{api.stage}
</Menu.Item>
))}
</Menu.Menu>
)}
</Menu.Item>
))}
</Menu>
Expand Down

0 comments on commit a7ae0c6

Please sign in to comment.