2022-10-14 16:45:57 +00:00
|
|
|
import classnames from "classnames";
|
2022-02-28 21:25:06 +00:00
|
|
|
import React from "react";
|
2023-11-07 21:15:49 +00:00
|
|
|
import { Tooltip as ReactTooltip5, PlacesType } from "react-tooltip-5";
|
2022-02-28 21:25:06 +00:00
|
|
|
|
2023-11-07 21:15:49 +00:00
|
|
|
import { uniqueId } from "lodash";
|
2023-06-08 17:13:27 +00:00
|
|
|
|
2023-11-07 21:15:49 +00:00
|
|
|
interface ITooltipWrapper {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
// default is bottom-start
|
|
|
|
|
position?: PlacesType;
|
2022-10-04 14:03:51 +00:00
|
|
|
isDelayed?: boolean;
|
2023-11-07 21:15:49 +00:00
|
|
|
underline?: boolean;
|
|
|
|
|
// Below two props used here to maintain the API of the old TooltipWrapper
|
|
|
|
|
// A clearer system would be to use the 3 below commented props, which describe exactly where they
|
|
|
|
|
// will apply, `element` being the element this tooltip will wrap. Associated logic is commented
|
|
|
|
|
// out, but ready to be used.
|
2022-10-14 16:45:57 +00:00
|
|
|
className?: string;
|
2023-08-29 10:47:37 +00:00
|
|
|
tooltipClass?: string;
|
2023-11-07 21:15:49 +00:00
|
|
|
// wrapperCustomClass?: string;
|
|
|
|
|
// elementCustomClass?: string;
|
|
|
|
|
// tipCustomClass?: string;
|
|
|
|
|
clickable?: boolean;
|
|
|
|
|
tipContent: React.ReactNode;
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
/** If set to `true`, will not show the tooltip. This can be used to dynamically
|
|
|
|
|
* disable the tooltip from the parent component.
|
|
|
|
|
* @default false
|
|
|
|
|
*/
|
|
|
|
|
disableTooltip?: boolean;
|
2024-06-11 11:56:50 +00:00
|
|
|
/** If set to `true`, will show the arrow on the tooltip.
|
|
|
|
|
* This can be used to dynamically hide the arrow from the parent component.
|
|
|
|
|
* @default false
|
|
|
|
|
*/
|
|
|
|
|
showArrow?: boolean;
|
2022-02-28 21:25:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const baseClass = "component__tooltip-wrapper";
|
|
|
|
|
|
|
|
|
|
const TooltipWrapper = ({
|
2023-11-07 21:15:49 +00:00
|
|
|
// wrapperCustomClass,
|
|
|
|
|
// elementCustomClass,
|
|
|
|
|
// tipCustomClass,
|
2022-02-28 21:25:06 +00:00
|
|
|
children,
|
|
|
|
|
tipContent,
|
2023-11-07 21:15:49 +00:00
|
|
|
position = "bottom-start",
|
2022-10-04 14:03:51 +00:00
|
|
|
isDelayed,
|
2023-11-07 21:15:49 +00:00
|
|
|
underline = true,
|
2022-10-14 16:45:57 +00:00
|
|
|
className,
|
2023-08-29 10:47:37 +00:00
|
|
|
tooltipClass,
|
2023-11-07 21:15:49 +00:00
|
|
|
clickable = true,
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
disableTooltip = false,
|
2024-06-11 11:56:50 +00:00
|
|
|
showArrow = false,
|
2023-11-07 21:15:49 +00:00
|
|
|
}: ITooltipWrapper) => {
|
|
|
|
|
const wrapperClassNames = classnames(baseClass, className, {
|
2024-06-11 11:56:50 +00:00
|
|
|
"show-arrow": showArrow,
|
2023-11-07 21:15:49 +00:00
|
|
|
// [`${baseClass}__${wrapperCustomClass}`]: !!wrapperCustomClass,
|
2023-08-29 10:47:37 +00:00
|
|
|
});
|
2022-10-04 14:03:51 +00:00
|
|
|
|
2023-11-07 21:15:49 +00:00
|
|
|
const elementClassNames = classnames(`${baseClass}__element`, {
|
|
|
|
|
// [`${baseClass}__${elementCustomClass}`]: !!elementCustomClass,
|
|
|
|
|
[`${baseClass}__underline`]: underline,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tipClassNames = classnames(`${baseClass}__tip-text`, tooltipClass, {
|
|
|
|
|
// [`${baseClass}__${tipCustomClass}`]: !!tipCustomClass,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tipId = uniqueId();
|
2023-06-08 17:13:27 +00:00
|
|
|
|
2022-02-28 21:25:06 +00:00
|
|
|
return (
|
2023-11-07 21:15:49 +00:00
|
|
|
<span className={wrapperClassNames}>
|
|
|
|
|
<div className={elementClassNames} data-tooltip-id={tipId}>
|
2022-02-28 21:25:06 +00:00
|
|
|
{children}
|
|
|
|
|
</div>
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
{!disableTooltip && (
|
|
|
|
|
<ReactTooltip5
|
|
|
|
|
className={tipClassNames}
|
|
|
|
|
id={tipId}
|
|
|
|
|
delayShow={isDelayed ? 500 : undefined}
|
|
|
|
|
delayHide={isDelayed ? 500 : undefined}
|
2024-06-11 11:56:50 +00:00
|
|
|
noArrow={!showArrow}
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
place={position}
|
|
|
|
|
opacity={1}
|
|
|
|
|
disableStyleInjection
|
|
|
|
|
clickable={clickable}
|
|
|
|
|
offset={5}
|
|
|
|
|
>
|
|
|
|
|
{tipContent}
|
|
|
|
|
</ReactTooltip5>
|
|
|
|
|
)}
|
2023-11-07 21:15:49 +00:00
|
|
|
</span>
|
2022-02-28 21:25:06 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TooltipWrapper;
|