Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #208 Add sign out uri(s) field in app form (#222)
Browse files Browse the repository at this point in the history
* feat: #208 Add sign out uri field in app form

* feat: #208 Update type definition
trankhacvy authored Feb 11, 2020
1 parent 46bdce7 commit 2b88221
Showing 10 changed files with 91 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -71,6 +71,10 @@ export interface AppDetailModel {
* Gets the app revisions redirect uri (or uris) where a user will be redirected to immediately after a successful authentication
*/
redirectUris?: string[]
/**
* Gets the app revisions signout uri (or uris) where a user will be redirected to immediately after a successful logout
*/
signoutUris?: string[]
/**
* Gets the date the app was installed for a specific client
*/
@@ -168,6 +172,10 @@ export interface AppRevisionModel {
* Gets the app revisions redirect uri (or uris) where a user will be redirected to immediately after a successful authentication
*/
redirectUris?: string[]
/**
* Gets the app revisions signout uri (or uris) where a user will be redirected to immediately after a successful logout
*/
signoutUris?: string[]
/**
* Gets the listed status of the app revision
*/
@@ -387,10 +395,14 @@ export interface CreateAppModel {
* Sets the apps launch uri
*/
launchUri?: string
/**
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed as a comma separated list
/**
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed in the array
*/
redirectUris?: string[]
/**
* Set the apps uri where a user will be redirected to immediately after a session is logged out. Multiple URIs can be passed in the array
*/
signoutUris?: string[]
/**
* Sets the unique identifer of the developer registering the app
*/
@@ -509,9 +521,13 @@ export interface CreateAppRevisionModel {
*/
launchUri?: string
/**
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed as a comma separated list
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed in the array
*/
redirectUris?: string[]
/**
* Set the apps uri where a user will be redirected to immediately after a session is logged out. Multiple URIs can be passed in the array
*/
signoutUris?: string[]
/**
* Sets the listed status of the app
* When false, the app will not be visible in marketplace app listings
4 changes: 2 additions & 2 deletions packages/foundations-ts-definitions/types/platform-schema.ts
Original file line number Diff line number Diff line change
@@ -1422,12 +1422,12 @@ export interface Contacts {
NegotiatorId?: string[]
OfficeId?: string[]
Address?: string
IdentityCheck?: string
Name?: string
MarketingConsent?: string
Active?: boolean
CreatedFrom?: string
CreatedTo?: string
IdentityCheck?: ('pass' | 'fail' | 'pending' | 'warnings' | 'unchecked')[]
MarketingConsent?: ('grant' | 'deny' | 'notAsked')[]
}
/**
* The details specific to applicants with a marketingMode of buying
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ exports[`DeveloperSubmitApp should match a snapshot 1`] = `
"screen3ImageUrl": "",
"screen4ImageUrl": "",
"screen5ImageUrl": "",
"signoutUris": "",
"summary": "",
"supportEmail": "",
"telephone": "",
@@ -93,6 +94,7 @@ exports[`DeveloperSubmitApp should match submit revision form snapshot 1`] = `
],
"screen1ImageUrl": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png",
"screen2ImageUrl": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png",
"signoutUris": "",
"summary": "vitae elementum curabitur vitae nunc sed velit eget gravida cum sociis natoque!!",
"supportEmail": "[email protected]",
"telephone": "0113 288 2900",
32 changes: 29 additions & 3 deletions packages/marketplace/src/components/pages/developer-submit-app.tsx
Original file line number Diff line number Diff line change
@@ -43,7 +43,10 @@ import { selectCategories } from '../../selector/app-categories'
import styles from '@/styles/pages/developer-submit-app.scss?mod'
import { TermsAndConditionsModal } from '../ui/terms-and-conditions-modal'

export type CustomCreateAppModel = Omit<CreateAppModel, 'redirectUris'> & { redirectUris?: string }
export type CustomCreateAppModel = Omit<CreateAppModel, 'redirectUris' | 'signoutUris'> & {
redirectUris?: string
signoutUris?: string
}

export interface SubmitAppMappedActions {
submitApp: (
@@ -102,6 +105,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
isDirectApi,
scopes: appScopes,
redirectUris = [],
signoutUris = [],
} = appDetail

const icon = (media || []).filter(({ order }) => order === 0)[0]
@@ -128,6 +132,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
isDirectApi,
scopes: appScopes ? appScopes.map(item => item.name) : [],
redirectUris: redirectUris.join(','),
signoutUris: signoutUris.join(','),
...images,
}
} else {
@@ -150,6 +155,7 @@ export const generateInitialValues = (appDetail: AppDetailModel | null, develope
developerId,
scopes: [],
redirectUris: '',
signoutUris: '',
}
}

@@ -170,15 +176,23 @@ export const handleSubmitApp = ({
}
if (!appId) {
submitApp(
{ ...appModel, redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [] },
{
...appModel,
redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [],
signoutUris: appModel.signoutUris ? appModel.signoutUris.split(',') : [],
},
actions,
setSubmitError,
)
} else {
if (appModel.authFlow) {
delete appModel.authFlow
}
submitRevision(appId, { ...appModel, redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [] })
submitRevision(appId, {
...appModel,
redirectUris: appModel.redirectUris ? appModel.redirectUris.split(',') : [],
signoutUris: appModel.signoutUris ? appModel.signoutUris.split(',') : [],
})
}
}

@@ -387,6 +401,18 @@ export const SubmitApp: React.FC<SubmitAppProps> = ({
/>
</GridItem>
</Grid>
<Grid>
<GridItem>
<Input
dataTest="submit-app-signout-uris"
type="text"
labelText="Sign Out URI(s)"
id="signoutUris"
name="signoutUris"
placeholder="Enter the URI that your application should navigate to when a user logs out. For multiple URI's, separate using a comma. HTTPS other than for http://localhost"
/>
</GridItem>
</Grid>
<Grid>
<GridItem>
<TextArea
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/marketplace/src/utils/form/__tests__/submit-app.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ describe('submitAppValidation', () => {
summary: '',
scopes: [],
redirectUris: '',
signoutUris: '',
}

const validateRequiredKeys = [
@@ -32,6 +33,7 @@ describe('submitAppValidation', () => {
'screen1ImageUrl',
'summary',
'redirectUris',
'signoutUris',
]

const output = {}
@@ -58,6 +60,7 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({
@@ -81,13 +84,38 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'http://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({
redirectUris: 'Invalid redirect uri(s)',
})
})

it('validate sign out uri(s) field ', () => {
const input: CustomCreateAppModel = {
screen4ImageUrl: 'test',
screen3ImageUrl: 'test',
screen2ImageUrl: 'test',
screen1ImageUrl: 'test',
name: 'test',
telephone: 'test',
supportEmail: '[email protected]',
launchUri: 'test',
iconImageUrl: 'test',
homePage: 'test',
description: 'test',
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'https://localhost:8080',
}

expect(validate(input)).toEqual({
signoutUris: 'Invalid sign out uri(s)',
})
})

it('return empty object it everything is valid', () => {
const input: CustomCreateAppModel = {
screen4ImageUrl: 'test',
@@ -104,6 +132,7 @@ describe('submitAppValidation', () => {
summary: 'test',
scopes: [],
redirectUris: 'https://google.com,https://twitter.com,http://localhost:8080',
signoutUris: 'http://localhost:8080',
}

expect(validate(input)).toEqual({})
6 changes: 6 additions & 0 deletions packages/marketplace/src/utils/form/submit-app.ts
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export type SubmitAppFormErrorKeys =
| 'screen1ImageUrl'
| 'authFlow'
| 'redirectUris'
| 'signoutUris'

export const validate = (values: CustomCreateAppModel) => {
let errors = validateRequire<CustomCreateAppModel, SubmitAppFormErrorKeys>({
@@ -31,6 +32,7 @@ export const validate = (values: CustomCreateAppModel) => {
'screen1ImageUrl',
'authFlow',
'redirectUris',
'signoutUris',
],
})

@@ -44,5 +46,9 @@ export const validate = (values: CustomCreateAppModel) => {
errors.redirectUris = 'Invalid redirect uri(s)'
}

if (values.signoutUris && !isValidRedirectUrls(values.signoutUris)) {
errors.signoutUris = 'Invalid sign out uri(s)'
}

return errors
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
@@ -19013,7 +19013,7 @@ redux-persist@^5.10.0:
resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b"
integrity sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg==

redux-saga@^1.1.1:
redux-saga@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-1.1.3.tgz#9f3e6aebd3c994bbc0f6901a625f9a42b51d1112"
integrity sha512-RkSn/z0mwaSa5/xH/hQLo8gNf4tlvT18qXDNvedihLcfzh+jMchDgaariQoehCpgRltEm4zHKJyINEz6aqswTw==

0 comments on commit 2b88221

Please sign in to comment.