Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Commit

Permalink
Add keys (#39)
Browse files Browse the repository at this point in the history
* add keys

* Add keys
  • Loading branch information
carlosthe19916 committed Jun 6, 2021
1 parent f7bdb95 commit 7c135aa
Show file tree
Hide file tree
Showing 37 changed files with 1,799 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AppRoutes } from "./Routes";
import "./App.scss";

import { DefaultLayout } from "./layout";
import { ConfirmDialogContainer } from "./shared/containers/confirm-dialog-container";

import NotificationsPortal from "@redhat-cloud-services/frontend-components-notifications/NotificationPortal";
import "@redhat-cloud-services/frontend-components-notifications/index.css";
Expand All @@ -16,6 +17,7 @@ const App: React.FC = () => {
<AppRoutes />
</DefaultLayout>
<NotificationsPortal />
<ConfirmDialogContainer />
</BrowserRouter>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const DEFAULT_PAGINATION: PageQuery = {
};

export const DEFAULT_SELECT_MAX_HEIGHT = "350";

export const DEFAULT_KEY_ALGORITHM = "RS256";
12 changes: 12 additions & 0 deletions src/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export enum Paths {
editCompany = "/ns-company/:namespaceId/companies/:companyId",
editCompany_overview = "/ns-company/:namespaceId/companies/:companyId/overview",
editCompany_details = "/ns-company/:namespaceId/companies/:companyId/details",
editCompany_keys = "/ns-company/:namespaceId/companies/:companyId/keys",
editCompany_keys_new = "/ns-company/:namespaceId/companies/:companyId/keys/:providerId/~new",
editCompany_keys_edit = "/ns-company/:namespaceId/companies/:companyId/keys/:providerId/:componentId",

// Documents
documentList_empty = "/ns-document/select-company",
Expand All @@ -44,3 +47,12 @@ export interface CompanyRoute {
namespaceId: string;
companyId: string;
}

export interface NewKeyRoute extends CompanyRoute {
providerId: string;
}

export interface EditKeyRoute extends CompanyRoute {
providerId: string;
componentId: string;
}
58 changes: 58 additions & 0 deletions src/api/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,61 @@ export interface UBLDocumentEvent {
description: string;
createdOn: number;
}

//

export interface ServerInfoRepresentation {
componentTypes: ComponentTypes;
}

export interface KeysMetadataRepresentation {
active: { [key: string]: string };
keys: KeyMetadataRepresentation[];
}

export interface KeyMetadataRepresentation {
providerId: string;
providerPriority: number;
kid: string;
status: "ACTIVE" | "PASSIVE" | "DISABLED";
type: string;
algorithm: string;
publicKey: string;
certificate: string;
// This does not come from backend but from UI
provider?: ComponentRepresentation;
}

export interface ComponentRepresentation {
id: string;
name: string;
providerId: string;
providerType: string;
parentId: string;
subType: string;
config: { [key: string]: string[] };
}

export interface ServerInfoRepresentation {
componentTypes: ComponentTypes;
}

export interface ComponentTypes {
keyProviders: ComponentTypeRepresentation[];
}

export interface ComponentTypeRepresentation {
id: string;
helpText: string;
properties: ConfigPropertyRepresentation[];
}

export interface ConfigPropertyRepresentation {
name: string;
label: string;
helpText: string;
type: string;
defaultValue: string;
options: string[];
secret: boolean;
}
84 changes: 84 additions & 0 deletions src/api/rest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
PageQuery,
PageRepresentation,
Namespace,
KeysMetadataRepresentation,
ComponentRepresentation,
ServerInfoRepresentation,
} from "./models";

const USER_NAMESPACES = "/user/namespaces";
Expand Down Expand Up @@ -43,6 +46,12 @@ const buildQuery = (params: any) => {
return query;
};

// Server info

export const getServerInfo = (): AxiosPromise<ServerInfoRepresentation> => {
return APIClient.get("/server-info");
};

//

export enum NamespaceSortBy {
Expand Down Expand Up @@ -190,6 +199,81 @@ export const getCompany = (
);
};

export const getCompanyKeys = (
namespaceId: string,
companyId: string
): AxiosPromise<KeysMetadataRepresentation> => {
return APIClient.get(
`${COMPANIES.replaceAll(":namespaceId", namespaceId)}/${companyId}/keys`
);
};

export const getCompanyComponents = (
namespaceId: string,
companyId: string
): AxiosPromise<ComponentRepresentation[]> => {
return APIClient.get(
`${COMPANIES.replaceAll(
":namespaceId",
namespaceId
)}/${companyId}/components`
);
};

export const createCompanyComponent = (
namespaceId: string,
companyId: string,
component: ComponentRepresentation
): AxiosPromise<ComponentRepresentation> => {
return APIClient.post(
`${COMPANIES.replaceAll(
":namespaceId",
namespaceId
)}/${companyId}/components`,
component
);
};

export const updateCompanyComponent = (
namespaceId: string,
companyId: string,
component: ComponentRepresentation
): AxiosPromise<ComponentRepresentation> => {
return APIClient.put(
`${COMPANIES.replaceAll(
":namespaceId",
namespaceId
)}/${companyId}/components/${component.id}`,
component
);
};

export const getCompanyComponent = (
namespaceId: string,
companyId: string,
componentId: string
): AxiosPromise<ComponentRepresentation> => {
return APIClient.get(
`${COMPANIES.replaceAll(
":namespaceId",
namespaceId
)}/${companyId}/components/${componentId}`
);
};

export const deleteCompanyComponent = (
namespaceId: string,
companyId: string,
componentId: string
): AxiosPromise => {
return APIClient.delete(
`${COMPANIES.replaceAll(
":namespaceId",
namespaceId
)}/${companyId}/components/${componentId}`
);
};

//

export enum UBLDocumentSortBy {
Expand Down
7 changes: 7 additions & 0 deletions src/pages/companies/edit-company/edit-company-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export const EditCompanyHeader: React.FC<EditCompanyHeaderProps> = () => {
companyId,
}),
},
{
title: "Certificados",
path: formatPath(Paths.editCompany_keys, {
namespaceId,
companyId,
}),
},
]}
/>
</ConditionalRender>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/companies/edit-company/edit-company.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EditCompanyHeader } from "./edit-company-header";

const Overview = lazy(() => import("./overview"));
const Details = lazy(() => import("./details"));
const Keys = lazy(() => import("./keys"));

export interface AnalysisConfigurationProps
extends RouteComponentProps<NamespaceRoute> {}
Expand All @@ -25,6 +26,7 @@ export const EditCompany: React.FC<AnalysisConfigurationProps> = () => {
<Switch>
<Route path={Paths.editCompany_overview} component={Overview} />
<Route path={Paths.editCompany_details} component={Details} />
<Route path={Paths.editCompany_keys} component={Keys} />

<Redirect
from={Paths.editCompany}
Expand Down
1 change: 1 addition & 0 deletions src/pages/companies/edit-company/keys/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Keys as default } from "./keys";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { KeyForm } from "./key-form";
Loading

0 comments on commit 7c135aa

Please sign in to comment.