Skip to content

Commit

Permalink
feat: remove module package name from settings
Browse files Browse the repository at this point in the history
refs: SHELL-54 (#210)
  • Loading branch information
beawar authored Feb 23, 2023
1 parent 4706a54 commit 5f41cfa
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,43 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

/* eslint-disable @typescript-eslint/ban-ts-comment */

import {
Badge,
Container,
Divider,
FormSubSection,
Text,
ThemeContext,
Tooltip
TextProps,
Tooltip,
useTheme
} from '@zextras/carbonio-design-system';
import { map } from 'lodash';
import React, { FC, useContext, useMemo } from 'react';
import { useAppList } from '../../../store/app/hooks';
import React, { useCallback, useMemo } from 'react';
import { useAppList } from '../../../store/app';

import { CarbonioModule } from '../../../../types';
import { SEARCH_APP_ID, SETTINGS_APP_ID } from '../../../constants/index';
import { SEARCH_APP_ID, SETTINGS_APP_ID } from '../../../constants';
import { getT } from '../../../store/i18n';
import { versionsSubSection } from '../../general-settings-sub-sections';

const ModuleVersionSettings: FC = () => {
const ModuleVersionSettings = (): JSX.Element => {
const apps = useAppList();
const t = getT();
const theme = useContext(ThemeContext);
const theme = useTheme();

const copyToClipboard: any = (e: any) => {
const copyToClipboard = useCallback<NonNullable<TextProps['onClick']>>((e) => {
e.preventDefault();
navigator.clipboard.writeText(e.target.innerText);
};
if (e.target instanceof HTMLElement) {
navigator.clipboard.writeText(e.target.innerText);
}
}, []);

const filteredList = useMemo(
() => apps.filter((app) => app.name !== SEARCH_APP_ID && app.name !== SETTINGS_APP_ID),
[apps]
);
const sectionTitle = useMemo(() => versionsSubSection(t), [t]);

return (
<>
<FormSubSection
Expand All @@ -50,11 +52,9 @@ const ModuleVersionSettings: FC = () => {
{map(filteredList, (app: CarbonioModule) => (
<Container key={app.name} padding={{ horizontal: 'large', vertical: 'small' }}>
<Container orientation="horizontal" mainAlignment="space-between">
<Text>
{app.display} ({app.name})
</Text>
<Text>{app.display}</Text>
<Tooltip placement="top" label={t('label.click_to_copy', 'Click to copy')}>
<Text style={{ cursor: 'pointer' }} onClick={(e: any): any => copyToClipboard(e)}>
<Text style={{ cursor: 'pointer' }} onClick={copyToClipboard}>
Version: {app.version}
</Text>
</Tooltip>
Expand All @@ -71,7 +71,7 @@ const ModuleVersionSettings: FC = () => {
backgroundColor: theme.palette.success.regular,
color: theme.palette.gray6.regular
}}
></Badge>
/>
</Container>
<Divider color="gray2" />
</Container>
Expand Down

0 comments on commit 5f41cfa

Please sign in to comment.