Skip to content
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

[MD][Cred mngment] - PoC Create credential #9

Merged
merged 3 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/plugins/credential_management/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* GitHub history for details.
*/

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

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

export { ICredential, IBasicAuthCredentialMaterial, IAWSIAMCredentialMaterial };
export { Credential };
18 changes: 12 additions & 6 deletions src/plugins/credential_management/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
* GitHub history for details.
*/

interface ICredential {
// TODO: refactor the credential in heritance:
// Credential -> USERNAMEANDPASSWORDCredential
// -> AWSIAMCredential
export interface ICredential {
readonly credential_name: string;
readonly credential_type: string;
readonly credential_type: CredentialType;
readonly credential_material: IBasicAuthCredentialMaterial | IAWSIAMCredentialMaterial;
}

interface IBasicAuthCredentialMaterial {
export type CredentialType = USERNAMEANDPASSWORDTYPE | AWSIAMTYPE;
// TODO: Update server side
export type USERNAMEANDPASSWORDTYPE = 'basic_auth';
export type AWSIAMTYPE = 'aws_iam_credential';

export interface IBasicAuthCredentialMaterial {
readonly user_name: string;
readonly password: string;
}

interface IAWSIAMCredentialMaterial {
export interface IAWSIAMCredentialMaterial {
readonly encrypted_aws_iam_credential: string;
noCharger marked this conversation as resolved.
Show resolved Hide resolved
}

export { ICredential, IBasicAuthCredentialMaterial, IAWSIAMCredentialMaterial };
24 changes: 24 additions & 0 deletions src/plugins/credential_management/public/components/breadsrumbs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { i18n } from '@osd/i18n';
noCharger marked this conversation as resolved.
Show resolved Hide resolved

export function getListBreadcrumbs() {
return [
{
text: i18n.translate('credentialManagement.credentials.listBreadcrumb', {
defaultMessage: 'Credentials',
}),
href: `/`,
},
];
}

export function getCreateBreadcrumbs() {
return [
...getListBreadcrumbs(),
{
text: i18n.translate('credentialManagement.credentials.createBreadcrumb', {
defaultMessage: 'Create credentials',
}),
href: `/create`,
},
];
}
noCharger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// @ts-ignore
import { euiColorAccent } from '@elastic/eui/dist/eui_theme_light.json';
import React, { Component, Fragment } from 'react';
import React from 'react';

import {
EuiBadge,
Expand Down Expand Up @@ -40,7 +40,7 @@ interface Props {
}>;
}

export class CreateButton extends Component<Props, State> {
export class CreateButton extends React.Component<Props, State> {
public state = {
isPopoverOpen: false,
};
Expand Down Expand Up @@ -100,7 +100,7 @@ export class CreateButton extends Component<Props, State> {
<EuiDescriptionList style={{ whiteSpace: 'nowrap' }}>
<EuiDescriptionListTitle>
{option.text}
{option.isBeta ? <Fragment> {this.renderBetaBadge()}</Fragment> : null}
{option.isBeta ? <React.Fragment> {this.renderBetaBadge()}</React.Fragment> : null}
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{option.description}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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.
*/

import React from 'react';

import { EuiBetaBadge, EuiSpacer, EuiTitle, EuiText, EuiCode, EuiLink } from '@elastic/eui';

import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { DocLinksStart } from 'opensearch-dashboards/public';
import { useOpenSearchDashboards } from '../../../../../../opensearch_dashboards_react/public';
import { CredentialManagementContext } from '../../../../types';
// TODO: Update the header content
export const Header = ({
isBeta = true,
docLinks,
}: {
isBeta?: boolean;
docLinks: DocLinksStart;
}) => {
const changeTitle = useOpenSearchDashboards<CredentialManagementContext>().services.chrome
.docTitle.change;
const createCredentialHeader = i18n.translate('credentialManagement.createIndexPatternHeader',
{
defaultMessage: 'Create Credential',
}
);

changeTitle(createCredentialHeader);

return (
<div>
<EuiTitle>
<h1>
{createCredentialHeader}
{isBeta ? (
<>
{' '}
<EuiBetaBadge
label={i18n.translate('credentialManagement.createCredential.betaLabel', {
defaultMessage: 'Beta',
})}
/>
</>
) : null}
</h1>
</EuiTitle>
<EuiSpacer size="s" />
<EuiText>
<p>
<FormattedMessage
id="credentialManagement.createCredential.description"
defaultMessage="An credential can be attached to multiple sources. For example, {credential} can be attached to two data sources {first} and {second}."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo An credential

values={{
credential: <EuiCode>username-password-credential</EuiCode>,
first: <EuiCode>os-service-log</EuiCode>,
second: <EuiCode>os-application-log</EuiCode>,
}}
/>
<br />
{/* // <HeaderBreadcrumbs /> */}
<EuiLink
href={docLinks.links.noDocumentation.indexPatterns.introduction}
target="_blank"
external
>
<FormattedMessage
id="credentialManagement.createCredential.documentation"
defaultMessage="Read documentation"
/>
</EuiLink>
</p>
</EuiText>
{prompt ? (
<>
<EuiSpacer size="m" />
{prompt}
</>
) : null}
</div>
);
};
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 { Header } from './header';
Loading