Skip to content

Commit

Permalink
Fixes #36793 - Allow plugins to close ActionsBar kebab via React context
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Sep 29, 2023
1 parent 735b401 commit 9c3a4a0
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import React, { useState, createContext } from 'react';
import { useSelector, shallowEqual, useDispatch } from 'react-redux';
import {
Button,
Expand Down Expand Up @@ -27,6 +27,8 @@ import { useForemanSettings } from '../../../Root/Context/ForemanContext';
import BuildModal from './BuildModal';
import Slot from '../../common/Slot';

export const ForemanActionsBarContext = createContext();

const ActionsBar = ({
hostId,
hostFriendlyId,
Expand Down Expand Up @@ -147,16 +149,18 @@ const ActionsBar = ({
>
{__('Edit')}
</Button>
<Dropdown
ouiaId="kebab-dropdown"
alignments={{ default: 'right' }}
toggle={
<KebabToggle id="hostdetails-kebab" onToggle={onKebabToggle} />
}
isOpen={kebabIsOpen}
isPlain
dropdownItems={dropdownItems.concat(registeredItems)}
/>
<ForemanActionsBarContext.Provider value={{ onKebabToggle }}>
<Dropdown
ouiaId="kebab-dropdown"
alignments={{ default: 'right' }}
toggle={
<KebabToggle id="hostdetails-kebab" onToggle={onKebabToggle} />
}
isOpen={kebabIsOpen}
isPlain
dropdownItems={dropdownItems.concat(registeredItems)}
/>
</ForemanActionsBarContext.Provider>
</SplitItem>
</Split>
{isBuildModalOpen && (
Expand Down

0 comments on commit 9c3a4a0

Please sign in to comment.