Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domains: Remove unused domains/kracken-ui/max-characters-filter feature flag #95564

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
77 changes: 9 additions & 68 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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only ever changed to true when hasValidationErrors returned true, which doesn't happen anymore. So this state property can be removed.

};

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;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method only checked if maxCharacters is an integer, so it can be removed.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since getMaxCharactersValidationErrors only returned null, isValid was always true and this method always returned null, so it can be removed too.


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

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

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

this.setState( { showOverallValidationError: false }, () => {
this.togglePopover( { discardChanges: false } );
this.hasFiltersChanged() && this.props.onSubmit();
} );
handleFiltersSubmit = () => {
this.togglePopover( { discardChanges: false } );
this.hasFiltersChanged() && this.props.onSubmit();
};

hasFiltersChanged() {
Expand Down Expand Up @@ -180,14 +146,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 +167,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 +204,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 @@ -63,7 +63,6 @@
"devdocs/color-scheme-picker": true,
"devdocs/redirect-loggedout-homepage": 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
Loading