-
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.
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.
- Loading branch information
John Dorlus
committed
Feb 14, 2020
1 parent
65aff58
commit 2edaacb
Showing
7 changed files
with
96 additions
and
106 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
77 changes: 0 additions & 77 deletions
77
x-pack/legacy/plugins/snapshot_restore/public/app/components/show_hide_indices.tsx
This file was deleted.
Oops, something went wrong.
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