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

Fixes #36793 - Allow plugins to close ActionsBar kebab via React context #9847

Merged
Merged
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
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