aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/web-api/components
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-03-13 17:28:41 +0100
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-03-14 10:39:38 +0100
commit10d9e0eb4ec208dba63e6c8bc2920adb788b04be (patch)
tree15900e29d7e81b37e79c6021acfd5bc3f1f955c4 /server/sonar-web/src/main/js/apps/web-api/components
parent796469600844cbbe5727e10761be8582b045ebf9 (diff)
downloadsonarqube-10d9e0eb4ec208dba63e6c8bc2920adb788b04be.tar.gz
sonarqube-10d9e0eb4ec208dba63e6c8bc2920adb788b04be.zip
SONAR-8779 hide deprecated api by default
Diffstat (limited to 'server/sonar-web/src/main/js/apps/web-api/components')
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/Action.js144
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/Domain.js66
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/Menu.js66
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/Params.js17
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/Search.js127
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js90
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.js40
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.js18
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Domain-test.js.snap49
-rw-r--r--server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Params-test.js.snap56
10 files changed, 443 insertions, 230 deletions
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Action.js b/server/sonar-web/src/main/js/apps/web-api/components/Action.js
index 0226a5d1a0c..8cb26123911 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/Action.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/Action.js
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import React from 'react';
import { Link } from 'react-router';
import { getActionKey } from '../utils';
@@ -25,24 +26,35 @@ import ResponseExample from './ResponseExample';
import DeprecatedBadge from './DeprecatedBadge';
import InternalBadge from './InternalBadge';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
+import type { Action as ActionType, Domain as DomainType } from '../../../api/web-api';
-export default class Action extends React.Component {
- static propTypes = {
- showInternal: React.PropTypes.bool
- };
+type Props = {
+ action: ActionType,
+ domain: DomainType,
+ showDeprecated: boolean,
+ showInternal: boolean
+};
+
+type State = {
+ showParams: boolean,
+ showResponse: boolean
+};
+
+export default class Action extends React.PureComponent {
+ props: Props;
- state = {
+ state: State = {
showParams: false,
showResponse: false
};
- handleShowParamsClick (e) {
+ handleShowParamsClick (e: SyntheticInputEvent) {
e.preventDefault();
this.refs.toggleParameters.blur();
this.setState({ showResponse: false, showParams: !this.state.showParams });
}
- handleShowResponseClick (e) {
+ handleShowResponseClick (e: SyntheticInputEvent) {
e.preventDefault();
this.refs.toggleResponse.blur();
this.setState({ showParams: false, showResponse: !this.state.showResponse });
@@ -55,69 +67,61 @@ export default class Action extends React.Component {
const actionKey = getActionKey(domain.path, action.key);
return (
- <div id={actionKey} className="web-api-action">
- <TooltipsContainer>
- <header className="web-api-action-header">
- <Link
- to={{ pathname: '/web_api/' + actionKey }}
- className="spacer-right icon-link"/>
-
- <h3 className="web-api-action-title">
- {verb}&nbsp;{actionKey}
- </h3>
-
- {action.internal && (
- <span className="spacer-left">
- <InternalBadge/>
- </span>
- )}
-
- {action.since && (
- <span className="spacer-left badge">since {action.since}</span>
- )}
-
- {action.deprecatedSince && (
- <span className="spacer-left">
- <DeprecatedBadge since={action.deprecatedSince}/>
- </span>
- )}
- </header>
- </TooltipsContainer>
-
- <div
- className="web-api-action-description markdown"
- dangerouslySetInnerHTML={{ __html: action.description }}/>
-
- {(action.params || action.hasResponseExample) && (
- <ul className="web-api-action-actions list-inline">
- {action.params && (
- <li>
- <a
- ref="toggleParameters"
- onClick={this.handleShowParamsClick.bind(this)}
- href="#">
- {showParams ? 'Hide Parameters' : 'Show Parameters'}
- </a>
- </li>
- )}
-
- {action.hasResponseExample && (
- <li>
- <a
- ref="toggleResponse"
- onClick={this.handleShowResponseClick.bind(this)}
- href="#">
- {showResponse ? 'Hide Response Example' : 'Show Response Example'}
- </a>
- </li>
- )}
- </ul>
- )}
-
- {showParams && action.params && <Params params={action.params} showInternal={this.props.showInternal}/>}
-
- {showResponse && action.hasResponseExample && <ResponseExample domain={domain} action={action}/>}
- </div>
+ <div id={actionKey} className="web-api-action">
+ <TooltipsContainer>
+ <header className="web-api-action-header">
+ <Link to={{ pathname: '/web_api/' + actionKey }} className="spacer-right icon-link"/>
+
+ <h3 className="web-api-action-title">
+ {verb}&nbsp;{actionKey}
+ </h3>
+
+ {action.internal &&
+ <span className="spacer-left">
+ <InternalBadge/>
+ </span>}
+
+ {action.since && <span className="spacer-left badge">since {action.since}</span>}
+
+ {action.deprecatedSince &&
+ <span className="spacer-left">
+ <DeprecatedBadge since={action.deprecatedSince}/>
+ </span>}
+ </header>
+ </TooltipsContainer>
+
+ <div
+ className="web-api-action-description markdown"
+ dangerouslySetInnerHTML={{ __html: action.description }}/>
+
+ {(action.params || action.hasResponseExample) &&
+ <ul className="web-api-action-actions list-inline">
+ {action.params &&
+ <li>
+ <a ref="toggleParameters" onClick={this.handleShowParamsClick.bind(this)} href="#">
+ {showParams ? 'Hide Parameters' : 'Show Parameters'}
+ </a>
+ </li>}
+
+ {action.hasResponseExample &&
+ <li>
+ <a ref="toggleResponse" onClick={this.handleShowResponseClick.bind(this)} href="#">
+ {showResponse ? 'Hide Response Example' : 'Show Response Example'}
+ </a>
+ </li>}
+ </ul>}
+
+ {showParams &&
+ action.params &&
+ <Params
+ params={action.params}
+ showDeprecated={this.props.showDeprecated}
+ showInternal={this.props.showInternal}/>}
+
+ {showResponse &&
+ action.hasResponseExample &&
+ <ResponseExample domain={domain} action={action}/>}
+ </div>
);
}
}
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Domain.js b/server/sonar-web/src/main/js/apps/web-api/components/Domain.js
index bb41c979a85..0cfbb1de482 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/Domain.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/Domain.js
@@ -17,50 +17,60 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import React from 'react';
import Action from './Action';
+import DeprecatedBadge from './DeprecatedBadge';
import InternalBadge from './InternalBadge';
import { getActionKey } from '../utils';
+import type { Domain as DomainType } from '../../../api/web-api';
-export default function Domain ({ domain, showInternal, showOnlyDeprecated, searchQuery }) {
- const filteredActions = domain.actions
- .filter(action => {
- return showInternal || !action.internal;
- })
- .filter(action => {
- return !showOnlyDeprecated || (showOnlyDeprecated && action.deprecatedSince);
- })
- .filter(action => {
- const actionKey = getActionKey(domain.path, action.key);
- return actionKey.indexOf(searchQuery) !== -1;
- });
+type Props = {
+ domain: DomainType,
+ showDeprecated: boolean,
+ showInternal: boolean,
+ searchQuery: string
+};
- return (
+export default class Domain extends React.PureComponent {
+ props: Props;
+
+ render () {
+ const { domain, showInternal, showDeprecated, searchQuery } = this.props;
+ const filteredActions = domain.actions
+ .filter(action => showInternal || !action.internal)
+ .filter(action => showDeprecated || !action.deprecatedSince)
+ .filter(action => getActionKey(domain.path, action.key).indexOf(searchQuery) !== -1);
+
+ return (
<div className="web-api-domain">
<header className="web-api-domain-header">
<h2 className="web-api-domain-title">{domain.path}</h2>
- {domain.internal && (
- <span className="spacer-left">
- <InternalBadge/>
- </span>
- )}
+ {domain.deprecated &&
+ <span className="spacer-left">
+ <DeprecatedBadge/>
+ </span>}
+
+ {domain.internal &&
+ <span className="spacer-left">
+ <InternalBadge/>
+ </span>}
</header>
- {domain.description && (
- <p className="web-api-domain-description">{domain.description}</p>
- )}
+ {domain.description && <p className="web-api-domain-description">{domain.description}</p>}
<div className="web-api-domain-actions">
{filteredActions.map(action => (
- <Action
- key={getActionKey(domain.path, action.key)}
- action={action}
- domain={domain}
- location={location}
- showInternal={showInternal}/>
+ <Action
+ key={getActionKey(domain.path, action.key)}
+ action={action}
+ domain={domain}
+ showDeprecated={showDeprecated}
+ showInternal={showInternal}/>
))}
</div>
</div>
- );
+ );
+ }
}
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Menu.js b/server/sonar-web/src/main/js/apps/web-api/components/Menu.js
index 260587ce4ee..b2bea00727f 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/Menu.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/Menu.js
@@ -17,53 +17,63 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import React from 'react';
import { Link } from 'react-router';
import classNames from 'classnames';
+import DeprecatedBadge from './DeprecatedBadge';
import InternalBadge from './InternalBadge';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
import { getActionKey, isDomainPathActive } from '../utils';
+import type { Domain as DomainType } from '../../../api/web-api';
-export default function Menu ({ domains, showInternal, showOnlyDeprecated, searchQuery, splat }) {
- const filteredDomains = (domains || [])
+type Props = {
+ domains: Array<DomainType>,
+ showDeprecated: boolean,
+ showInternal: boolean,
+ searchQuery: string,
+ splat: string
+};
+
+export default class Menu extends React.PureComponent {
+ props: Props;
+
+ render () {
+ const { domains, showInternal, showDeprecated, searchQuery, splat } = this.props;
+ const filteredDomains = (domains || [])
.map(domain => {
const filteredActions = domain.actions
- .filter(action => {
- return showInternal || !action.internal;
- })
- .filter(action => {
- return !showOnlyDeprecated || (showOnlyDeprecated && action.deprecatedSince);
- })
- .filter(action => {
- const actionKey = getActionKey(domain.path, action.key);
- return actionKey.indexOf(searchQuery) !== -1;
- });
+ .filter(action => showInternal || !action.internal)
+ .filter(action => showDeprecated || !action.deprecatedSince)
+ .filter(action => getActionKey(domain.path, action.key).indexOf(searchQuery) !== -1);
return { ...domain, filteredActions };
})
.filter(domain => domain.filteredActions.length);
- return (
+ return (
<div className="api-documentation-results panel">
<TooltipsContainer>
<div className="list-group">
{filteredDomains.map(domain => (
- <Link
- key={domain.path}
- className={classNames('list-group-item', { 'active': isDomainPathActive(domain.path, splat) })}
- to={'/web_api/' + domain.path}>
- <h3 className="list-group-item-heading">
- {domain.path}
- {domain.internal && (
- <InternalBadge/>
- )}
- </h3>
- <p className="list-group-item-text">
- {domain.description}
- </p>
- </Link>
+ <Link
+ key={domain.path}
+ className={classNames('list-group-item', {
+ active: isDomainPathActive(domain.path, splat)
+ })}
+ to={'/web_api/' + domain.path}>
+ <h3 className="list-group-item-heading">
+ {domain.path}
+ {domain.deprecated && <DeprecatedBadge/>}
+ {domain.internal && <InternalBadge/>}
+ </h3>
+ <p className="list-group-item-text">
+ {domain.description}
+ </p>
+ </Link>
))}
</div>
</TooltipsContainer>
</div>
- );
+ );
+ }
}
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Params.js b/server/sonar-web/src/main/js/apps/web-api/components/Params.js
index ac8459cc2f2..bba2118bfa0 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/Params.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/Params.js
@@ -25,13 +25,16 @@ import type { Param } from '../../../api/web-api';
export default class Params extends React.PureComponent {
props: {
- params: Array<Param>,
- showInternal: boolean
+ showDeprecated: boolean,
+ showInternal: boolean,
+ params: Array<Param>
};
render () {
- const { showInternal, params } = this.props;
- const displayedParameters = showInternal ? params : params.filter(p => !p.internal);
+ const { showDeprecated, showInternal, params } = this.props;
+ const displayedParameters = params
+ .filter(p => showDeprecated || !p.deprecatedSince)
+ .filter(p => showInternal || !p.internal);
return (
<div className="web-api-params">
@@ -52,12 +55,14 @@ export default class Params extends React.PureComponent {
<DeprecatedBadge since={param.deprecatedSince}/>
</div>}
- {param.deprecatedKey &&
+ {showDeprecated &&
+ param.deprecatedKey &&
<div className="little-spacer-top">
<code>{param.deprecatedKey}</code>
</div>}
- {param.deprecatedKey &&
+ {showDeprecated &&
+ param.deprecatedKey &&
param.deprecatedKeySince &&
<div className="little-spacer-top">
<DeprecatedBadge since={param.deprecatedKeySince}/>
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Search.js b/server/sonar-web/src/main/js/apps/web-api/components/Search.js
index 66f5da7cda4..233ad109a57 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/Search.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/Search.js
@@ -17,20 +17,37 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import React from 'react';
import debounce from 'lodash/debounce';
import Checkbox from '../../../components/controls/Checkbox';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
import { translate } from '../../../helpers/l10n';
-export default class Search extends React.Component {
- constructor (props) {
+type Props = {
+ showDeprecated: boolean,
+ showInternal: boolean,
+ onSearch: (string) => void,
+ onToggleInternal: () => void,
+ onToggleDeprecated: () => void
+};
+
+type State = {
+ query: string
+};
+
+export default class Search extends React.PureComponent {
+ actuallySearch: () => void;
+ props: Props;
+ state: State;
+
+ constructor (props: Props) {
super(props);
this.state = { query: '' };
this.actuallySearch = debounce(this.actuallySearch.bind(this), 250);
}
- handleSearch (e) {
+ handleSearch (e: SyntheticInputEvent) {
const { value } = e.target;
this.setState({ query: value });
this.actuallySearch();
@@ -42,64 +59,60 @@ export default class Search extends React.Component {
}
render () {
- const { showInternal, showOnlyDeprecated, onToggleInternal, onToggleDeprecated } = this.props;
+ const { showInternal, showDeprecated, onToggleInternal, onToggleDeprecated } = this.props;
return (
- <div className="web-api-search">
- <div>
- <i className="icon-search"/>
- <input
- className="spacer-left input-large"
- type="search"
- value={this.state.query}
- placeholder={translate('search_verb')}
- onChange={this.handleSearch.bind(this)}/>
- </div>
+ <div className="web-api-search">
+ <div>
+ <i className="icon-search"/>
+ <input
+ className="spacer-left input-large"
+ type="search"
+ value={this.state.query}
+ placeholder={translate('search_verb')}
+ onChange={this.handleSearch.bind(this)}/>
+ </div>
- <TooltipsContainer>
- <div className="big-spacer-top">
- <Checkbox
- checked={showInternal}
- onCheck={onToggleInternal}/>
- {' '}
- <span
- style={{ cursor: 'pointer' }}
- title={translate('api_documentation.internal_tooltip')}
- tabIndex="0"
- role="checkbox"
- aria-checked={showInternal ? 'true' : 'false'}
- onClick={onToggleInternal}>
- Show Internal API
- </span>
- <i
- className="icon-help spacer-left"
- title={translate('api_documentation.internal_tooltip')}
- data-toggle="tooltip"/>
- </div>
- </TooltipsContainer>
+ <TooltipsContainer>
+ <div className="big-spacer-top">
+ <Checkbox checked={showInternal} onCheck={onToggleInternal}/>
+ {' '}
+ <span
+ style={{ cursor: 'pointer' }}
+ title={translate('api_documentation.internal_tooltip')}
+ tabIndex="0"
+ role="checkbox"
+ aria-checked={showInternal ? 'true' : 'false'}
+ onClick={onToggleInternal}>
+ Show Internal API
+ </span>
+ <i
+ className="icon-help spacer-left"
+ title={translate('api_documentation.internal_tooltip')}
+ data-toggle="tooltip"/>
+ </div>
+ </TooltipsContainer>
- <TooltipsContainer>
- <div className="spacer-top">
- <Checkbox
- checked={showOnlyDeprecated}
- onCheck={onToggleDeprecated}/>
- {' '}
- <span
- style={{ cursor: 'pointer' }}
- title={translate('api_documentation.deprecation_tooltip')}
- tabIndex="0"
- role="checkbox"
- aria-checked={showOnlyDeprecated ? 'true' : 'false'}
- onClick={onToggleDeprecated}>
- Show Only Deprecated API
- </span>
- <i
- className="icon-help spacer-left"
- title={translate('api_documentation.deprecation_tooltip')}
- data-toggle="tooltip"/>
- </div>
- </TooltipsContainer>
- </div>
+ <TooltipsContainer>
+ <div className="spacer-top">
+ <Checkbox checked={showDeprecated} onCheck={onToggleDeprecated}/>
+ {' '}
+ <span
+ style={{ cursor: 'pointer' }}
+ title={translate('api_documentation.deprecation_tooltip')}
+ tabIndex="0"
+ role="checkbox"
+ aria-checked={showDeprecated ? 'true' : 'false'}
+ onClick={onToggleDeprecated}>
+ Show Deprecated API
+ </span>
+ <i
+ className="icon-help spacer-left"
+ title={translate('api_documentation.deprecation_tooltip')}
+ data-toggle="tooltip"/>
+ </div>
+ </TooltipsContainer>
+ </div>
);
}
}
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js
index 867bae7a974..6251e209c40 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import React from 'react';
import { Link } from 'react-router';
import { fetchWebApi } from '../../../api/web-api';
@@ -24,14 +25,24 @@ import Menu from './Menu';
import Search from './Search';
import Domain from './Domain';
import { getActionKey, isDomainPathActive } from '../utils';
+import type { Domain as DomainType } from '../../../api/web-api';
import '../styles/web-api.css';
-export default class WebApiApp extends React.Component {
- state = {
+type State = {
+ domains: Array<DomainType>,
+ searchQuery: string,
+ showDeprecated: boolean,
+ showInternal: boolean
+};
+
+export default class WebApiApp extends React.PureComponent {
+ mounted: boolean;
+ scrollToAction: () => void;
+ state: State = {
domains: [],
searchQuery: '',
- showInternal: false,
- showOnlyDeprecated: false
+ showDeprecated: false,
+ showInternal: false
};
componentDidMount () {
@@ -51,7 +62,7 @@ export default class WebApiApp extends React.Component {
document.getElementById('footer').classList.remove('search-navigator-footer');
}
- fetchList (cb) {
+ fetchList (cb?: () => void) {
fetchWebApi().then(domains => {
if (this.mounted) {
this.setState({ domains }, cb);
@@ -64,7 +75,7 @@ export default class WebApiApp extends React.Component {
this.scrollToElement(splat);
}
- scrollToElement (id) {
+ scrollToElement (id: string) {
const element = document.getElementById(id);
if (element) {
@@ -96,7 +107,7 @@ export default class WebApiApp extends React.Component {
}
}
- handleSearch (searchQuery) {
+ handleSearch (searchQuery: string) {
this.setState({ searchQuery });
}
@@ -115,50 +126,49 @@ export default class WebApiApp extends React.Component {
}
handleToggleDeprecated () {
- this.setState({ showOnlyDeprecated: !this.state.showOnlyDeprecated });
+ this.setState(state => ({ showDeprecated: !state.showDeprecated }));
}
render () {
const splat = this.props.params.splat || '';
- const { domains, showInternal, showOnlyDeprecated, searchQuery } = this.state;
+ const { domains, showInternal, showDeprecated, searchQuery } = this.state;
const domain = domains.find(domain => isDomainPathActive(domain.path, splat));
return (
- <div className="search-navigator sticky">
- <div className="search-navigator-side search-navigator-side-light" style={{ top: 30 }}>
- <div className="web-api-page-header">
- <Link to="/web_api/">
- <h1>Web API</h1>
- </Link>
- </div>
-
- <Search
- showInternal={showInternal}
- showOnlyDeprecated={showOnlyDeprecated}
- onSearch={this.handleSearch.bind(this)}
- onToggleInternal={this.handleToggleInternal.bind(this)}
- onToggleDeprecated={this.handleToggleDeprecated.bind(this)}/>
-
- <Menu
- domains={this.state.domains}
- showInternal={showInternal}
- showOnlyDeprecated={showOnlyDeprecated}
- searchQuery={searchQuery}
- splat={splat}/>
+ <div className="search-navigator sticky">
+ <div className="search-navigator-side search-navigator-side-light" style={{ top: 30 }}>
+ <div className="web-api-page-header">
+ <Link to="/web_api/">
+ <h1>Web API</h1>
+ </Link>
</div>
- <div className="search-navigator-workspace">
- {domain && (
- <Domain
- key={domain.path}
- domain={domain}
- showInternal={showInternal}
- showOnlyDeprecated={showOnlyDeprecated}
- searchQuery={searchQuery}/>
- )}
- </div>
+ <Search
+ showDeprecated={showDeprecated}
+ showInternal={showInternal}
+ onSearch={this.handleSearch.bind(this)}
+ onToggleInternal={this.handleToggleInternal.bind(this)}
+ onToggleDeprecated={this.handleToggleDeprecated.bind(this)}/>
+
+ <Menu
+ domains={this.state.domains}
+ showDeprecated={showDeprecated}
+ showInternal={showInternal}
+ searchQuery={searchQuery}
+ splat={splat}/>
+ </div>
+
+ <div className="search-navigator-workspace">
+ {domain &&
+ <Domain
+ key={domain.path}
+ domain={domain}
+ showDeprecated={showDeprecated}
+ showInternal={showInternal}
+ searchQuery={searchQuery}/>}
</div>
+ </div>
);
}
}
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.js b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.js
new file mode 100644
index 00000000000..e503202d181
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Domain-test.js
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import Domain from '../Domain';
+
+it('should render deprecated actions', () => {
+ const actions = [{
+ key: 'foo',
+ deprecatedSince: '5.0'
+ }];
+ const domain = { actions, path: 'api' };
+ expect(shallow(<Domain domain={domain} searchQuery="" showDeprecated={true}/>)).toMatchSnapshot();
+});
+
+it('should not render deprecated actions', () => {
+ const actions = [{
+ key: 'foo',
+ deprecatedSince: '5.0'
+ }];
+ const domain = { actions, path: 'api' };
+ expect(shallow(<Domain domain={domain} searchQuery="" showDeprecated={false}/>)).toMatchSnapshot();
+});
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.js b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.js
index c3d0a92834c..8d3f89da3dd 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.js
+++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.js
@@ -21,11 +21,27 @@ import React from 'react';
import { shallow } from 'enzyme';
import Params from '../Params';
+it('should render deprecated parameters', () => {
+ const params = [{
+ key: 'foo',
+ deprecatedSince: '5.0'
+ }];
+ expect(shallow(<Params params={params} showDeprecated={true}/>)).toMatchSnapshot();
+});
+
+it('should not render deprecated parameters', () => {
+ const params = [{
+ key: 'foo',
+ deprecatedSince: '5.0'
+ }];
+ expect(shallow(<Params params={params} showDeprecated={false}/>)).toMatchSnapshot();
+});
+
it('should render deprecated key', () => {
const params = [{
key: 'foo',
deprecatedKey: 'foo-deprecated',
deprecatedKeySince: '5.0'
}];
- expect(shallow(<Params params={params} showInternal={true}/>)).toMatchSnapshot();
+ expect(shallow(<Params params={params} showDeprecated={true}/>)).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Domain-test.js.snap b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Domain-test.js.snap
new file mode 100644
index 00000000000..49b0fcb5b79
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Domain-test.js.snap
@@ -0,0 +1,49 @@
+exports[`test should not render deprecated actions 1`] = `
+<div
+ className="web-api-domain">
+ <header
+ className="web-api-domain-header">
+ <h2
+ className="web-api-domain-title">
+ api
+ </h2>
+ </header>
+ <div
+ className="web-api-domain-actions" />
+</div>
+`;
+
+exports[`test should render deprecated actions 1`] = `
+<div
+ className="web-api-domain">
+ <header
+ className="web-api-domain-header">
+ <h2
+ className="web-api-domain-title">
+ api
+ </h2>
+ </header>
+ <div
+ className="web-api-domain-actions">
+ <Action
+ action={
+ Object {
+ "deprecatedSince": "5.0",
+ "key": "foo",
+ }
+ }
+ domain={
+ Object {
+ "actions": Array [
+ Object {
+ "deprecatedSince": "5.0",
+ "key": "foo",
+ },
+ ],
+ "path": "api",
+ }
+ }
+ showDeprecated={true} />
+ </div>
+</div>
+`;
diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Params-test.js.snap b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Params-test.js.snap
index e96ab29ed2d..5bc2426ebef 100644
--- a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Params-test.js.snap
+++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/__snapshots__/Params-test.js.snap
@@ -1,3 +1,12 @@
+exports[`test should not render deprecated parameters 1`] = `
+<div
+ className="web-api-params">
+ <table>
+ <tbody />
+ </table>
+</div>
+`;
+
exports[`test should render deprecated key 1`] = `
<div
className="web-api-params">
@@ -50,3 +59,50 @@ exports[`test should render deprecated key 1`] = `
</table>
</div>
`;
+
+exports[`test should render deprecated parameters 1`] = `
+<div
+ className="web-api-params">
+ <table>
+ <tbody>
+ <tr>
+ <td
+ className="markdown"
+ style={
+ Object {
+ "width": 180,
+ }
+ }>
+ <code>
+ foo
+ </code>
+ <div
+ className="little-spacer-top">
+ <DeprecatedBadge
+ since="5.0" />
+ </div>
+ <div
+ className="note little-spacer-top">
+ optional
+ </div>
+ </td>
+ <td>
+ <div
+ className="markdown"
+ dangerouslySetInnerHTML={
+ Object {
+ "__html": undefined,
+ }
+ } />
+ </td>
+ <td
+ style={
+ Object {
+ "width": 250,
+ }
+ } />
+ </tr>
+ </tbody>
+ </table>
+</div>
+`;