add unstable prop for disabling unregister entity
Signed-off-by: Prasetya Aria Wibawa <prasetya.wibawa@grabtaxi.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': patch
|
||||
---
|
||||
|
||||
Add unstable prop for disabling unregister entity menu
|
||||
@@ -44,13 +44,20 @@ type ExtraContextMenuItem = {
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
// unstable context menu option, eg: disable the unregister entity menu
|
||||
type contextMenuOptions = {
|
||||
disableUnregister: boolean;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
UNSTABLE_extraContextMenuItems?: ExtraContextMenuItem[];
|
||||
UNSTABLE_contextMenuOptions?: contextMenuOptions;
|
||||
onUnregisterEntity: () => void;
|
||||
};
|
||||
|
||||
export const EntityContextMenu = ({
|
||||
UNSTABLE_extraContextMenuItems,
|
||||
UNSTABLE_contextMenuOptions,
|
||||
onUnregisterEntity,
|
||||
}: Props) => {
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>();
|
||||
@@ -82,6 +89,9 @@ export const EntityContextMenu = ({
|
||||
<Divider key="the divider is here!" />,
|
||||
];
|
||||
|
||||
const disableUnregister =
|
||||
UNSTABLE_contextMenuOptions?.disableUnregister ?? false;
|
||||
|
||||
return (
|
||||
<>
|
||||
<IconButton
|
||||
@@ -108,6 +118,7 @@ export const EntityContextMenu = ({
|
||||
onClose();
|
||||
onUnregisterEntity();
|
||||
}}
|
||||
disabled={disableUnregister}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<Cancel fontSize="small" />
|
||||
|
||||
@@ -132,8 +132,14 @@ type ExtraContextMenuItem = {
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
// unstable context menu option, eg: disable the unregister entity menu
|
||||
type contextMenuOptions = {
|
||||
disableUnregister: boolean;
|
||||
};
|
||||
|
||||
type EntityLayoutProps = {
|
||||
UNSTABLE_extraContextMenuItems?: ExtraContextMenuItem[];
|
||||
UNSTABLE_contextMenuOptions?: contextMenuOptions;
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
@@ -154,6 +160,7 @@ type EntityLayoutProps = {
|
||||
*/
|
||||
export const EntityLayout = ({
|
||||
UNSTABLE_extraContextMenuItems,
|
||||
UNSTABLE_contextMenuOptions,
|
||||
children,
|
||||
}: EntityLayoutProps) => {
|
||||
const { kind, namespace, name } = useEntityCompoundName();
|
||||
@@ -210,6 +217,7 @@ export const EntityLayout = ({
|
||||
<EntityLabels entity={entity} />
|
||||
<EntityContextMenu
|
||||
UNSTABLE_extraContextMenuItems={UNSTABLE_extraContextMenuItems}
|
||||
UNSTABLE_contextMenuOptions={UNSTABLE_contextMenuOptions}
|
||||
onUnregisterEntity={showRemovalDialog}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -112,14 +112,21 @@ type ExtraContextMenuItem = {
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
// unstable context menu option, eg: disable the unregister entity menu
|
||||
type contextMenuOptions = {
|
||||
disableUnregister: boolean;
|
||||
};
|
||||
|
||||
type EntityPageLayoutProps = {
|
||||
UNSTABLE_extraContextMenuItems?: ExtraContextMenuItem[];
|
||||
UNSTABLE_contextMenuOptions?: contextMenuOptions;
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
export const EntityPageLayout = ({
|
||||
children,
|
||||
UNSTABLE_extraContextMenuItems,
|
||||
UNSTABLE_contextMenuOptions,
|
||||
}: EntityPageLayoutProps) => {
|
||||
const { kind, namespace, name } = useEntityCompoundName();
|
||||
const { entity, loading, error } = useContext(EntityContext);
|
||||
@@ -152,6 +159,7 @@ export const EntityPageLayout = ({
|
||||
<EntityLabels entity={entity} />
|
||||
<EntityContextMenu
|
||||
UNSTABLE_extraContextMenuItems={UNSTABLE_extraContextMenuItems}
|
||||
UNSTABLE_contextMenuOptions={UNSTABLE_contextMenuOptions}
|
||||
onUnregisterEntity={showRemovalDialog}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user