diff options
author | stanislavh <stanislav.honcharov@sonarsource.com> | 2023-02-01 13:07:32 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-02-03 14:26:00 +0000 |
commit | 8f72091b04eb22c28339e89c603e3f52ad26d4a4 (patch) | |
tree | 67d6b3ee0390cde269c4545c456eaa338a770bd0 | |
parent | f878f29cfe8940a3b291cd54a4b951f668dde2a5 (diff) | |
download | sonarqube-8f72091b04eb22c28339e89c603e3f52ad26d4a4.tar.gz sonarqube-8f72091b04eb22c28339e89c603e3f52ad26d4a4.zip |
SONAR-18067 Buttons have same name but different actions
11 files changed, 43 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx index dd581137e23..eabd93eaa72 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx @@ -68,6 +68,8 @@ export class LanguageFacet extends React.PureComponent<Props> { disabled={this.props.disabled} disabledHelper={translate('coding_rules.filters.language.inactive')} facetHeader={translate('coding_rules.facet.languages')} + showMoreAriaLabel={translate('coding_rules.facet.language.show_more')} + showLessAriaLabel={translate('coding_rules.facet.language.show_less')} fetching={false} getFacetItemText={this.getLanguageName} getSearchResultKey={(language) => language.key} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx index 2eda13557bc..321e49e4c65 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx @@ -88,6 +88,8 @@ export class RepositoryFacet extends React.PureComponent<Props> { return ( <ListStyleFacet<string> facetHeader={translate('coding_rules.facet.repositories')} + showMoreAriaLabel={translate('coding_rules.facet.repository.show_more')} + showLessAriaLabel={translate('coding_rules.facet.repository.show_less')} fetching={false} getFacetItemText={this.renderTextName} getSearchResultKey={(rep) => rep} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/TagFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/TagFacet.tsx index d196cd47b5c..255badc4571 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/TagFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/TagFacet.tsx @@ -65,6 +65,8 @@ export default class TagFacet extends React.PureComponent<BasicProps> { getFacetItemText={this.getTagName} getSearchResultKey={(tag) => tag} getSearchResultText={(tag) => tag} + showMoreAriaLabel={translate('coding_rules.facet.tag.show_more')} + showLessAriaLabel={translate('coding_rules.facet.tag.show_less')} onChange={this.props.onChange} onSearch={this.handleSearch} onToggle={this.props.onToggle} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/TagFacet-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/TagFacet-test.tsx.snap index cabca9e9a09..51eabc32eae 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/TagFacet-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/TagFacet-test.tsx.snap @@ -43,6 +43,8 @@ exports[`should render correctly 1`] = ` renderFacetItem={[Function]} renderSearchResult={[Function]} searchPlaceholder="search.search_for_tags" + showLessAriaLabel="coding_rules.facet.tag.show_less" + showMoreAriaLabel="coding_rules.facet.tag.show_more" stats={{}} values={[]} /> diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx index 44734aca30f..407fe9341e9 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx @@ -398,12 +398,8 @@ export default class StandardFacet extends React.PureComponent<Props, State> { )} {!allItemShown && ( <ListStyleFacetFooter + showMoreAriaLabel={translate('issues.facet.sonarsource.show_more')} count={limitedList.length + selectedBelowLimit.length} - showLess={ - this.state.showFullSonarSourceList - ? () => this.setState({ showFullSonarSourceList: false }) - : undefined - } showMore={() => this.setState({ showFullSonarSourceList: true })} total={sortedItems.length} /> diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 1c42ddcfa5a..55aa17d9838 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -266,7 +266,7 @@ export class AllProjects extends React.PureComponent<Props, State> { /> )} <ListFooter - accessibleLoadMoreLabel={translate('projects.show_more')} + loadMoreAriaLabel={translate('projects.show_more')} count={this.state.projects !== undefined ? this.state.projects.length : 0} loading={this.state.loading} loadMore={this.fetchMoreProjects} diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap index e2e307db962..aefede3dc66 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap @@ -170,9 +170,9 @@ exports[`renders 1`] = ` } /> <ListFooter - accessibleLoadMoreLabel="projects.show_more" count={1} loadMore={[Function]} + loadMoreAriaLabel="projects.show_more" loading={false} ready={true} total={0} diff --git a/server/sonar-web/src/main/js/components/controls/ListFooter.tsx b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx index 32f47f2fe74..fbbcb2af464 100644 --- a/server/sonar-web/src/main/js/components/controls/ListFooter.tsx +++ b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx @@ -25,7 +25,7 @@ import DeferredSpinner from '../ui/DeferredSpinner'; import { Button } from './buttons'; export interface ListFooterProps { - accessibleLoadMoreLabel?: string; + loadMoreAriaLabel?: string; count: number; className?: string; loading?: boolean; @@ -39,7 +39,7 @@ export interface ListFooterProps { export default function ListFooter(props: ListFooterProps) { const { - accessibleLoadMoreLabel, + loadMoreAriaLabel, className, count, loadMore, @@ -79,7 +79,7 @@ export default function ListFooter(props: ListFooterProps) { } else if (hasMore && props.loadMore) { button = ( <Button - aria-label={accessibleLoadMoreLabel} + aria-label={loadMoreAriaLabel} className="spacer-left" disabled={loading} data-test="show-more" diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx index cd08ffbacf5..a87da01e050 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -67,6 +67,8 @@ export interface Props<S> { getSortedItems?: () => string[]; stats: Dict<number> | undefined; values: string[]; + showMoreAriaLabel?: string; + showLessAriaLabel?: string; } interface State<S> { @@ -238,7 +240,7 @@ export default class ListStyleFacet<S> extends React.Component<Props<S>, State<S }; renderList() { - const { stats } = this.props; + const { stats, showMoreAriaLabel, showLessAriaLabel } = this.props; if (!stats) { return null; @@ -303,6 +305,8 @@ export default class ListStyleFacet<S> extends React.Component<Props<S>, State<S showLess={this.state.showFullList ? this.hideFullList : undefined} showMore={this.showFullList} total={sortedItems.length} + showMoreAriaLabel={showMoreAriaLabel} + showLessAriaLabel={showLessAriaLabel} /> {mightHaveMoreResults && this.state.showFullList && ( <Alert className="spacer-top" variant="warning"> @@ -328,6 +332,7 @@ export default class ListStyleFacet<S> extends React.Component<Props<S>, State<S } renderSearchResults() { + const { showMoreAriaLabel } = this.props; const { searching, searchMaxResults, searchResults, searchPaging } = this.state; if (!searching && (!searchResults || !searchResults.length)) { @@ -356,6 +361,7 @@ export default class ListStyleFacet<S> extends React.Component<Props<S>, State<S loadMore={this.searchMore} ready={!searching} total={searchPaging.total} + loadMoreAriaLabel={showMoreAriaLabel} /> )} </> diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx index 5498906d885..0d0faead164 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacetFooter.tsx @@ -25,8 +25,10 @@ import { ButtonLink } from '../controls/buttons'; interface Props { count: number; showMore: () => void; - showLess: (() => void) | undefined; + showLess?: () => void; total: number; + showMoreAriaLabel?: string; + showLessAriaLabel?: string; } export default class ListStyleFacetFooter extends React.PureComponent<Props> { @@ -41,7 +43,7 @@ export default class ListStyleFacetFooter extends React.PureComponent<Props> { }; render() { - const { count, total } = this.props; + const { count, total, showMoreAriaLabel, showLessAriaLabel } = this.props; const hasMore = total > count; const allShown = Boolean(total && total === count); @@ -50,13 +52,21 @@ export default class ListStyleFacetFooter extends React.PureComponent<Props> { {translateWithParameters('x_show', formatMeasure(count, 'INT', null))} {hasMore && ( - <ButtonLink className="spacer-left" onClick={this.handleShowMoreClick}> + <ButtonLink + className="spacer-left" + aria-label={showMoreAriaLabel} + onClick={this.handleShowMoreClick} + > {translate('show_more')} </ButtonLink> )} {this.props.showLess && allShown && ( - <ButtonLink className="spacer-left" onClick={this.handleShowLessClick}> + <ButtonLink + className="spacer-left" + aria-label={showLessAriaLabel} + onClick={this.handleShowLessClick} + > {translate('show_less')} </ButtonLink> )} diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index e188285828e..5989351b9ef 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1012,6 +1012,7 @@ issues.facet.owaspTop10_2021=OWASP Top 10 2021 issues.facet.sansTop25=SANS Top 25 issues.facet.sonarsourceSecurity=SonarSource issues.facet.cwe=CWE +issues.facet.sonarsource.show_more=Show more SonarSource categories #------------------------------------------------------------------------------ # @@ -2023,6 +2024,13 @@ coding_rules.facet.template=Template coding_rules.facet.rule_key=Rule coding_rules.facet.types=Type +coding_rules.facet.language.show_more=Show more languages +coding_rules.facet.language.show_less=Show less languages +coding_rules.facet.tag.show_more=Show more tags +coding_rules.facet.tag.show_less=Show less tags +coding_rules.facet.repository.show_more=Show more repositories +coding_rules.facet.repository.show_less=Show less repositories + coding_rules.facets.languages=Languages coding_rules.facets.tags=Tags coding_rules.facets.repositories=Repositories |