forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MD][Cred mngment] - PoC List all credentials (opensearch-project#8)
1. Move Credential Management within Stack Management 2. Find all credentials and list their names 3. Add credential creation button
- Loading branch information
Showing
25 changed files
with
993 additions
and
184 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
interface ICredential { | ||
readonly credential_name: string; | ||
readonly credential_type: string; | ||
readonly credential_material: IBasicAuthCredentialMaterial | IAWSIAMCredentialMaterial; | ||
} | ||
|
||
interface IBasicAuthCredentialMaterial { | ||
readonly user_name: string; | ||
readonly password: string; | ||
} | ||
|
||
interface IAWSIAMCredentialMaterial { | ||
readonly encrypted_aws_iam_credential: string; | ||
} | ||
|
||
export { ICredential, IBasicAuthCredentialMaterial, IAWSIAMCredentialMaterial }; |
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 was deleted.
Oops, something went wrong.
119 changes: 0 additions & 119 deletions
119
src/plugins/credential_management/public/components/app.tsx
This file was deleted.
Oops, something went wrong.
140 changes: 140 additions & 0 deletions
140
src/plugins/credential_management/public/components/create_button/create_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,140 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
// @ts-ignore | ||
import { euiColorAccent } from '@elastic/eui/dist/eui_theme_light.json'; | ||
import React, { Component, Fragment } from 'react'; | ||
|
||
import { | ||
EuiBadge, | ||
EuiButton, | ||
EuiContextMenuItem, | ||
EuiContextMenuPanel, | ||
EuiDescriptionList, | ||
EuiDescriptionListDescription, | ||
EuiDescriptionListTitle, | ||
EuiPopover, | ||
} from '@elastic/eui'; | ||
|
||
import { FormattedMessage } from '@osd/i18n/react'; | ||
|
||
interface State { | ||
isPopoverOpen: boolean; | ||
} | ||
|
||
interface Props { | ||
options: Array<{ | ||
text: string; | ||
description?: string; | ||
testSubj?: string; | ||
isBeta?: boolean; | ||
onClick: () => void; | ||
}>; | ||
} | ||
|
||
export class CreateButton extends Component<Props, State> { | ||
public state = { | ||
isPopoverOpen: false, | ||
}; | ||
|
||
public render() { | ||
const { options, children } = this.props; | ||
const { isPopoverOpen } = this.state; | ||
|
||
if (!options || !options.length) { | ||
return null; | ||
} | ||
|
||
if (options.length === 1) { | ||
return ( | ||
<EuiButton | ||
data-test-subj="createCredentialButton" | ||
fill={true} | ||
onClick={options[0].onClick} | ||
iconType="plusInCircle" | ||
> | ||
{children} | ||
</EuiButton> | ||
); | ||
} | ||
|
||
const button = ( | ||
<EuiButton | ||
data-test-subj="createCredentialButton" | ||
fill={true} | ||
size="s" | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={this.togglePopover} | ||
> | ||
{children} | ||
</EuiButton> | ||
); | ||
|
||
if (options.length > 1) { | ||
return ( | ||
<EuiPopover | ||
id="singlePanel" | ||
button={button} | ||
isOpen={isPopoverOpen} | ||
closePopover={this.closePopover} | ||
panelPaddingSize="none" | ||
anchorPosition="downLeft" | ||
> | ||
<EuiContextMenuPanel | ||
items={options.map((option) => { | ||
return ( | ||
<EuiContextMenuItem | ||
key={option.text} | ||
onClick={option.onClick} | ||
data-test-subj={option.testSubj} | ||
> | ||
<EuiDescriptionList style={{ whiteSpace: 'nowrap' }}> | ||
<EuiDescriptionListTitle> | ||
{option.text} | ||
{option.isBeta ? <Fragment> {this.renderBetaBadge()}</Fragment> : null} | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription> | ||
{option.description} | ||
</EuiDescriptionListDescription> | ||
</EuiDescriptionList> | ||
</EuiContextMenuItem> | ||
); | ||
})} | ||
/> | ||
</EuiPopover> | ||
); | ||
} | ||
} | ||
|
||
private togglePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: !this.state.isPopoverOpen, | ||
}); | ||
}; | ||
|
||
private closePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: false, | ||
}); | ||
}; | ||
|
||
private renderBetaBadge = () => { | ||
return ( | ||
<EuiBadge color={euiColorAccent}> | ||
<FormattedMessage | ||
id="credentialManagement.createButton.betaLabel" | ||
defaultMessage="Beta" | ||
/> | ||
</EuiBadge> | ||
); | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/plugins/credential_management/public/components/create_button/index.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,12 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
export { CreateButton } from './create_button'; |
10 changes: 10 additions & 0 deletions
10
...ential_management/public/components/create_credential_wizard/create_credential_wizard.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,10 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ |
12 changes: 12 additions & 0 deletions
12
src/plugins/credential_management/public/components/create_credential_wizard/index.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,12 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
export { CreateCredentialWizardWithRouter } from './create_credential_wizard'; |
Oops, something went wrong.