mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Fleet] disable reinstall with tooltip for uploaded packages (#150535)
## Summary Disable Reinstall button and added tooltip to prevent clicking Reinstall for uploaded packages. Related to https://github.com/elastic/kibana/issues/148599#issuecomment-1420869104 <img width="731" alt="image" src="https://user-images.githubusercontent.com/90178898/217497440-e36bad4d-d4dc-4d1c-b434-b17f0a4ead0a.png"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
This commit is contained in:
parent
031f67bb49
commit
84003d2a8b
2 changed files with 55 additions and 23 deletions
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { EuiButton } from '@elastic/eui';
|
||||
import { EuiButton, EuiToolTip } from '@elastic/eui';
|
||||
import React, { Fragment, useCallback } from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
|
@ -13,41 +13,66 @@ import type { PackageInfo } from '../../../../../types';
|
|||
import { InstallStatus } from '../../../../../types';
|
||||
import { useAuthz, useGetPackageInstallStatus, useInstallPackage } from '../../../../../hooks';
|
||||
|
||||
type ReinstallationButtonProps = Pick<PackageInfo, 'name' | 'title' | 'version'>;
|
||||
type ReinstallationButtonProps = Pick<PackageInfo, 'name' | 'title' | 'version'> & {
|
||||
installSource: string;
|
||||
};
|
||||
export function ReinstallButton(props: ReinstallationButtonProps) {
|
||||
const { name, title, version } = props;
|
||||
const { name, title, version, installSource } = props;
|
||||
const canInstallPackages = useAuthz().integrations.installPackages;
|
||||
const installPackage = useInstallPackage();
|
||||
const getPackageInstallStatus = useGetPackageInstallStatus();
|
||||
const { status: installationStatus } = getPackageInstallStatus(name);
|
||||
|
||||
const isReinstalling = installationStatus === InstallStatus.reinstalling;
|
||||
const isUploadedPackage = installSource === 'upload';
|
||||
|
||||
const handleClickReinstall = useCallback(() => {
|
||||
installPackage({ name, version, title, isReinstall: true });
|
||||
}, [installPackage, name, title, version]);
|
||||
|
||||
const reinstallButton = (
|
||||
<EuiButton
|
||||
iconType="refresh"
|
||||
isLoading={isReinstalling}
|
||||
onClick={handleClickReinstall}
|
||||
disabled={isUploadedPackage}
|
||||
>
|
||||
{isReinstalling ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.integrations.installPackage.reinstallingPackageButtonLabel"
|
||||
defaultMessage="Reinstalling {title}"
|
||||
values={{
|
||||
title,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.integrations.installPackage.reinstallPackageButtonLabel"
|
||||
defaultMessage="Reinstall {title}"
|
||||
values={{
|
||||
title,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</EuiButton>
|
||||
);
|
||||
|
||||
return canInstallPackages ? (
|
||||
<Fragment>
|
||||
<EuiButton iconType="refresh" isLoading={isReinstalling} onClick={handleClickReinstall}>
|
||||
{isReinstalling ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.integrations.installPackage.reinstallingPackageButtonLabel"
|
||||
defaultMessage="Reinstalling {title}"
|
||||
values={{
|
||||
title,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.integrations.installPackage.reinstallPackageButtonLabel"
|
||||
defaultMessage="Reinstall {title}"
|
||||
values={{
|
||||
title,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</EuiButton>
|
||||
{isUploadedPackage ? (
|
||||
<EuiToolTip
|
||||
content={
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.integrations.installPackage.uploadedTooltip"
|
||||
defaultMessage="This integration was installed by upload and cannot be automatically reinstalled. Please upload it again to reinstall."
|
||||
/>
|
||||
}
|
||||
>
|
||||
{reinstallButton}
|
||||
</EuiToolTip>
|
||||
) : (
|
||||
reinstallButton
|
||||
)}
|
||||
</Fragment>
|
||||
) : null;
|
||||
}
|
||||
|
|
|
@ -410,7 +410,14 @@ export const SettingsPage: React.FC<Props> = memo(({ packageInfo, theme$ }: Prop
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<div>
|
||||
<ReinstallButton {...packageInfo} />
|
||||
<ReinstallButton
|
||||
{...packageInfo}
|
||||
installSource={
|
||||
'savedObject' in packageInfo
|
||||
? packageInfo.savedObject.attributes.install_source
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue