Skip to content

Commit

Permalink
Alternate description for disabled filters
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWeill committed Feb 23, 2024
1 parent 2d68127 commit 059fb7e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/documentsearch/src/searchview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,21 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> {
<div className={SEARCH_OPTIONS_CLASS}>
{Object.keys(filters).map(name => {
const filter = filters[name];

const isEnabled = !showReplace || filter.supportReplace;
// Show an alternate description, if one exists, when a filter is disabled in replace mode.
const description = isEnabled
? filter.description
: (filter.disabledDescription ?? filter.description);
return (
<FilterSelection
key={name}
title={filter.title}
description={
filter.description +
description +
(name == 'selection' ? selectionKeyHint : '')
}
isEnabled={!showReplace || filter.supportReplace}
isEnabled={isEnabled}
onToggle={async () => {
await this.props.onFilterChanged(
name,
Expand Down
4 changes: 4 additions & 0 deletions packages/documentsearch/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export interface IFilter {
* Filter description
*/
description: string;
/**
* Filter description to be used when the filter is disabled in replace mode.
*/
disabledDescription?: string;
/**
* Default value
*/
Expand Down
1 change: 1 addition & 0 deletions packages/notebook/src/searchprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export class NotebookSearchProvider extends SearchProvider<NotebookPanel> {
output: {
title: trans.__('Search Cell Outputs'),
description: trans.__('Search in the cell outputs.'),
disabledDescription: trans.__('Search in the cell outputs. (Not available in find and replace mode.)'),
default: false,
supportReplace: false
},
Expand Down

0 comments on commit 059fb7e

Please sign in to comment.