-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…136158) * Add package reinstall button in settings tab * Fix uninstall unavailable message Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit e817d5e) Co-authored-by: Jen Huang <[email protected]>
- Loading branch information
1 parent
2ac8754
commit a2f538d
Showing
6 changed files
with
180 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ublic/applications/integrations/sections/epm/screens/detail/settings/reinstall_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiButton } from '@elastic/eui'; | ||
import React, { Fragment, useCallback } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
import type { PackageInfo } from '../../../../../types'; | ||
import { InstallStatus } from '../../../../../types'; | ||
import { useAuthz, useGetPackageInstallStatus, useInstallPackage } from '../../../../../hooks'; | ||
|
||
type ReinstallationButtonProps = Pick<PackageInfo, 'name' | 'title' | 'version'>; | ||
export function ReinstallButton(props: ReinstallationButtonProps) { | ||
const { name, title, version } = props; | ||
const canInstallPackages = useAuthz().integrations.installPackages; | ||
const installPackage = useInstallPackage(); | ||
const getPackageInstallStatus = useGetPackageInstallStatus(); | ||
const { status: installationStatus } = getPackageInstallStatus(name); | ||
|
||
const isReinstalling = installationStatus === InstallStatus.reinstalling; | ||
|
||
const handleClickReinstall = useCallback(() => { | ||
installPackage({ name, version, title, isReinstall: true }); | ||
}, [installPackage, name, title, version]); | ||
|
||
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> | ||
</Fragment> | ||
) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters