Skip to content

Commit

Permalink
ISPN-15105 Console black theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu Verma authored and karesti committed Oct 27, 2023
1 parent e70f1e6 commit bd12541
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 32 deletions.
14 changes: 12 additions & 2 deletions src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useContext } from 'react';

import {
Brand,
Expand All @@ -25,7 +25,8 @@ import {
ToolbarGroup,
ToolbarItem,
Tooltip,
PageSidebarBody
PageSidebarBody,
Switch
} from '@patternfly/react-core';
import {
Dropdown,
Expand All @@ -50,6 +51,7 @@ import { useConnectedUser } from '@app/services/userManagementHook';
import { KeycloakService } from '@services/keycloakService';
import { BarsIcon, ExternalLinkAltIcon, InfoCircleIcon, QuestionCircleIcon } from '@patternfly/react-icons';
import { ConsoleACL } from '@services/securityService';
import { ThemeContext } from '@app/providers/ThemeProvider';

interface IAppLayout {
init: string;
Expand All @@ -59,6 +61,7 @@ interface IAppLayout {
const AppLayout: React.FunctionComponent<IAppLayout> = ({ init, children }) => {
const { t } = useTranslation();
const brandname = t('brandname.brandname');
const {theme,toggleTheme} = useContext(ThemeContext);

const history = useHistory();
const { connectedUser } = useConnectedUser();
Expand Down Expand Up @@ -161,6 +164,13 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ init, children }) => {
align={{ default: 'alignRight' }}
spacer={{ default: 'spacerNone', md: 'spacerMd' }}
>
<Switch
id="simple-switch"
isChecked={theme === 'dark'}
onChange={toggleTheme}
ouiaId="BasicSwitch"
label=""
/>
<ToolbarItem>
<Dropdown
data-cy="aboutInfoQuestionMark"
Expand Down
10 changes: 5 additions & 5 deletions src/app/Caches/Configuration/CacheConfiguration.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useContext} from 'react';
import {
Alert,
AlertActionLink,
Expand All @@ -18,12 +18,12 @@ import {
import { useTranslation } from 'react-i18next';
import { useFetchConfigurationYAML, useFetchConfigurationXML } from '@app/services/configHook';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { githubGist } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { ThemeContext } from '@app/providers/ThemeProvider';

const CacheConfiguration = (props: { cacheName: string; editable: boolean; config: string }) => {
const { t } = useTranslation();
const encodingDocs = t('brandname.encoding-docs-link');

const {syntaxHighLighterTheme} = useContext(ThemeContext)
const yamlConfig = useFetchConfigurationYAML(props.cacheName);
const xmlConfig = useFetchConfigurationXML(props.cacheName);

Expand Down Expand Up @@ -68,7 +68,7 @@ const CacheConfiguration = (props: { cacheName: string; editable: boolean; confi
<ClipboardCopy isReadOnly isCode variant={ClipboardCopyVariant.inline}>
{config}
</ClipboardCopy>
<SyntaxHighlighter wrapLines={false} style={githubGist} useInlineStyles={true} showLineNumbers={true}>
<SyntaxHighlighter wrapLines={false} style={syntaxHighLighterTheme} useInlineStyles={true} showLineNumbers={true}>
{config}
</SyntaxHighlighter>
</CardBody>
Expand All @@ -78,7 +78,7 @@ const CacheConfiguration = (props: { cacheName: string; editable: boolean; confi

return (
<React.Fragment>
<Tabs defaultActiveKey={0} style={{ backgroundColor: 'white' }}>
<Tabs defaultActiveKey={0}>
<Tab eventKey={0} title={<TabTitleText>JSON</TabTitleText>} tabContentId="tab1" tabContentRef={contentRef1} />
<Tab eventKey={1} title={<TabTitleText>XML</TabTitleText>} tabContentId="tab2" tabContentRef={contentRef2} />
<Tab eventKey={2} title={<TabTitleText>YAML</TabTitleText>} tabContentId="tab3" tabContentRef={contentRef3} />
Expand Down
8 changes: 5 additions & 3 deletions src/app/Caches/Configuration/DetailConfigurations.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useEffect, useState } from 'react';
import { useEffect, useState, useContext } from 'react';
import {
Button,
Bullseye,
Expand Down Expand Up @@ -28,13 +28,13 @@ import { Thead, Tr, Th, Tbody, Td, ExpandableRowContent } from '@patternfly/reac
import { Table } from '@patternfly/react-table/deprecated';
import { DataContainerBreadcrumb } from '@app/Common/DataContainerBreadcrumb';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { githubGist } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { useTranslation } from 'react-i18next';
import { SearchIcon, CubeIcon } from '@patternfly/react-icons';
import { useFetchCacheTemplates } from '@app/services/cachesHook';
import { TableErrorState } from '@app/Common/TableErrorState';
import { onSearch } from '@app/utils/searchFilter';
import { global_spacer_sm, global_spacer_md } from '@patternfly/react-tokens';
import { ThemeContext } from '@app/providers/ThemeProvider';

const DetailConfigurations: React.FunctionComponent<any> = (props) => {
const { t } = useTranslation();
Expand All @@ -49,6 +49,8 @@ const DetailConfigurations: React.FunctionComponent<any> = (props) => {
perPage: 10
});

const {syntaxHighLighterTheme} = useContext(ThemeContext)

useEffect(() => {
setFilteredTemplates(cacheTemplates);
}, [cacheTemplates]);
Expand Down Expand Up @@ -223,7 +225,7 @@ const DetailConfigurations: React.FunctionComponent<any> = (props) => {
<ExpandableRowContent data-cy={row.name + 'ConfigExpanded'}>
<SyntaxHighlighter
wrapLines={false}
style={githubGist}
style={syntaxHighLighterTheme}
useInlineStyles={true}
showLineNumbers={true}
>
Expand Down
5 changes: 4 additions & 1 deletion src/app/Caches/Create/CacheConfigEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';

import {
Alert,
Expand All @@ -20,13 +20,15 @@ import { CubeIcon } from '@patternfly/react-icons';
import { useTranslation } from 'react-i18next';
import { ConsoleServices } from '@services/ConsoleServices';
import { useApiAlert } from '@app/utils/useApiAlert';
import { ThemeContext } from '@app/providers/ThemeProvider';

const CacheConfigEditor = (props: {
cmName: string;
cacheEditor: CacheEditorStep;
cacheEditorModifier: (CacheEditorStep) => void;
setReviewConfig: (string) => void;
}) => {
const {theme} = useContext(ThemeContext);
const sampleConfig =
'{\n' +
' "distributed-cache": {\n' +
Expand Down Expand Up @@ -127,6 +129,7 @@ const CacheConfigEditor = (props: {
id="cache-config"
language={Language.json}
height="200px"
isDarkTheme={theme === 'dark'}
/>
<Alert
isInline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import {
Alert,
Button,
Expand All @@ -25,8 +25,10 @@ import { useCreateCache } from '@app/services/createCacheHook';
import { FeatureCard } from '@app/Caches/Create/Features/FeatureCard';
import { PopoverHelp } from '@app/Common/PopoverHelp';
import { global_spacer_md } from '@patternfly/react-tokens';
import { ThemeContext } from '@app/providers/ThemeProvider';

const PersistentCacheConfigurator = () => {
const {theme} = useContext(ThemeContext);
const { configuration, setConfiguration } = useCreateCache();
const { t } = useTranslation();
const brandname = t('brandname.brandname');
Expand Down Expand Up @@ -155,6 +157,7 @@ const PersistentCacheConfigurator = () => {
onChange={changeAndValidate}
language={Language.json}
height={'sizeToFit'}
isDarkTheme={theme === 'dark'}
/>
{displayValidationError()}
</FormGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/app/Caches/Create/ReviewCacheConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React, { useEffect, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import { Flex, Form, FormGroup, Text, TextContent, TextVariants } from '@patternfly/react-core';
import { CodeEditor } from '@patternfly/react-code-editor';
import { useTranslation } from 'react-i18next';
import { CacheConfigUtils } from '@services/cacheConfigUtils';
import { useCreateCache } from '@app/services/createCacheHook';
import { ThemeContext } from '@app/providers/ThemeProvider';

const ReviewCacheConfig = (props: { setReviewConfig: (string) => void }) => {
const { configuration } = useCreateCache();
const { t } = useTranslation();
const [config, setConfig] = useState(CacheConfigUtils.createCacheConfigFromData(configuration));
const {theme} = useContext(ThemeContext);

useEffect(() => {
const jsonFormatConfig = CacheConfigUtils.createCacheConfigFromData(configuration);
Expand All @@ -30,6 +32,7 @@ const ReviewCacheConfig = (props: { setReviewConfig: (string) => void }) => {
code={config}
height="sizeToFit"
isCopyEnabled
isDarkTheme={theme === 'dark'}
copyButtonSuccessTooltipText={t('caches.create.review.copied-tooltip')}
copyButtonToolTipText={t('caches.create.review.copy-tooltip')}
/>
Expand Down
8 changes: 5 additions & 3 deletions src/app/Caches/Entries/CacheEntries.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useContext } from 'react';
import {
Bullseye,
Button,
Expand Down Expand Up @@ -28,7 +28,6 @@ import { ActionsColumn, IAction, Table, Tbody, Td, Th, Thead, Tr } from '@patter
import { FilterIcon, HelpIcon, PlusCircleIcon, SearchIcon } from '@patternfly/react-icons';
import { global_spacer_md, global_spacer_sm } from '@patternfly/react-tokens';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { githubGist } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import displayUtils from '@services/displayUtils';
import { useTranslation } from 'react-i18next';
import { useCacheDetail, useCacheEntries } from '@app/services/cachesHook';
Expand All @@ -40,6 +39,7 @@ import { ContentType, EncodingType } from '@services/infinispanRefData';
import { CreateOrUpdateEntryForm } from '@app/Caches/Entries/CreateOrUpdateEntryForm';
import { ClearAllEntries } from '@app/Caches/Entries/ClearAllEntries';
import { DeleteEntry } from '@app/Caches/Entries/DeleteEntry';
import { ThemeContext } from '@app/providers/ThemeProvider';

const CacheEntries = (props: { cacheName: string }) => {
const { cacheEntries, totalEntriesCount, loadingEntries, errorEntries, infoEntries, reloadEntries, getByKey } =
Expand All @@ -64,6 +64,8 @@ const CacheEntries = (props: { cacheName: string }) => {
perPage: 10
});

const {syntaxHighLighterTheme} = useContext(ThemeContext)

useEffect(() => {
if (cache.encoding.key == EncodingType.Protobuf) {
setSelectSearchOption(ContentType.string);
Expand Down Expand Up @@ -145,7 +147,7 @@ const CacheEntries = (props: { cacheName: string }) => {
<SyntaxHighlighter
language="json"
lineProps={{ style: { wordBreak: 'break-all' } }}
style={githubGist}
style={syntaxHighLighterTheme}
useInlineStyles={true}
wrapLongLines={true}
>
Expand Down
9 changes: 6 additions & 3 deletions src/app/Caches/Query/QueryEntries.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect,useContext } from 'react';
import {
Bullseye,
Button,
Expand All @@ -20,12 +20,12 @@ import {
import { SearchIcon, ExclamationCircleIcon, HelpIcon } from '@patternfly/react-icons';
import displayUtils from '../../../services/displayUtils';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { githubGist } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { useTranslation } from 'react-i18next';
import { ConsoleServices } from '@services/ConsoleServices';
import { Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
import { Table } from '@patternfly/react-table/deprecated';
import { global_danger_color_200, global_spacer_md, global_spacer_sm } from '@patternfly/react-tokens';
import { ThemeContext } from '@app/providers/ThemeProvider';

const QueryEntries = (props: { cacheName: string; indexed: boolean; changeTab: () => void }) => {
const [query, setQuery] = useState<string>('');
Expand All @@ -41,6 +41,9 @@ const QueryEntries = (props: { cacheName: string; indexed: boolean; changeTab: (
total: 0
});

const {syntaxHighLighterTheme} = useContext(ThemeContext)


const columnNames = {
value: 'Value'
};
Expand All @@ -57,7 +60,7 @@ const QueryEntries = (props: { cacheName: string; indexed: boolean; changeTab: (
return (
<SyntaxHighlighter
lineProps={{ style: { wordBreak: 'break-all' } }}
style={githubGist}
style={syntaxHighLighterTheme}
useInlineStyles={true}
wrapLongLines={true}
>
Expand Down
15 changes: 12 additions & 3 deletions src/app/Common/Health.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import React from 'react';
import React,{useContext} from 'react';
import { Flex, FlexItem, Text, TextContent } from '@patternfly/react-core';
import { AlertIcon } from '@patternfly/react-core/dist/js/components/Alert/AlertIcon';
import displayUtils from '@services/displayUtils';
import { ComponentHealth } from '@services/infinispanRefData';
import { ThemeContext } from '@app/providers/ThemeProvider';
import { chart_global_label_Fill, global_Color_light_100 } from '@patternfly/react-tokens';

const Health = (props: { health: string; displayIcon?: boolean; cacheName?: string }) => {
const health = ComponentHealth[props.health];
const displayIcon = props.displayIcon == undefined ? true : props.displayIcon;

const {theme} = useContext(ThemeContext);

const getHealthLabelColor = ()=>{
const color = displayUtils.healthColor(health, false);
return (theme === 'dark' && color === chart_global_label_Fill.value)
? global_Color_light_100.value
: color;
}
return (
<Flex>
{displayIcon && (
Expand All @@ -28,7 +37,7 @@ const Health = (props: { health: string; displayIcon?: boolean; cacheName?: stri
<Text
data-cy={`health-${props.cacheName}`}
style={{
color: displayUtils.healthColor(health, false)
color: getHealthLabelColor()
}}
>
{displayUtils.healthLabel(health)}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Common/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Status = (props: { status?: Status }) => {
</FlexItem>
<FlexItem>
<TextContent>
<Text component={TextVariants.p} style={{ color: chart_global_label_Fill.value }}>
<Text component={TextVariants.p}>
{status.name}
</Text>
</TextContent>
Expand Down
7 changes: 4 additions & 3 deletions src/app/ProtoSchema/ProtobufSchemasDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useContext } from 'react';
import {
Alert,
AlertVariant,
Expand Down Expand Up @@ -26,7 +26,6 @@ import { Table, Thead, Tr, Th, Tbody, Td, ExpandableRowContent, ActionsColumn, I
import { DatabaseIcon, SearchIcon } from '@patternfly/react-icons';
import { global_spacer_md, global_spacer_sm, global_spacer_xl } from '@patternfly/react-tokens';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { githubGist } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { useApiAlert } from '@app/utils/useApiAlert';
import { useTranslation } from 'react-i18next';
import { ConsoleServices } from '@services/ConsoleServices';
Expand All @@ -38,6 +37,7 @@ import { EditSchema } from './EditSchema';
import { useFetchProtobufSchemas } from '@app/services/protobufHooks';
import { onSearch } from '@app/utils/searchFilter';
import './ProtobufSchemasDisplay.css';
import { ThemeContext } from '@app/providers/ThemeProvider';

const ProtobufSchemasDisplay = (props: { setProtoSchemasCount: (number) => void; isVisible: boolean }) => {
const { t } = useTranslation();
Expand All @@ -59,6 +59,7 @@ const ProtobufSchemasDisplay = (props: { setProtoSchemasCount: (number) => void;
page: 1,
perPage: 10
});
const {syntaxHighLighterTheme} = useContext(ThemeContext)

const isSchemaExpanded = (row) => expandedSchemaNames.includes(row.name);

Expand Down Expand Up @@ -217,7 +218,7 @@ const ProtobufSchemasDisplay = (props: { setProtoSchemasCount: (number) => void;

return (
<ExpandableRowContent>
<SyntaxHighlighter wrapLines={false} style={githubGist} useInlineStyles={true} showLineNumbers={true}>
<SyntaxHighlighter wrapLines={false} style={syntaxHighLighterTheme} useInlineStyles={true} showLineNumbers={true}>
{schemasContent.get(name)}
</SyntaxHighlighter>
</ExpandableRowContent>
Expand Down
1 change: 0 additions & 1 deletion src/app/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const Welcome = (props) => {
}}
component={'button'}
className={'button'}
style={{ backgroundColor: global_BackgroundColor_100.value }}
>
<Text style={{ color: chart_color_blue_500.value }}>{goToTheConsole}</Text>
</Button>
Expand Down
Loading

0 comments on commit bd12541

Please sign in to comment.