Skip to content

Commit

Permalink
hide subscribe button if an API doesn't have a usage plan
Browse files Browse the repository at this point in the history
  • Loading branch information
MynockSpit committed Jun 8, 2020
1 parent 8834e25 commit b7df128
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dev-portal/src/components/SwaggerUiLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,24 @@ function InfoReplacement ({ specSelectors }) {
const SubscriptionButtons = observer(class SubscriptionButtons extends React.Component {
render () {
const { api } = store
return (
(api && isAuthenticated()) ? api.apiStage != null ? (

if (!api || !isAuthenticated()) {
return null
}

const apiIsSubscribable = !!(api && api.apiStage && api.usagePlan)

if (apiIsSubscribable) {
return (
api.subscribed ? (
<Button onClick={() => unsubscribe(api.usagePlan.id)}>Unsubscribe</Button>
) : (
<Button onClick={() => subscribe(api.usagePlan.id)}>Subscribe</Button>
)
) : <Header style={{ marginTop: '0em' }} as='h4' color='grey'>This version of the API is not configured to be subscribable from the portal. Please contact an admin for more details.</Header> : null
)
)
} else {
return <Header style={{ marginTop: '0em' }} as='h4' color='grey'>This version of the API is not configured to be subscribable from the portal. Please contact an admin for more details.</Header>
}
}
})

Expand Down

0 comments on commit b7df128

Please sign in to comment.