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

fix: #1127 add categories data to preview #1610

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('DeveloperSubmitApp', () => {

describe('handleOpenAppPreview', () => {
it('should run correctly', () => {
const params = { appDetails: {}, values: {}, scopes: [], appId: 'appId' }
const params = { appDetails: {}, values: {}, scopes: [], categories: [], appId: 'appId' }
const spyLocalStorageSetItem = jest.spyOn(window.localStorage, 'setItem')
const spyOpenUrl = jest.spyOn(window, 'open')
const expected = JSON.stringify({ scopes: [] })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import UploadImageSection from './upload-image-section'
import MarketplaceStatusSection from './marketplace-status-section'
import PermissionSection from './permission-section'
import styles from '@/styles/pages/developer-submit-app.scss?mod'
import { ScopeModel } from '@/types/marketplace-api-schema'
import { ScopeModel, CategoryModel } from '@/types/marketplace-api-schema'
import { selectCategories } from '@/selector/app-categories'

export type DeveloperSubmitAppProps = {}

Expand Down Expand Up @@ -277,16 +278,18 @@ export const handleOnSubmitAnotherApp = (dispatch: Dispatch) => {

export type HandleOpenAppPreview = {
scopes: ScopeModel[]
categories: CategoryModel[]
values: FormikValues
appId?: string
appDetails?: AppDetailModel & { apiKey?: string }
}

export const handleOpenAppPreview = ({ appDetails, values, scopes, appId }: HandleOpenAppPreview) => () => {
export const handleOpenAppPreview = ({ appDetails, values, scopes, categories, appId }: HandleOpenAppPreview) => () => {
const appDetailState = {
...appDetails,
...values,
scopes: scopes.filter(scope => values.scopes.includes(scope.name)),
category: categories.find(category => values.categoryId === category.id),
}

const url = `developer/apps/${appId}/preview`
Expand All @@ -305,6 +308,7 @@ export const DeveloperSubmitApp: React.FC<DeveloperSubmitAppProps> = () => {
const appDetailState = useSelector(selectAppDetailState)
const submitAppState = useSelector(selectSubmitAppState)
const submitRevisionState = useSelector(selectSubmitAppRevisionState)
const appCategories = useSelector(selectCategories)

const [isSubmitModalOpen, setIsSubmitModalOpen] = React.useState<boolean>(!getCookieString(COOKIE_FIRST_SUBMIT))

Expand Down Expand Up @@ -402,6 +406,7 @@ export const DeveloperSubmitApp: React.FC<DeveloperSubmitAppProps> = () => {
appDetails: appDetailState?.appDetailData?.data,
values,
scopes,
categories: appCategories,
appId: appid,
})}
variant="primary"
Expand Down
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-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.