21224: fixed description html rendering
[arvados.git] / services / workbench2 / src / views-components / details-card / root-details-card.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { RootState } from 'store/store';
7 import { connect } from 'react-redux';
8 import { getResource } from 'store/resources/resources';
9 import { ProjectResource } from 'models/project';
10 import { ResourceKind } from 'models/resource';
11 import { UserResource } from 'models/user';
12 import { UserCard } from './user-details-card';
13 import { ProjectCard } from './project-details-card';
14
15 const mapStateToProps = ({ resources, properties }: RootState) => {
16     const currentResource = getResource(properties.currentRouteUuid)(resources);
17
18     return {
19         currentResource,
20     };
21 };
22
23 type DetailsCardProps = {
24     currentResource: ProjectResource | UserResource;
25 };
26
27 export const RootDetailsCard = connect(mapStateToProps)(({ currentResource }: DetailsCardProps) => {
28     if (!currentResource) {
29         return null;
30     }
31     switch (currentResource.kind as string) {
32         case ResourceKind.USER:
33             return <UserCard />;
34         case ResourceKind.PROJECT:
35             return <ProjectCard />;
36         default:
37             return null;
38     }
39 });