-
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
…#58063) * Moved all of the show/hide toggles outside of ordered lists. * Fixed styling issues for indice list. * Fixed i10n tag that I accidentally changed. * Added component to show/hide indices. * Abstracted out some of the common parts of the Show Hide component and implemented the general component in the pages. Also made conditional for the i18n tags. * Fixed changes per comments. Restored <EuiText> to fix the issue with the bullet points. Updated the i18n tags to be more generic. Created 2 components for formatted message. * Fixed internalization issues.. Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
b3af317
commit d7b70f6
Showing
8 changed files
with
98 additions
and
289 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
x-pack/legacy/plugins/snapshot_restore/public/app/components/collapsible_indices_list.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,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { EuiTitle, EuiLink, EuiIcon, EuiText, EuiSpacer } from '@elastic/eui'; | ||
interface Props { | ||
indices: string[] | string | undefined; | ||
} | ||
|
||
import { useAppDependencies } from '../index'; | ||
|
||
export const CollapsibleIndicesList: React.FunctionComponent<Props> = ({ indices }) => { | ||
const { | ||
core: { i18n }, | ||
} = useAppDependencies(); | ||
const { FormattedMessage } = i18n; | ||
const [isShowingFullIndicesList, setIsShowingFullIndicesList] = useState<boolean>(false); | ||
const displayIndices = indices | ||
? typeof indices === 'string' | ||
? indices.split(',') | ||
: indices | ||
: undefined; | ||
const hiddenIndicesCount = | ||
displayIndices && displayIndices.length > 10 ? displayIndices.length - 10 : 0; | ||
return ( | ||
<> | ||
{displayIndices ? ( | ||
<> | ||
<EuiText> | ||
<ul> | ||
{(isShowingFullIndicesList ? displayIndices : [...displayIndices].splice(0, 10)).map( | ||
index => ( | ||
<li key={index}> | ||
<EuiTitle size="xs"> | ||
<span>{index}</span> | ||
</EuiTitle> | ||
</li> | ||
) | ||
)} | ||
</ul> | ||
</EuiText> | ||
{hiddenIndicesCount ? ( | ||
<> | ||
<EuiSpacer size="xs" /> | ||
<EuiLink | ||
onClick={() => | ||
isShowingFullIndicesList | ||
? setIsShowingFullIndicesList(false) | ||
: setIsShowingFullIndicesList(true) | ||
} | ||
> | ||
{isShowingFullIndicesList ? ( | ||
<FormattedMessage | ||
id="xpack.snapshotRestore.indicesList.indicesCollapseAllLink" | ||
defaultMessage="Hide {count, plural, one {# index} other {# indices}}" | ||
values={{ count: hiddenIndicesCount }} | ||
/> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.snapshotRestore.indicesList.indicesExpandAllLink" | ||
defaultMessage="Show {count, plural, one {# index} other {# indices}}" | ||
values={{ count: hiddenIndicesCount }} | ||
/> | ||
)}{' '} | ||
<EuiIcon type={isShowingFullIndicesList ? 'arrowUp' : 'arrowDown'} /> | ||
</EuiLink> | ||
</> | ||
) : null} | ||
</> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.snapshotRestore.indicesList.allIndicesValue" | ||
defaultMessage="All indices" | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
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
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
Oops, something went wrong.