Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide subscribe button if an API doesn't have a usage plan #402

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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