Skip to content

Commit

Permalink
chore: #1159 update webhook table render
Browse files Browse the repository at this point in the history
  • Loading branch information
An Duong committed May 7, 2020
1 parent 7664d79 commit 5f4cc2c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ exports[`DeveloperWebHooks should match a snapshot 1`] = `
"accessor": "url",
},
Object {
"Cell": [Function],
"Header": "Topics",
"accessor": "topics",
},
Object {
"Cell": [Function],
"Header": "Customer",
"accessor": "customer",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('DeveloperWebHooks', () => {
]
const subscriptionTopicIds: string[] = ['XXX', 'YYY']
const result = renderTopicName(topics, subscriptionTopicIds)
const expected = 'xxx\nyyy'
const expected = ['xxx', 'yyy']
expect(result).toEqual(expected)
})
})
Expand All @@ -156,11 +156,11 @@ describe('DeveloperWebHooks', () => {
const subscriptionCustomerIds = ['XXX', 'yyy']
const subscriptionCustomerIdsEmpty = []
const result = renderCustomerName(subscriptionCustomerIds)
const expected = 'XXX\nyyy'
const expected = ['XXX', 'yyy']
expect(result).toEqual(expected)

const emptyResult = renderCustomerName(subscriptionCustomerIdsEmpty)
expect(emptyResult).toEqual('All Customers (*)')
expect(emptyResult).toEqual(['All Customers (*)'])
})
})
describe('openEditModal', () => {
Expand Down
14 changes: 10 additions & 4 deletions packages/marketplace/src/components/pages/developer-webhooks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { ReactElement } from 'react'
import { Loader, SelectBoxOptions } from '@reapit/elements'
import { ReduxState } from '@/types/core'
import { DeveloperState } from '@/reducers/developer'
Expand Down Expand Up @@ -35,6 +35,10 @@ import FormikAutoSave from '@/components/hocs/formik-auto-save'
import WebhookEditModal from '../ui/webhook-edit-modal'
import { selectDeveloperApps } from '@/selector/developer'

export const CreatedCell = ({ cell: { value } }): ReactElement[] => {
return value.map((line, index) => <p key={index}>{line}</p>)
}

export const columns = [
{
Header: 'URL',
Expand All @@ -43,10 +47,12 @@ export const columns = [
{
Header: 'Topics',
accessor: 'topics',
Cell: CreatedCell,
},
{
Header: 'Customer',
accessor: 'customer',
Cell: CreatedCell,
},
{
Header: 'Test Webhook',
Expand Down Expand Up @@ -86,14 +92,14 @@ export const openEditModal = ({ webhookSetOpenModal, setWebhookId }: OpenEditMod
export const renderTopicName = (topics: TopicModel[], subscriptionTopicIds: string[]) => {
const subscriptionTopics = topics.filter(topic => subscriptionTopicIds.includes(topic.id))
const subscriptionTopicsName = subscriptionTopics.map(topic => topic.name)
return subscriptionTopicsName.join('\n')
return subscriptionTopicsName
}

export const renderCustomerName = (subscriptionCustomerIds: string[]) => {
if (subscriptionCustomerIds.length) {
return subscriptionCustomerIds.join('\n')
return subscriptionCustomerIds
}
return 'All Customers (*)'
return ['All Customers (*)']
}

type GetTableTopicsDataParams = {
Expand Down
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-lines.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.

0 comments on commit 5f4cc2c

Please sign in to comment.