Skip to content

Commit

Permalink
chore(utils): use default debounce time for typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuan Vo committed Aug 1, 2023
1 parent 00afc56 commit dc409ad
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
9 changes: 2 additions & 7 deletions src/app/Rules/CreateRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ import { SelectTemplateSelectorForm } from '@app/Shared/SelectTemplateSelectorFo
import { TemplateType } from '@app/Shared/Services/Api.service';
import { ServiceContext } from '@app/Shared/Services/Services';
import { Target } from '@app/Shared/Services/Target.service';
import {
DEFAULT_MATCH_EXPR_DEBOUNCE_TIME,
SearchExprService,
SearchExprServiceContext,
useExprSvc,
} from '@app/Topology/Shared/utils';
import { SearchExprService, SearchExprServiceContext, useExprSvc } from '@app/Topology/Shared/utils';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { portalRoot } from '@app/utils/utils';
import {
Expand Down Expand Up @@ -292,7 +287,7 @@ const CreateRuleForm: React.FC<CreateRuleFormProps> = ({ ...props }) => {
const matchedTargets = matchedTargetsRef.current;
addSubscription(
combineLatest([
matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME),
matchExprService.searchExpression(),
context.targets.targets().pipe(tap((ts) => setSampleTarget(ts[0]))),
])
.pipe(
Expand Down
9 changes: 2 additions & 7 deletions src/app/SecurityPanel/Credentials/CreateCredentialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ import { MatchExpressionHint } from '@app/Shared/MatchExpression/MatchExpression
import { MatchExpressionVisualizer } from '@app/Shared/MatchExpression/MatchExpressionVisualizer';
import { ServiceContext } from '@app/Shared/Services/Services';
import { Target } from '@app/Shared/Services/Target.service';
import {
DEFAULT_MATCH_EXPR_DEBOUNCE_TIME,
SearchExprService,
SearchExprServiceContext,
useExprSvc,
} from '@app/Topology/Shared/utils';
import { SearchExprService, SearchExprServiceContext, useExprSvc } from '@app/Topology/Shared/utils';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { portalRoot, StreamOf } from '@app/utils/utils';
import {
Expand Down Expand Up @@ -173,7 +168,7 @@ export const AuthForm: React.FC<AuthFormProps> = ({ onDismiss, onPropsSave, prog
React.useEffect(() => {
addSubscription(
combineLatest([
matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME),
matchExprService.searchExpression(),
context.targets.targets().pipe(tap((ts) => setSampleTarget(ts[0]))),
])
.pipe(
Expand Down
4 changes: 2 additions & 2 deletions src/app/SecurityPanel/Credentials/CredentialTestTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { LoadingView } from '@app/LoadingView/LoadingView';
import { LinearDotSpinner } from '@app/Shared/LinearDotSpinner';
import { ServiceContext } from '@app/Shared/Services/Services';
import { Target } from '@app/Shared/Services/Target.service';
import { DEFAULT_MATCH_EXPR_DEBOUNCE_TIME, useExprSvc } from '@app/Topology/Shared/utils';
import { useExprSvc } from '@app/Topology/Shared/utils';
import { useSort } from '@app/utils/useSort';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { TableColumn, portalRoot, sortResources } from '@app/utils/utils';
Expand Down Expand Up @@ -114,7 +114,7 @@ export const CredentialTestTable: React.FC<CredentialTestTableProps> = ({ ...pro
React.useEffect(() => {
addSubscription(
combineLatest([
matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME).pipe(tap((exp) => setMatchExpr(exp))),
matchExprService.searchExpression().pipe(tap((exp) => setMatchExpr(exp))),
context.targets.targets(),
])
.pipe(
Expand Down
9 changes: 2 additions & 7 deletions src/app/Shared/MatchExpression/MatchExpressionVisualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ import { TopologyControlBar } from '@app/Topology/GraphView/TopologyControlBar';
import { SavedGraphPosition, SavedNodePosition } from '@app/Topology/GraphView/TopologyGraphView';
import { getNodeById } from '@app/Topology/GraphView/UtilsFactory';
import EntityDetails, { AlertOptions } from '@app/Topology/Shared/Entity/EntityDetails';
import {
DEFAULT_MATCH_EXPR_DEBOUNCE_TIME,
MatchedTargetsServiceContext,
useExprSvc,
useMatchedTargetsSvcSource,
} from '@app/Topology/Shared/utils';
import { MatchedTargetsServiceContext, useExprSvc, useMatchedTargetsSvcSource } from '@app/Topology/Shared/utils';
import { TopologySideBar } from '@app/Topology/SideBar/TopologySideBar';
import { NodeType } from '@app/Topology/typings';
import { getFromLocalStorage, saveToLocalStorage } from '@app/utils/LocalStorage';
Expand Down Expand Up @@ -348,7 +343,7 @@ const ListView: React.FC<{ alertOptions?: AlertOptions }> = ({ alertOptions, ...
React.useEffect(() => {
addSubscription(
combineLatest([
matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME).pipe(tap((exp) => setMatchExpr(exp))),
matchExprService.searchExpression().pipe(tap((exp) => setMatchExpr(exp))),
context.targets.targets(),
])
.pipe(
Expand Down
10 changes: 2 additions & 8 deletions src/app/Topology/ListView/TopologyListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ import * as React from 'react';
import { useSelector } from 'react-redux';
import { Subject, catchError, combineLatest, of, switchMap } from 'rxjs';
import { TopologyEmptyState } from '../Shared/TopologyEmptyState';
import {
DEFAULT_MATCH_EXPR_DEBOUNCE_TIME,
DiscoveryTreeContext,
TransformConfig,
getAllLeaves,
useExprSvc,
} from '../Shared/utils';
import { DiscoveryTreeContext, TransformConfig, getAllLeaves, useExprSvc } from '../Shared/utils';
import { TopologyToolbar, TopologyToolbarVariant } from '../Toolbar/TopologyToolbar';
import { transformData } from './UtilsFactory';

Expand Down Expand Up @@ -80,7 +74,7 @@ export const TopologyListView: React.FC<TopologyListViewProps> = ({ transformCon

React.useEffect(() => {
addSubscription(
combineLatest([matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME), tSubject.asObservable()])
combineLatest([matchExprService.searchExpression(), tSubject.asObservable()])
.pipe(
switchMap(([input, ts]) =>
input ? svcContext.api.matchTargetsWithExpr(input, ts).pipe(catchError((_) => of([]))) : of(undefined)
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Shared/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export const useMatchedTargetsSvcSource = (): BehaviorSubject<Target[] | undefin

React.useEffect(() => {
addSubscription(
combineLatest([matchExprService.searchExpression(DEFAULT_MATCH_EXPR_DEBOUNCE_TIME), svc.targets.targets()])
combineLatest([matchExprService.searchExpression(), svc.targets.targets()])
.pipe(
switchMap(([input, targets]) =>
input ? svc.api.matchTargetsWithExpr(input, targets).pipe(catchError((_) => of([]))) : of(undefined)
Expand Down

0 comments on commit dc409ad

Please sign in to comment.