-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Allow User to Cleanup Repository from UI #53047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cuff-links
merged 27 commits into
elastic:master
from
cuff-links:43904_Add_Cleanup_Action_To_UI
Jan 11, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a0e1773
Added repository cleanup button. Added logic for spinner while loadin…
77c9076
Added additional bindings for server side to hit the cleanup endpoint.
bdd834f
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine a3f48b6
fix cleanup request
alisonelizabeth 004b93f
Added data test subject to the code editors to differentiate them and…
34d2a69
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine c6cac4a
Merge branch 'master' of github.com:elastic/kibana into 43904_Add_Cle…
4d2b85f
Added files for a component integration test. The tests are failing r…
2307730
Merge branch 'master' of github.com:elastic/kibana into 43904_Add_Cle…
f86725a
Added change to the way data-test-subjects were created for the repos…
1296528
Merge branch 'master' of github.com:elastic/kibana into 43904_Add_Cle…
6ad982d
Removed the jest tests for repository details until we get jest fixed.
9deb14e
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine bf413be
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine 71fd891
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine 6d536a9
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine f6e34d0
Merge branch 'master' of github.com:elastic/kibana into 43904_Add_Cle…
0d0c470
Fixed jest test to reflect updated test subjects.
e9e9dbf
Made changes per feedback in PR comments.
f61a139
Fixed i10n issues using <FormattedMessage>. Removed reference to blue…
590a904
Added i10n fixes for header.
dae7208
Added i10n fixes for header.
ce69496
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine c065f88
Added name parameter for i18n strings.
da765a0
Merge branch '43904_Add_Cleanup_Action_To_UI' of github.com:cuff-link…
558ff5e
Removed i18n string from JSON.stringify call since it's already a str…
a8b21c7
Merge branch 'master' into 43904_Add_Cleanup_Action_To_UI
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import { | |
| EuiButton, | ||
| EuiButtonEmpty, | ||
| EuiCallOut, | ||
| EuiCodeEditor, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiFlyout, | ||
|
|
@@ -19,6 +18,8 @@ import { | |
| EuiLink, | ||
| EuiSpacer, | ||
| EuiTitle, | ||
| EuiCodeBlock, | ||
| EuiText, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import 'brace/theme/textmate'; | ||
|
|
@@ -28,12 +29,17 @@ import { documentationLinksService } from '../../../../services/documentation'; | |
| import { | ||
| useLoadRepository, | ||
| verifyRepository as verifyRepositoryRequest, | ||
| cleanupRepository as cleanupRepositoryRequest, | ||
| } from '../../../../services/http'; | ||
| import { textService } from '../../../../services/text'; | ||
| import { linkToSnapshots, linkToEditRepository } from '../../../../services/navigation'; | ||
|
|
||
| import { REPOSITORY_TYPES } from '../../../../../../common/constants'; | ||
| import { Repository, RepositoryVerification } from '../../../../../../common/types'; | ||
| import { | ||
| Repository, | ||
| RepositoryVerification, | ||
| RepositoryCleanup, | ||
| } from '../../../../../../common/types'; | ||
| import { | ||
| RepositoryDeleteProvider, | ||
| SectionError, | ||
|
|
@@ -61,7 +67,9 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({ | |
| const { FormattedMessage } = i18n; | ||
| const { error, data: repositoryDetails } = useLoadRepository(repositoryName); | ||
| const [verification, setVerification] = useState<RepositoryVerification | undefined>(undefined); | ||
| const [cleanup, setCleanup] = useState<RepositoryCleanup | undefined>(undefined); | ||
| const [isLoadingVerification, setIsLoadingVerification] = useState<boolean>(false); | ||
| const [isLoadingCleanup, setIsLoadingCleanup] = useState<boolean>(false); | ||
|
|
||
| const verifyRepository = async () => { | ||
| setIsLoadingVerification(true); | ||
|
|
@@ -70,11 +78,20 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({ | |
| setIsLoadingVerification(false); | ||
| }; | ||
|
|
||
| // Reset verification state when repository name changes, either from adjust URL or clicking | ||
| const cleanupRepository = async () => { | ||
| setIsLoadingCleanup(true); | ||
| const { data } = await cleanupRepositoryRequest(repositoryName); | ||
| setCleanup(data.cleanup); | ||
| setIsLoadingCleanup(false); | ||
| }; | ||
|
|
||
| // Reset verification state and cleanup when repository name changes, either from adjust URL or clicking | ||
| // into a different repository in table list. | ||
| useEffect(() => { | ||
| setVerification(undefined); | ||
| setIsLoadingVerification(false); | ||
| setCleanup(undefined); | ||
| setIsLoadingCleanup(false); | ||
| }, [repositoryName]); | ||
|
|
||
| const renderBody = () => { | ||
|
|
@@ -231,6 +248,8 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({ | |
| <TypeDetails repository={repository} /> | ||
| <EuiHorizontalRule /> | ||
| {renderVerification()} | ||
| <EuiHorizontalRule /> | ||
| {renderCleanup()} | ||
| </Fragment> | ||
| ); | ||
| }; | ||
|
|
@@ -260,36 +279,13 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({ | |
| </EuiTitle> | ||
| <EuiSpacer size="s" /> | ||
| {verification ? ( | ||
| <EuiCodeEditor | ||
| mode="json" | ||
| theme="textmate" | ||
| width="100%" | ||
| isReadOnly | ||
| value={JSON.stringify( | ||
| <EuiCodeBlock language="json" inline={false} data-test-subj="verificationCodeBlock"> | ||
| {JSON.stringify( | ||
| verification.valid ? verification.response : verification.error, | ||
| null, | ||
| 2 | ||
| )} | ||
| setOptions={{ | ||
| showLineNumbers: false, | ||
| tabSize: 2, | ||
| maxLines: Infinity, | ||
| }} | ||
| editorProps={{ | ||
| $blockScrolling: Infinity, | ||
| }} | ||
| showGutter={false} | ||
| minLines={6} | ||
| aria-label={ | ||
| <FormattedMessage | ||
| id="xpack.snapshotRestore.repositoryDetails.verificationDetails" | ||
| defaultMessage="Verification details repository '{name}'" | ||
| values={{ | ||
| name, | ||
| }} | ||
| /> | ||
| } | ||
| /> | ||
| </EuiCodeBlock> | ||
| ) : null} | ||
| <EuiSpacer size="m" /> | ||
| <EuiButton onClick={verifyRepository} color="primary" isLoading={isLoadingVerification}> | ||
|
|
@@ -318,6 +314,78 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({ | |
| </Fragment> | ||
| ); | ||
|
|
||
| const renderCleanup = () => ( | ||
| <> | ||
| <EuiTitle size="s"> | ||
| <h3> | ||
| <FormattedMessage | ||
| id="xpack.snapshotRestore.repositoryDetails.cleanupTitle" | ||
| defaultMessage="Repository cleanup" | ||
| /> | ||
| </h3> | ||
| </EuiTitle> | ||
| <EuiSpacer size="s" /> | ||
| <EuiText size="s"> | ||
| <p> | ||
| <FormattedMessage | ||
| id="xpack.snapshotRestore.repositoryDetails.cleanupRepositoryMessage" | ||
| defaultMessage="You can clean up a repository to delete any unreferenced data from a snapshot. This | ||
| may provide storage space savings. Note: If you regularly delete snapshots, this | ||
| functionality will likely not be as beneficial and should be used less frequently." | ||
| /> | ||
| </p> | ||
| </EuiText> | ||
| {cleanup ? ( | ||
| <> | ||
| <EuiSpacer size="s" /> | ||
| {cleanup.cleaned ? ( | ||
| <div> | ||
| <EuiTitle size="xs"> | ||
| <h4> | ||
| <FormattedMessage | ||
| id="xpack.snapshotRestore.repositoryDetails.cleanupDetailsTitle" | ||
| defaultMessage="Details" | ||
| /> | ||
| </h4> | ||
| </EuiTitle> | ||
| <EuiCodeBlock language="json" inline={false} data-test-subj="cleanupCodeBlock"> | ||
| {JSON.stringify(cleanup.response, null, 2)} | ||
| </EuiCodeBlock> | ||
| </div> | ||
| ) : ( | ||
| <EuiCallOut | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also include the actual error from the request underneath the title (as CJ mentioned in his comment)? |
||
| color="danger" | ||
| iconType="alert" | ||
| title={i18n.translate('xpack.snapshotRestore.repositoryDetails.cleanupErrorTitle', { | ||
| defaultMessage: 'Sorry, there was an error cleaning the repository.', | ||
| })} | ||
| > | ||
| <p> | ||
| {cleanup.error | ||
| ? JSON.stringify(cleanup.error) | ||
| : i18n.translate('xpack.snapshotRestore.repositoryDetails.cleanupUnknownError', { | ||
| defaultMessage: '503: Unknown error', | ||
| })} | ||
| </p> | ||
| </EuiCallOut> | ||
| )} | ||
| </> | ||
| ) : null} | ||
| <EuiSpacer size="m" /> | ||
| <EuiButton | ||
| onClick={cleanupRepository} | ||
| color="primary" | ||
| isLoading={isLoadingCleanup} | ||
| data-test-subj="cleanupRepositoryButton" | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.snapshotRestore.repositoryDetails.cleanupButtonLabel" | ||
| defaultMessage="Clean up repository" | ||
| /> | ||
| </EuiButton> | ||
| </> | ||
| ); | ||
|
|
||
| const renderFooter = () => { | ||
| return ( | ||
| <EuiFlexGroup justifyContent="spaceBetween" alignItems="center"> | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.