Skip to content

Commit

Permalink
DT-1442 Fixes error/warnings on dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
francostramana committed Jan 2, 2024
1 parent 8307e43 commit 82056d3
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 76 deletions.
3 changes: 2 additions & 1 deletion assets/i18n/en/Tooltip.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
"Detected": "Detected",
"NotDetected": "Not Detected",
"Ignored": "Ignored",
"Progress": "Progress"
"Progress": "Progress",
"RefreshReportButtonLabel": "Update report for the latest vulnerabilities and cryptography data"
}
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
},
"dependencies": {
"@electron/rebuild": "^3.2.13",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.8.4",
"@mui/lab": "^5.0.0-alpha.89",
"@mui/material": "^5.8.7",
Expand Down
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/api/services/cryptography.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ class CryptographyService extends BaseService {
}
}



export const cryptographyService = new CryptographyService();

document.crypto = cryptographyService;
10 changes: 4 additions & 6 deletions src/api/services/vulnerability.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VulnerabilitiesGetAllDTO } from "@api/dto";
import { IpcChannels } from "@api/ipc-channels";
import { ComponentVulnerability } from "main/model/entity/ComponentVulnerability";
import { BaseService } from "./base.service";
import { VulnerabilitiesGetAllDTO } from '@api/dto';
import { IpcChannels } from '@api/ipc-channels';
import { ComponentVulnerability } from 'main/model/entity/ComponentVulnerability';
import { BaseService } from './base.service';

