Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove module package name from settings #210

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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