Skip to content

Commit

Permalink
Remove unused domains/kracken-ui/max-characters-filter feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardost committed Oct 21, 2024
1 parent 98e3a66 commit 7c962c5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 75 deletions.
5 changes: 1 addition & 4 deletions client/components/domains/register-domain-step/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ class RegisterDomainStep extends Component {

getInitialFiltersState() {
return {
maxCharacters: '',
exactSldMatchesOnly: false,
tlds: [],
};
Expand Down Expand Up @@ -532,9 +531,7 @@ class RegisterDomainStep extends Component {
}

renderSearchFilters() {
const isKrackenUi =
config.isEnabled( 'domains/kracken-ui/exact-match-filter' ) ||
config.isEnabled( 'domains/kracken-ui/max-characters-filter' );
const isKrackenUi = config.isEnabled( 'domains/kracken-ui/exact-match-filter' );
const isRenderingInitialSuggestions =
! Array.isArray( this.state.searchResults ) &&
! this.state.loadingResults &&
Expand Down
70 changes: 7 additions & 63 deletions client/components/domains/search-filters/dropdown-filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ import PropTypes from 'prop-types';
import { createRef, Component } from 'react';
import FormInputCheckbox from 'calypso/components/forms/form-checkbox';
import FormFieldset from 'calypso/components/forms/form-fieldset';
import FormTextInput from 'calypso/components/forms/form-text-input';
import TokenField from 'calypso/components/token-field';
import ValidationFieldset from 'calypso/signup/validation-fieldset';

const HANDLED_FILTER_KEYS = [ 'tlds', 'maxCharacters', 'exactSldMatchesOnly' ];
const HANDLED_FILTER_KEYS = [ 'tlds', 'exactSldMatchesOnly' ];

export class DropdownFilters extends Component {
static propTypes = {
availableTlds: PropTypes.array,
filters: PropTypes.shape( {
maxCharacters: PropTypes.string,
exactSldMatchesOnly: PropTypes.bool,
tlds: PropTypes.array,
} ).isRequired,
lastFilters: PropTypes.shape( {
maxCharacters: PropTypes.string,
exactSldMatchesOnly: PropTypes.bool,
tlds: PropTypes.array,
} ).isRequired,
Expand All @@ -41,7 +38,6 @@ export class DropdownFilters extends Component {

state = {
showPopover: false,
showOverallValidationError: false,
};

constructor( props ) {
Expand All @@ -65,32 +61,10 @@ export class DropdownFilters extends Component {
getFiltercounts() {
return (
( this.props.lastFilters.tlds?.length || 0 ) +
( this.props.lastFilters.exactSldMatchesOnly && 1 ) +
( this.props.lastFilters.maxCharacters !== '' && 1 )
( this.props.lastFilters.exactSldMatchesOnly && 1 )
);
}

getMaxCharactersValidationErrors() {
const {
filters: { maxCharacters },
translate,
} = this.props;
const isValid = /^-?\d*$/.test( maxCharacters );
return ! isValid ? [ translate( 'Value must be a whole number' ) ] : null;
}

getOverallValidationErrors() {
const isValid = this.getMaxCharactersValidationErrors() === null;
const { showOverallValidationError } = this.state;
return ! isValid && showOverallValidationError
? [ this.props.translate( 'Please correct any errors above' ) ]
: null;
}

hasValidationErrors() {
return this.getOverallValidationErrors() !== null;
}

updateFilterValues = ( name, value ) => {
this.props.onChange( {
[ name ]: value,
Expand All @@ -107,18 +81,13 @@ export class DropdownFilters extends Component {
};

handleFiltersReset = () => {
this.setState( { showOverallValidationError: false }, () => {
this.setState( {}, () => {
this.togglePopover( { discardChanges: false } );
this.props.onReset( 'tlds', 'maxCharacters', 'exactSldMatchesOnly' );
this.props.onReset( 'tlds', 'exactSldMatchesOnly' );
} );
};
handleFiltersSubmit = () => {
if ( this.hasValidationErrors() ) {
this.setState( { showOverallValidationError: true } );
return;
}

this.setState( { showOverallValidationError: false }, () => {
this.setState( {}, () => {
this.togglePopover( { discardChanges: false } );
this.hasFiltersChanged() && this.props.onSubmit();
} );
Expand Down Expand Up @@ -180,14 +149,13 @@ export class DropdownFilters extends Component {

renderPopover() {
const {
filters: { maxCharacters, exactSldMatchesOnly },
filters: { exactSldMatchesOnly },
popoverId,
translate,
showTldFilter,
} = this.props;

const isExactMatchFilterEnabled = config.isEnabled( 'domains/kracken-ui/exact-match-filter' );
const isLengthFilterEnabled = config.isEnabled( 'domains/kracken-ui/max-characters-filter' );

return (
<Popover
Expand All @@ -202,27 +170,6 @@ export class DropdownFilters extends Component {
{ ...( isWithinBreakpoint( '>660px' ) && { relativePosition: { left: -238 } } ) }
hideArrow
>
{ isLengthFilterEnabled && (
<ValidationFieldset
className="search-filters__text-input-fieldset"
errorMessages={ this.getMaxCharactersValidationErrors() }
>
<FormLabel className="search-filters__label" htmlFor="search-filters-max-characters">
{ translate( 'Max Characters' ) }:
</FormLabel>
<FormTextInput
className="search-filters__input"
id="search-filters-max-characters"
min="1"
name="maxCharacters"
onChange={ this.handleOnChange }
placeholder="14"
type="number"
value={ maxCharacters }
/>
</ValidationFieldset>
) }

{ showTldFilter && (
<ValidationFieldset className="search-filters__tld-filters">
<TokenField
Expand Down Expand Up @@ -260,10 +207,7 @@ export class DropdownFilters extends Component {
) }
</FormFieldset>

<ValidationFieldset
className="search-filters__buttons-fieldset"
errorMessages={ this.getOverallValidationErrors() }
>
<ValidationFieldset className="search-filters__buttons-fieldset">
<div className="search-filters__buttons">
<Button onClick={ this.handleFiltersReset }>{ translate( 'Clear' ) }</Button>
<Button primary onClick={ this.handleFiltersSubmit }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ export class FilterResetNotice extends Component {
static propTypes = {
isLoading: PropTypes.bool.isRequired,
lastFilters: PropTypes.shape( {
maxCharacters: PropTypes.string,
exactSldMatchesOnly: PropTypes.bool,
tlds: PropTypes.arrayOf( PropTypes.string ),
} ).isRequired,
suggestions: PropTypes.arrayOf( PropTypes.object ),
};

hasActiveFilters() {
const { lastFilters: { exactSldMatchesOnly, maxCharacters, tlds = [] } = {} } = this.props;
return exactSldMatchesOnly || maxCharacters !== '' || tlds.length > 0;
const { lastFilters: { exactSldMatchesOnly, tlds = [] } = {} } = this.props;
return exactSldMatchesOnly || tlds.length > 0;
}

hasTooFewSuggestions() {
Expand Down
4 changes: 0 additions & 4 deletions client/components/domains/search-filters/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
margin-left: 2px;
}

.search-filters__text-input-fieldset .search-filters__label {
margin-bottom: 0.25em;
}

.search-filters__tld-filters {
.token-field__token {
margin: 4px 8px 4px 0;
Expand Down
1 change: 0 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"devdocs/redirect-loggedout-homepage": true,
"domains/gdpr-consent-page": true,
"domains/kracken-ui/exact-match-filter": true,
"domains/kracken-ui/max-characters-filter": false,
"domains/kracken-ui/pagination": true,
"email-accounts/enabled": true,
"external-media": true,
Expand Down

0 comments on commit 7c962c5

Please sign in to comment.