class VulnerabilityService extends BaseService {
public async getAll(params: VulnerabilitiesGetAllDTO): Promise<ComponentVulnerability[]> {
Expand All @@ -16,5 +16,3 @@ class VulnerabilityService extends BaseService {
}

export const vulnerabilityService = new VulnerabilityService();

document.vul = vulnerabilityService;
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const createWindow = async () => {

mainWindow = new BrowserWindow({
show: false,
width: 1300,
width: 1330,
height: 820,
icon: getAssetPath('icon.png'),
webPreferences: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const LicenseSelector: React.FC<Partial<LicenseSelectorProps>> = (props) => {
InputProps={{
...params.InputProps,
startAdornment: <SearchIcon />,
disableUnderline: true,
className: 'autocomplete-option',
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ const CryptographyDataTable = ({ data }) => {

// empty
if (!data || data.length === 0) {
return <p className="text-center mt-5 mb-3">{t('NoData')}</p>;
return (
<div className="empty-table">
<p className="text-center mt-5 mb-3">{t('NoDataFound')}</p>
</div>
);
}

return (
Expand All @@ -57,6 +61,7 @@ const CryptographyDataTable = ({ data }) => {
rowGetter={({ index }) => items.current[index]}
headerClassName={classes.headerColumn}
rowClassName={classes.row}
index={(index) => `${items.current[index].purl}@${items.current[index].version}`}
>
<Column label={t('Table:Header:PURL')} dataKey="purl" width={200} flexGrow={1} flexShrink={0} />
<Column label={t('Table:Header:Version')} dataKey="version" width={100} flexGrow={1} flexShrink={0} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { Chart, registerables } from 'chart.js';
import {
Button,
Card, IconButton, Tab, Tabs,
Card, IconButton, Tab, Tabs, Tooltip,
} from '@mui/material';
import obligationsService from '@api/services/obligations.service';
import ArrowForwardOutlinedIcon from '@mui/icons-material/ArrowForwardOutlined';
Expand Down Expand Up @@ -108,17 +108,20 @@ const DetectedReport = ({ data, onRefresh }) => {
</ConditionalLink>
</Card>

<Tabs value={tab} onChange={(e, value) => setTab(value)} className="tabs-navigator">
<Tab value="matches" label={t('Title:MatchedTab')} />
{ layers.current.has(Scanner.ScannerType.DEPENDENCIES) && <Tab value="dependencies" label={t('Title:DeclaredDependenciesTab')} />}
<Tab value="obligations" label={t('Title:ObligationsTab')} />
{ layers.current.has(Scanner.ScannerType.CRYPTOGRAPHY) && <Tab value="cryptography" label={t('Title:CryptographyTab')} />}
<div className="refresh-btn-container">
<div className="tabs-navigator">
<Tabs value={tab} onChange={(e, value) => setTab(value)}>
<Tab value="matches" label={t('Title:MatchedTab')} />
{ layers.current.has(Scanner.ScannerType.DEPENDENCIES) && <Tab value="dependencies" label={t('Title:DeclaredDependenciesTab')} />}
<Tab value="obligations" label={t('Title:ObligationsTab')} />
{ layers.current.has(Scanner.ScannerType.CRYPTOGRAPHY) && <Tab value="cryptography" label={t('Title:CryptographyTab')} />}
</Tabs>

<Tooltip title={t('Tooltip:RefreshReportButtonLabel')} classes={{ tooltip: 'tooltip' }}>
<IconButton onClick={onRefresh}>
<RefreshIcon />
</IconButton>
</div>
</Tabs>
</Tooltip>
</div>

{tab === 'matches' && (
<Card className="report-item matches-for-license">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import { Chart, registerables } from 'chart.js';
import InsertDriveFileOutlinedIcon from '@mui/icons-material/InsertDriveFileOutlined';
import {
Button, Card, IconButton, Tab, Tabs,
Button, Card, IconButton, Tab, Tabs, Tooltip,
} from '@mui/material';
import obligationsService from '@api/services/obligations.service';
import { ConditionalLink } from '@components/ConditionalLink/ConditionalLink';
Expand Down Expand Up @@ -132,17 +132,21 @@ const IdentifiedReport = ({ data, onRefresh }) => {
</ConditionalLink>
</Card>

<Tabs value={tab} onChange={(e, value) => setTab(value)} className="tabs-navigator">
<Tab value="matches" label={t('Title:MatchedTab')} />
{ layers.current.has(Scanner.ScannerType.DEPENDENCIES) && <Tab value="dependencies" label={t('Title:IdentifiedDependenciesTab')} />}
<Tab value="obligations" label={t('Title:ObligationsTab')} />
{ layers.current.has(Scanner.ScannerType.CRYPTOGRAPHY) && <Tab value="cryptography" label={t('Title:CryptographyTab')} />}
<div className="refresh-btn-container">

<div className="tabs-navigator">
<Tabs value={tab} onChange={(e, value) => setTab(value)}>
<Tab value="matches" label={t('Title:MatchedTab')} />
{ layers.current.has(Scanner.ScannerType.DEPENDENCIES) && <Tab value="dependencies" label={t('Title:IdentifiedDependenciesTab')} />}
<Tab value="obligations" label={t('Title:ObligationsTab')} />
{ layers.current.has(Scanner.ScannerType.CRYPTOGRAPHY) && <Tab value="cryptography" label={t('Title:CryptographyTab')} />}
</Tabs>

<Tooltip title={t('Tooltip:RefreshReportButtonLabel')} classes={{ tooltip: 'tooltip' }}>
<IconButton onClick={onRefresh}>
<RefreshIcon />
</IconButton>
</div>
</Tabs>
</Tooltip>
</div>

{tab === 'matches' && (
<Card className="report-item matches-for-license">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@

.tabs-navigator {
grid-area: C;
position: relative;

.refresh-btn-container {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
height: 100%;
right: 0;
}

display: flex;
justify-content: space-between;
align-items: center;
}

.licenses-obligation, .matches-for-license, .cryptography, .dependencies-table {
grid-area: D;

Expand Down Expand Up @@ -107,7 +100,6 @@
grid-area: A2;
}


}

.report-item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack';

import TableCellActions from '@components/TableCellActions/TableCellActions';
import { vulnerabilityService } from '@api/services/vulnerability.service';
import { cryptographyService } from '@api/services/cryptography.service';
import { SourceType } from '@api/dto';
import useSearchParams from '@hooks/useSearchParams';
import { useNavigate } from 'react-router-dom'; // TODO: use alias?
Expand Down Expand Up @@ -53,10 +52,6 @@ const VulnerabilitiesReport = () => {
const init = async () => {
const source = type === SourceType.identified ? SourceType.identified : SourceType.detected;
const response = await vulnerabilityService.getAll({ type: source });

// TODO:Remove this line , just for testing
await cryptographyService.update();

data.current = response;

setItems(data.current);
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/theme/Main.global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,9 @@ a {
.selectable, .selectable * {
-webkit-user-select: text !important;
}

.tooltip {
text-align: center;
font-size: .75rem;
max-width: 140px;
}
1 change: 0 additions & 1 deletion src/renderer/ui/dialog/ComponentSearcherDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ const ComponentSearcherDialog = (props: ComponentSearcherDialogProps) => {
{...params}
InputProps={{
...params.InputProps,
disableUnderline: true,
className: 'autocomplete-option',
}}
/>
Expand Down
7 changes: 2 additions & 5 deletions src/renderer/ui/dialog/InventoryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const useStyles = makeStyles((theme) => ({
keep: {
'& .MuiInputBase-input': {
fontStyle: 'italic',
color: 'gray'
color: 'gray',
}
},
}));
Expand Down Expand Up @@ -436,7 +436,6 @@ export const InventoryDialog = (props: InventoryDialogProps) => {
InputProps={{
...params.InputProps,
startAdornment: <SearchIcon />,
disableUnderline: true,
className: 'autocomplete-option',
}}
/>
Expand Down Expand Up @@ -475,7 +474,6 @@ export const InventoryDialog = (props: InventoryDialogProps) => {
InputProps={{
...params.InputProps,
startAdornment: <SearchIcon />,
disableUnderline: true,
className: 'autocomplete-option',
}}
/>
Expand Down Expand Up @@ -573,8 +571,7 @@ export const InventoryDialog = (props: InventoryDialogProps) => {
size="small"
fullWidth
value={form?.usage || 'file'}
disableUnderline
className={ form?.usage === 'keep' ? classes.keep : ''}
className={form?.usage === 'keep' ? classes.keep : ''}
onChange={(e) => inputHandler(e)}
>
{ options.keepOriginalOption && <MenuItem value="keep" sx={{fontStyle: 'italic', color: 'gray'}}>{t('KeepOriginalUsage')}</MenuItem> }
Expand Down
14 changes: 6 additions & 8 deletions src/renderer/ui/dialog/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ interface SettingDialogProps {
const SettingDialog = ({ open, onClose, onCancel }: SettingDialogProps) => {
const { t, i18n } = useTranslation();

const [selectedApi, setSelectedApi] = useState(null);
const [apis, setApis] = useState([]);
const [sbomLedgerToken, setSbomLedgerToken] = useState(null);
const [selectedApi, setSelectedApi] = useState<any>('');
const [apis, setApis] = useState<any[]>([]);
const [sbomLedgerToken, setSbomLedgerToken] = useState<string>('');
const [language, setLanguage] = useState<string>('en');
const [apiDialog, setApiDialog] = useState({
open: false,
Expand Down Expand Up @@ -266,7 +266,7 @@ const SettingDialog = ({ open, onClose, onCancel }: SettingDialogProps) => {
<Paper className="dialog-form-field-control">
<Autocomplete
fullWidth
value={selectedApi}
value={selectedApi || ''}
onChange={handleOnChange}
onKeyPress={(e: any) => {
if (e.key === 'Enter') {
Expand Down Expand Up @@ -344,7 +344,6 @@ const SettingDialog = ({ open, onClose, onCancel }: SettingDialogProps) => {
{...params}
InputProps={{
...params.InputProps,
disableUnderline: true,
}}
/>
)}
Expand All @@ -371,7 +370,7 @@ const SettingDialog = ({ open, onClose, onCancel }: SettingDialogProps) => {
<TextField
name="token"
fullWidth
value={sbomLedgerToken}
value={sbomLedgerToken || ''}
onChange={(e) => setSbomLedgerToken(e.target.value)}
/>
</Paper>
Expand All @@ -385,8 +384,7 @@ const SettingDialog = ({ open, onClose, onCancel }: SettingDialogProps) => {
name="usage"
size="small"
fullWidth
disableUnderline
value={language}
value={language || ''}
onChange={(e) => setLanguage(e.target.value as string)}
>

Expand Down

0 comments on commit 82056d3

Please sign in to comment.