Files
shields/frontend/components/markup-modal/markup-modal-content.js
Marcin Mielnicki eeb78ccf15 Badge suggestion feature fix (#3331)
* Display suggested badges

* E2e test for badge suggestion

* Suggest resource returns example with pattern

* Do not require preview in MarkupModalContent

* Skip integration test for suggestion

* Unmodifiable path in customizer

* Use suggested link

* Allow to change suggested badges

* Enable skipped test

* Enable skipped test

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Unused code removed

* Unused code removed

* getExampleWithServiceByPattern helper added

* BadgeExamples uses examples instead of services definitions

* Revert "getExampleWithServiceByPattern helper added"

This reverts commit 80839fd705.

* style removed from example

* example.exact replaced with preview.buildFromExample

* keywords are required again

* Code refactoring

* More e2e tests for suggestion feature

* Code refactoring

* Build add with a base url

* showActualParams -> isPrefilled

* A new schema for BadgeExamples

* Link moved to queryParams

* Updated documentation for the suggest reponse format

* Link moved to queryParams - another test updated

* Revert "Link moved to queryParams - another test updated"

This reverts commit b5f811bb07.

* Revert "Link moved to queryParams"

This reverts commit 3b54c6d2b4.

* Disable changes in path in suggested badges

* 'link' element documentation restored
2019-04-29 18:38:27 +02:00

57 lines
1.3 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { examplePropType } from '../../lib/service-definitions/example-prop-types'
import { H3 } from '../common'
import Customizer from '../customizer/customizer'
const Documentation = styled.div`
max-width: 800px;
margin: 35px auto 20px;
`
export default class MarkupModalContent extends React.Component {
static propTypes = {
example: examplePropType,
baseUrl: PropTypes.string.isRequired,
}
renderDocumentation() {
const {
example: { documentation },
} = this.props
return documentation ? (
<Documentation dangerouslySetInnerHTML={documentation} />
) : null
}
render() {
const {
example: {
title,
example: { pattern, namedParams, queryParams },
link,
preview: { style: initialStyle, buildFromExample } = {},
},
baseUrl,
} = this.props
return (
<>
<H3>{title}</H3>
{this.renderDocumentation()}
<Customizer
baseUrl={baseUrl}
exampleNamedParams={namedParams}
exampleQueryParams={queryParams}
initialStyle={initialStyle}
isPrefilled={buildFromExample}
link={link}
pattern={pattern}
title={title}
/>
</>
)
}
}