Skip to content

Commit

Permalink
loading spinner added to accordian (opensearch-project#343) (opensear…
Browse files Browse the repository at this point in the history
…ch-project#344)

Signed-off-by: Amardeepsingh Siglani <[email protected]>

Signed-off-by: Amardeepsingh Siglani <[email protected]>
(cherry picked from commit 23a22be)

Co-authored-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
2 people authored and AWSHurneyt committed Oct 12, 2023
1 parent dfef47d commit cd2d007
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export interface CreateDetectorRulesState {

export interface DetectionRulesProps {
rulesState: CreateDetectorRulesState;
loading?: boolean;
onRuleToggle: (changedItem: RuleItem, isActive: boolean) => void;
onAllRulesToggle: (enabled: boolean) => void;
onPageChange: (page: { index: number; size: number }) => void;
}

export const DetectionRules: React.FC<DetectionRulesProps> = ({
rulesState,
loading,
onPageChange,
onRuleToggle,
onAllRulesToggle,
Expand Down Expand Up @@ -103,6 +105,7 @@ export const DetectionRules: React.FC<DetectionRulesProps> = ({
buttonProps={{ style: { paddingLeft: '10px', paddingRight: '10px' } }}
id={'detectorRulesAccordion'}
initialIsOpen={false}
isLoading={loading}
>
<EuiHorizontalRule margin={'xs'} />
<DetectionRulesTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface DefineDetectorProps extends RouteComponentProps {
indexService: IndexService;
rulesState: CreateDetectorRulesState;
notifications: NotificationsStart;
loadingRules?: boolean;
changeDetector: (detector: Detector) => void;
updateDataValidState: (step: DetectorCreationStep, isValid: boolean) => void;
onPageChange: (page: { index: number; size: number }) => void;
Expand Down Expand Up @@ -203,6 +204,7 @@ export default class DefineDetector extends Component<DefineDetectorProps, Defin

<DetectionRules
rulesState={rulesState}
loading={this.props.loadingRules}
onPageChange={onPageChange}
onRuleToggle={onRuleToggle}
onAllRulesToggle={onAllRulesToggle}
Expand Down
8 changes: 7 additions & 1 deletion public/pages/CreateDetector/containers/CreateDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface CreateDetectorState {
creatingDetector: boolean;
rulesState: CreateDetectorRulesState;
plugins: string[];
loadingRules: boolean;
}

export default class CreateDetector extends Component<CreateDetectorProps, CreateDetectorState> {
Expand All @@ -73,6 +74,7 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat
creatingDetector: false,
rulesState: { page: { index: 0 }, allRules: [] },
plugins: [],
loadingRules: false,
};
}

Expand Down Expand Up @@ -182,7 +184,9 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat

async setupRulesState() {
const { detector_type } = this.state.detector;

this.setState({
loadingRules: true,
});
const allRules = await this.rulesViewModelActor.fetchRules(undefined, {
bool: {
must: [{ match: { 'rule.category': `${detector_type}` } }],
Expand Down Expand Up @@ -212,6 +216,7 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat
},
],
},
loadingRules: false,
});
}

Expand Down Expand Up @@ -299,6 +304,7 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat
detector={this.state.detector}
indexService={services.indexService}
rulesState={this.state.rulesState}
loadingRules={this.state.loadingRules}
onRuleToggle={this.onRuleToggle}
onAllRulesToggle={this.onAllRulesToggle}
onPageChange={this.onPageChange}
Expand Down

0 comments on commit cd2d007

Please sign in to comment.