Skip to content

Commit

Permalink
[MD] Add initial credential management CRUD pages (#2040)
Browse files Browse the repository at this point in the history
* Add credential management CRUD pages

1. List all credentials 
2. Create your saved credential
3. Edit your credential
4. Delete credentials

Signed-off-by: Louis Chu <[email protected]>
  • Loading branch information
noCharger authored Aug 3, 2022
1 parent 2abcc21 commit 18278a1
Show file tree
Hide file tree
Showing 29 changed files with 1,070 additions and 251 deletions.
27 changes: 0 additions & 27 deletions src/plugins/credential_management/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/plugins/credential_management/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
*/

export const PLUGIN_ID = 'credentialManagement';
export const PLUGIN_NAME = 'credentialManagement';
export const PLUGIN_NAME = 'credential_management';
7 changes: 3 additions & 4 deletions src/plugins/credential_management/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"id": "credentialManagement",
"version": "1.0.0",
"opensearchDashboardsVersion": "opensearchDashboards",
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["navigation"],
"optionalPlugins": []
"requiredPlugins": ["management"],
"requiredBundles": ["opensearchDashboardsReact"]
}
28 changes: 0 additions & 28 deletions src/plugins/credential_management/public/application.tsx

This file was deleted.

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

This file was deleted.

40 changes: 40 additions & 0 deletions src/plugins/credential_management/public/components/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { CredentialEditPageItem } from './types';

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`,
},
];
}

export function getEditBreadcrumbs(credentials: CredentialEditPageItem) {
return [
...getListBreadcrumbs(),
{
text: credentials.title,
href: `/${credentials.id}`,
},
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

// @ts-ignore
import { euiColorAccent } from '@elastic/eui/dist/eui_theme_light.json';
import React from 'react';
import * as H from 'history';

import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';

interface Props {
history: H.History;
}

export const CreateButton = ({ history }: Props) => {
return (
<EuiButton
data-test-subj="createCredentialButton"
fill={true}
onClick={() => history.push('/create')}
iconType="plusInCircle"
>
<FormattedMessage
id="credentialManagement.credentialsTable.createBtn"
defaultMessage="Save your credential"
/>
</EuiButton>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { CreateButton } from './create_button';
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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';
export const Header = ({ docLinks }: { docLinks: DocLinksStart }) => {
const changeTitle = useOpenSearchDashboards<CredentialManagementContext>().services.chrome
.docTitle.change;
const createCredentialHeader = i18n.translate('credentialManagement.createIndexPatternHeader', {
defaultMessage: 'Save Your Credential',
});

changeTitle(createCredentialHeader);

return (
<div>
<EuiTitle>
<h1>
{createCredentialHeader}
<>
{' '}
<EuiBetaBadge
label={i18n.translate('credentialManagement.createCredential.betaLabel', {
defaultMessage: 'Beta',
})}
/>
</>
</h1>
</EuiTitle>
<EuiSpacer size="s" />
<EuiText>
<p>
<FormattedMessage
id="credentialManagement.createCredential.description"
defaultMessage="A credential can be attached to multiple sources. For example, {credential} can be attached to two data sources {first} and {second}."
values={{
credential: <EuiCode>username-password-credential</EuiCode>,
first: <EuiCode>os-service-log</EuiCode>,
second: <EuiCode>os-application-log</EuiCode>,
}}
/>
<br />
<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,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { Header } from './header';
Loading

0 comments on commit 18278a1

Please sign in to comment.