Skip to content

Commit

Permalink
[MD][Cred mngment] - PoC List all credentials (opensearch-project#8)
Browse files Browse the repository at this point in the history
1. Move Credential Management within Stack Management
2. Find all credentials and list their names
3. Add credential creation button
  • Loading branch information
noCharger committed Jul 5, 2022
1 parent 6882997 commit a739c28
Show file tree
Hide file tree
Showing 25 changed files with 993 additions and 184 deletions.
6 changes: 5 additions & 1 deletion src/plugins/credential_management/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
* GitHub history for details.
*/

import { ICredential, IBasicAuthCredentialMaterial, IAWSIAMCredentialMaterial } from './types';

export const PLUGIN_ID = 'credentialManagement';
export const PLUGIN_NAME = 'credentialManagement';
export const PLUGIN_NAME = 'Credential Management';

export { ICredential, IBasicAuthCredentialMaterial, IAWSIAMCredentialMaterial };
27 changes: 27 additions & 0 deletions src/plugins/credential_management/common/types.ts
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 };
5 changes: 3 additions & 2 deletions src/plugins/credential_management/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"opensearchDashboardsVersion": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["management", "data", "navigation"],
"optionalPlugins": []
"requiredPlugins": ["management", "data", "navigation", "urlForwarding"],
"optionalPlugins": [],
"requiredBundles": ["opensearchDashboardsReact"]
}
23 changes: 0 additions & 23 deletions src/plugins/credential_management/public/application.tsx

This file was deleted.

119 changes: 0 additions & 119 deletions src/plugins/credential_management/public/components/app.tsx

This file was deleted.

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>
);
};
}
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';
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.
*/
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';
Loading

0 comments on commit a739c28

Please sign in to comment.