-
Notifications
You must be signed in to change notification settings - Fork 843
Expand file tree
/
Copy pathGitOpsModeTooltipWrapper.tsx
More file actions
56 lines (49 loc) · 1.65 KB
/
GitOpsModeTooltipWrapper.tsx
File metadata and controls
56 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import TooltipWrapper, {
ITooltipWrapper,
} from "components/TooltipWrapper/TooltipWrapper";
import useGitOpsMode from "hooks/useGitOpsMode";
import { IGitOpsExceptions } from "interfaces/config";
import React from "react";
import { getGitOpsModeTipContent } from "utilities/helpers";
interface IGitOpsModeTooltipWrapper {
renderChildren: (disableChildren?: boolean) => React.ReactNode;
/** Positioned left in forms partially disabled by gitops mode (e.g. settings/organization/advanced) */
position?: ITooltipWrapper["position"];
tipOffset?: ITooltipWrapper["tipOffset"];
fixedPositionStrategy?: ITooltipWrapper["fixedPositionStrategy"];
// When specified, the wrapper checks the exception for this entity type.
// If the entity is excepted, children remain enabled even in GitOps mode.
entityType?: keyof IGitOpsExceptions;
}
const baseClass = "gitops-mode-tooltip-wrapper";
const GitOpsModeTooltipWrapper = ({
position = "top",
tipOffset,
renderChildren,
fixedPositionStrategy,
entityType,
}: IGitOpsModeTooltipWrapper) => {
const { gitOpsModeEnabled, repoURL } = useGitOpsMode(entityType);
if (!gitOpsModeEnabled) {
return <>{renderChildren()}</>;
}
const tipContent = (
<div className={`${baseClass}__tooltip-content`}>
{repoURL && getGitOpsModeTipContent(repoURL)}
</div>
);
return (
<TooltipWrapper
className={baseClass}
position={position}
tipOffset={tipOffset}
tipContent={tipContent}
underline={false}
showArrow
fixedPositionStrategy={fixedPositionStrategy}
>
{renderChildren(true)}
</TooltipWrapper>
);
};
export default GitOpsModeTooltipWrapper;