displayName of components is now taken from WebSettingsContext

This commit is contained in:
Mose Müller
2023-12-21 10:30:21 +01:00
parent 9fc6d6f910
commit 9d90fd2b81
11 changed files with 95 additions and 25 deletions

View File

@@ -1,10 +1,11 @@
import { useState } from 'react';
import { useContext, useState } from 'react';
import React from 'react';
import { Card, Collapse } from 'react-bootstrap';
import { ChevronDown, ChevronRight } from 'react-bootstrap-icons';
import { Attribute, GenericComponent } from './GenericComponent';
import { getIdFromFullAccessPath } from '../utils/stringUtils';
import { LevelName } from './NotificationsComponent';
import { WebSettingsContext } from '../WebSettings';
type DataServiceProps = {
name: string;
@@ -31,6 +32,13 @@ export const DataServiceComponent = React.memo(
}
const id = getIdFromFullAccessPath(fullAccessPath);
const webSettings = useContext(WebSettingsContext);
let displayName = fullAccessPath;
if (webSettings[fullAccessPath] && webSettings[fullAccessPath].displayName) {
displayName = webSettings[fullAccessPath].displayName;
}
return (
<div className="dataServiceComponent" id={id}>
<Card className="mb-3">
@@ -38,7 +46,7 @@ export const DataServiceComponent = React.memo(
onClick={() => setOpen(!open)}
style={{ cursor: 'pointer' }} // Change cursor style on hover
>
{fullAccessPath} {open ? <ChevronDown /> : <ChevronRight />}
{displayName} {open ? <ChevronDown /> : <ChevronRight />}
</Card.Header>
<Collapse in={open}>
<Card.Body>