aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsTagsPopup.tsx11
-rw-r--r--server/sonar-web/src/main/js/apps/overview/meta/MetaTagsSelector.tsx24
2 files changed, 23 insertions, 12 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsTagsPopup.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsTagsPopup.tsx
index d6064752070..ddd9a5d54ed 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsTagsPopup.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsTagsPopup.tsx
@@ -32,7 +32,7 @@ interface Props {
}
interface State {
- searchResult: any[];
+ searchResult: string[];
}
const LIST_SIZE = 10;
@@ -43,7 +43,6 @@ export default class RuleDetailsTagsPopup extends React.PureComponent<Props, Sta
componentDidMount() {
this.mounted = true;
- this.onSearch('');
}
componentWillUnmount() {
@@ -51,7 +50,7 @@ export default class RuleDetailsTagsPopup extends React.PureComponent<Props, Sta
}
onSearch = (query: string) => {
- getRuleTags({
+ return getRuleTags({
q: query,
ps: Math.min(this.props.tags.length + LIST_SIZE, 100),
organization: this.props.organization
@@ -77,13 +76,13 @@ export default class RuleDetailsTagsPopup extends React.PureComponent<Props, Sta
render() {
return (
<TagsSelector
- position={this.props.popupPosition || {}}
- tags={this.state.searchResult}
- selectedTags={this.props.tags}
listSize={LIST_SIZE}
onSearch={this.onSearch}
onSelect={this.onSelect}
onUnselect={this.onUnselect}
+ position={this.props.popupPosition || {}}
+ selectedTags={this.props.tags}
+ tags={this.state.searchResult}
/>
);
}
diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaTagsSelector.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaTagsSelector.tsx
index 2e2bb774a80..2fdd9fe1f6e 100644
--- a/server/sonar-web/src/main/js/apps/overview/meta/MetaTagsSelector.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaTagsSelector.tsx
@@ -37,17 +37,29 @@ interface State {
const LIST_SIZE = 10;
export default class MetaTagsSelector extends React.PureComponent<Props, State> {
+ mounted = false;
state: State = { searchResult: [] };
componentDidMount() {
- this.onSearch('');
+ this.mounted = true;
+ }
+
+ componentWillUnmount() {
+ this.mounted = false;
}
onSearch = (query: string) => {
- searchProjectTags({
+ return searchProjectTags({
q: query,
ps: Math.min(this.props.selectedTags.length - 1 + LIST_SIZE, 100)
- }).then(result => this.setState({ searchResult: result.tags }), () => {});
+ }).then(
+ ({ tags }) => {
+ if (this.mounted) {
+ this.setState({ searchResult: tags });
+ }
+ },
+ () => {}
+ );
};
onSelect = (tag: string) => {
@@ -61,13 +73,13 @@ export default class MetaTagsSelector extends React.PureComponent<Props, State>
render() {
return (
<TagsSelector
- position={this.props.position}
- tags={this.state.searchResult}
- selectedTags={this.props.selectedTags}
listSize={LIST_SIZE}
onSearch={this.onSearch}
onSelect={this.onSelect}
onUnselect={this.onUnselect}
+ position={this.props.position}
+ selectedTags={this.props.selectedTags}
+ tags={this.state.searchResult}
/>
);
}