Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: 🐛 fixed variant doc links in the wizard
Browse files Browse the repository at this point in the history
The wizard was always pointing to android docs
  • Loading branch information
ziccardi authored and secondsun committed Sep 16, 2020
1 parent 37db56c commit 4e55993
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/application/ApplicationDetail/SenderAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class SenderAPI extends Component<Props, State> {
<Text component={'small'}>
First add{' '}
<code className={'code'}>unifiedpush-java-client.jar</code> as a{' '}
<a href={'links.pushApplications.senderAPI.docs.java_client'}>
<a href={getLink('sender-api-java')}>
dependency to your Java project
</a>
.
Expand Down Expand Up @@ -149,7 +149,7 @@ export class SenderAPI extends Component<Props, State> {
<Tab eventKey={'node-sender-api'} title="Node.js Sender API">
<Title headingLevel={'h1'}>Set up Node.js Sender API</Title>
<Text component={'small'}>
First add <code className={'code'}>unifiedpush-jnode-sender</code>{' '}
First add <code className={'code'}>unifiedpush-node-sender</code>{' '}
as a{' '}
<a href={getLink('sender-api-nodejs')}>
dependency to your project
Expand Down
82 changes: 40 additions & 42 deletions src/application/wizard/SetupPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, ReactNode } from 'react';
import React, { Component } from 'react';
import {
TextContent,
Text,
Expand Down Expand Up @@ -37,6 +37,41 @@ export class SetupPage extends Component<Props> {
const context = this.context as ContextInterface;
const getLink = (key: string) => _getLink(context.upsConfig, key);

const getCodeSnippet = () => {
switch (context.selectedVariant?.type) {
case 'android':
return (
<AndroidCodeSnippets
app={this.props.app}
variant={context.selectedVariant! as AndroidVariant}
/>
);
case 'web_push':
return (
<WebPushCodeSnippets
app={this.props.app}
variant={context.selectedVariant! as WebPushVariant}
/>
);
case 'ios':
return (
<IOSCertCodeSnippets
app={this.props.app}
variant={context.selectedVariant! as IOSVariant}
/>
);
case 'ios_token':
return (
<IOSTokenCodeSnippets
app={this.props.app}
variant={context.selectedVariant! as IOSTokenVariant}
/>
);
default:
return <></>;
}
};

return (
<>
<Page>
Expand Down Expand Up @@ -68,52 +103,15 @@ export class SetupPage extends Component<Props> {
<TextListItem>Click Next(below)</TextListItem>
</TextList>
</TextContent>
<ApplicationListContext.Consumer>
{({ selectedVariant }: ContextInterface): ReactNode => {
if (selectedVariant?.type === 'android') {
return (
<AndroidCodeSnippets
app={this.props.app}
variant={selectedVariant! as AndroidVariant}
/>
);
}
if (selectedVariant?.type === 'web_push') {
return (
<WebPushCodeSnippets
app={this.props.app}
variant={selectedVariant! as WebPushVariant}
/>
);
}
if (selectedVariant?.type === 'ios') {
return (
<IOSCertCodeSnippets
app={this.props.app}
variant={selectedVariant! as IOSVariant}
/>
);
}
if (selectedVariant?.type === 'ios_token') {
return (
<IOSTokenCodeSnippets
app={this.props.app}
variant={selectedVariant! as IOSTokenVariant}
/>
);
}

return () => {
console.log('missing code snippets');
};
}}
</ApplicationListContext.Consumer>
{getCodeSnippet()}
<TextContent>
<Text component={TextVariants.p}>
Next we are going to send a test notification. Make sure you {''}
<Text
component={TextVariants.a}
href={getLink('build-and-deploy-android')}
href={getLink(
`build-and-deploy-${context.selectedVariant?.type}`
)}
>
build or deploy your app
</Text>
Expand Down

0 comments on commit 4e55993

Please sign in to comment.