Skip to content

Commit

Permalink
Merge pull request #2570 from opossum-tool/feat-opossumui-2.0
Browse files Browse the repository at this point in the history
feat: opossumui-2.0
  • Loading branch information
mstykow authored Mar 6, 2024
2 parents 40b1d80 + a9de25d commit 11e2df2
Show file tree
Hide file tree
Showing 445 changed files with 15,005 additions and 24,080 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ jobs:
- uses: actions/upload-artifact@v4
if: failure()
with:
name: artifacts
path: src/e2e-tests/artifacts
name: artifacts-${{ matrix.os }}
path: src/e2e-tests/artifacts-${{ matrix.os }}
retention-days: 30
333 changes: 113 additions & 220 deletions USER_GUIDE.md

Large diffs are not rendered by default.

Binary file removed docs/user_guide_screenshots/attribution_view.png
Binary file not shown.
Binary file modified docs/user_guide_screenshots/audit_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/user_guide_screenshots/exports.png
Binary file not shown.
Binary file removed docs/user_guide_screenshots/filetree.png
Binary file not shown.
Binary file removed docs/user_guide_screenshots/locator.png
Binary file not shown.
Binary file not shown.
Binary file removed docs/user_guide_screenshots/open_file.png
Binary file not shown.
Binary file modified docs/user_guide_screenshots/report_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/user_guide_screenshots/search.png
Binary file not shown.
Binary file not shown.
Binary file modified docs/user_guide_screenshots/top_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@fontsource-variable/karla": "^5.0.20",
"@mui/icons-material": "^5.15.12",
"@mui/material": "^5.15.12",
"@mui/system": "^5.15.12",
"@reduxjs/toolkit": "^2.2.1",
"@tanstack/react-query": "^5.25.0",
"compare-versions": "^6.1.0",
"dayjs": "^1.11.10",
"electron-devtools-installer": "^3.2.0",
"electron-log": "^5.1.1",
"electron-settings": "^4.0.2",
"fast-csv": "^5.0.1",
Expand All @@ -29,6 +29,7 @@
"re-resizable": "^6.9.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"react-hot-toast": "^2.4.1",
"react-hotkeys-hook": "^4.5.0",
"react-redux": "^9.1.0",
Expand Down Expand Up @@ -56,7 +57,6 @@
"@testing-library/user-event": "^14.5.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/babel__core": "^7.20.5",
"@types/electron-devtools-installer": "^2.2.5",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/lodash": "^4.14.202",
Expand Down
9 changes: 9 additions & 0 deletions public/icons/wave.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'dotenv',
'electron',
'electron-builder',
'electron-devtools-installer',
'electron-log',
'electron-playwright-helpers',
'electron-settings',
Expand All @@ -49,6 +48,7 @@
'prettier',
'prop-types',
'proxy-memoize',
'react-error-boundary',
'react-hot-toast',
'react-hotkeys-hook',
'react-virtuoso',
Expand Down Expand Up @@ -99,6 +99,13 @@
matchUpdateTypes: ['minor', 'patch'],
automerge: true,
},
{
matchPackagePrefixes: ['@fontsource-variable/'],
groupName: 'fontsource dependencies',
groupSlug: 'fontsource',
matchUpdateTypes: ['minor', 'patch'],
automerge: true,
},
{
matchPackagePrefixes: ['@tanstack/'],
groupName: 'Tanstack dependencies',
Expand Down
14 changes: 0 additions & 14 deletions src/ElectronBackend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
//
// SPDX-License-Identifier: Apache-2.0
import { app } from 'electron';
import installExtension, {
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
} from 'electron-devtools-installer';

import { main } from './main/main';

Expand All @@ -15,13 +11,3 @@ app.on('ready', main);
app.on('window-all-closed', () => {
app.quit();
});

app.on('ready', () => {
if (!app.isPackaged) {
[REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS].forEach((extension) => {
installExtension(extension)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));
});
}
});
8 changes: 2 additions & 6 deletions src/ElectronBackend/input/__tests__/importFromFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import * as zlib from 'zlib';

import { EMPTY_PROJECT_METADATA } from '../../../Frontend/shared-constants';
import { AllowedFrontendChannels } from '../../../shared/ipc-channels';
import {
Criticality,
DiscreteConfidence,
ParsedFileContent,
} from '../../../shared/shared-types';
import { Criticality, ParsedFileContent } from '../../../shared/shared-types';
import { writeFile, writeOpossumFile } from '../../../shared/write-file';
import { faker } from '../../../testing/Faker';
import {
Expand Down Expand Up @@ -433,7 +429,7 @@ describe('Test of loading function', () => {
comment: 'some comment',
copyright: '(c) first party',
preSelected: true,
attributionConfidence: DiscreteConfidence.Low,
attributionConfidence: 17,
id: manualAttributionUuid,
},
},
Expand Down
10 changes: 5 additions & 5 deletions src/ElectronBackend/input/__tests__/parseFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ const correctOutput: OpossumOutputFile = {
resolvedExternalAttributions: [],
};

const correctParsedOuput: ParsedOpossumOutputFile = {
const correctParsedOutput: ParsedOpossumOutputFile = {
...correctOutput,
resolvedExternalAttributions: new Set(),
resolvedExternalAttributions: [],
};

describe('parseOpossumFile', () => {
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('parseOpossumFile', () => {
opossumFilePath,
)) as ParsedOpossumInputAndOutput;
expect(parsingResult.input).toStrictEqual(correctInput);
expect(parsingResult.output).toStrictEqual(correctParsedOuput);
expect(parsingResult.output).toStrictEqual(correctParsedOutput);
});

it('returns JSONParsingError on an incorrect .opossum file', async () => {
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('parseOutputJsonFile', () => {

const attributions = parseOutputJsonFile(attributionPath);

expect(attributions).toStrictEqual(correctParsedOuput);
expect(attributions).toStrictEqual(correctParsedOutput);
});

it('throws when reading an incorrect file', async () => {
Expand All @@ -272,7 +272,7 @@ describe('parseOutputJsonFile', () => {
'cff9095a-5c24-46e6-b84d-cc8596b17c58',
);
const parsedFileContentWithWrongProjectId: ParsedOpossumOutputFile = set(
cloneDeep(correctParsedOuput),
cloneDeep(correctParsedOutput),
'metadata.projectId',
'cff9095a-5c24-46e6-b84d-cc8596b17c58',
);
Expand Down
15 changes: 4 additions & 11 deletions src/ElectronBackend/input/importFromFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { v4 as uuid4 } from 'uuid';
import { AllowedFrontendChannels } from '../../shared/ipc-channels';
import {
Attributions,
DiscreteConfidence,
ParsedFileContent,
ResourcesToAttributions,
} from '../../shared/shared-types';
Expand Down Expand Up @@ -177,11 +176,11 @@ export async function loadInputAndOutputFromFilePath(
attributionsToResources: externalAttributionsToResources,
},
frequentLicenses,
resolvedExternalAttributions: parsedOutputData.resolvedExternalAttributions,
attributionBreakpoints: new Set(
parsedInputData.attributionBreakpoints ?? [],
resolvedExternalAttributions: new Set(
parsedOutputData.resolvedExternalAttributions,
),
filesWithChildren: new Set(parsedInputData.filesWithChildren ?? []),
attributionBreakpoints: new Set(parsedInputData.attributionBreakpoints),
filesWithChildren: new Set(parsedInputData.filesWithChildren),
baseUrlsForSources: sanitizeRawBaseUrlsForSources(
parsedInputData.baseUrlsForSources,
),
Expand Down Expand Up @@ -261,12 +260,6 @@ function createJsonOutputFile(
delete packageInfo.source;
delete packageInfo.preferred;
delete packageInfo.preferredOverOriginIds;
if (packageInfo.attributionConfidence !== undefined) {
packageInfo.attributionConfidence =
packageInfo.attributionConfidence >= DiscreteConfidence.High
? DiscreteConfidence.High
: DiscreteConfidence.Low;
}

const newUUID = uuid4();
manualAttributions[newUUID] = packageInfo;
Expand Down
93 changes: 38 additions & 55 deletions src/ElectronBackend/input/parseFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,52 @@ export async function parseOpossumFile(
): Promise<
ParsedOpossumInputAndOutput | JsonParsingError | InvalidDotOpossumFileError
> {
let parsedInputData: unknown;
let parsedOutputData: unknown = null;
let jsonParsingError: JsonParsingError | null = null;
let invalidDotOpossumFileError: InvalidDotOpossumFileError | null = null;
let parsedInputData: ParsedOpossumInputFile;
let parsedOutputData: ParsedOpossumOutputFile | null = null;

const zip: fflate.Unzipped = await readZipAsync(opossumFilePath);

if (!zip[INPUT_FILE_NAME]) {
invalidDotOpossumFileError = {
return {
filesInArchive: Object.keys(zip)
.map((fileName) => `'${fileName}'`)
.join(', '),
type: 'invalidDotOpossumFileError',
};
} else {
getGlobalBackendState().inputFileRaw = zip[INPUT_FILE_NAME];
const inputJson = fflate.strFromU8(zip[INPUT_FILE_NAME]);
} satisfies InvalidDotOpossumFileError;
}

getGlobalBackendState().inputFileRaw = zip[INPUT_FILE_NAME];

try {
parsedInputData = JSON.parse(fflate.strFromU8(zip[INPUT_FILE_NAME]));
jsonSchemaValidator.validate(
parsedInputData,
OpossumInputFileSchema,
validationOptions,
);
} catch (err) {
return {
message: `Error: ${opossumFilePath} does not contain a valid input file.\n Original error message: ${err?.toString()}`,
type: 'jsonParsingError',
} satisfies JsonParsingError;
}

if (zip[OUTPUT_FILE_NAME]) {
try {
parsedInputData = parseAndValidateJson(inputJson, OpossumInputFileSchema);
const outputJson = fflate.strFromU8(zip[OUTPUT_FILE_NAME]);
parsedOutputData = parseOutputJsonContent(outputJson, opossumFilePath);
} catch (err) {
jsonParsingError = {
message: `Error: ${opossumFilePath} does not contain a valid input file.\n Original error message: ${err?.toString()}`,
return {
message: `Error: ${opossumFilePath} does not contain a valid output file.\n${err?.toString()}`,
type: 'jsonParsingError',
};
}

if (zip[OUTPUT_FILE_NAME]) {
try {
const outputJson = fflate.strFromU8(zip[OUTPUT_FILE_NAME]);
parsedOutputData = parseOutputJsonContent(outputJson, opossumFilePath);
} catch (err) {
jsonParsingError = {
message: `Error: ${opossumFilePath} does not contain a valid output file.\n${err?.toString()}`,
type: 'jsonParsingError',
};
}
} satisfies JsonParsingError;
}
}

return jsonParsingError
? jsonParsingError
: invalidDotOpossumFileError
? invalidDotOpossumFileError
: {
input: parsedInputData as ParsedOpossumInputFile,
output: parsedOutputData as ParsedOpossumOutputFile,
};
return {
input: parsedInputData,
output: parsedOutputData,
};
}

async function readZipAsync(opossumFilePath: string): Promise<fflate.Unzipped> {
Expand Down Expand Up @@ -160,34 +160,17 @@ export function parseOutputJsonContent(
fileContent: string,
filePath: fs.PathLike,
): ParsedOpossumOutputFile {
let outputJsonContent;
try {
outputJsonContent = parseAndValidateJson(
fileContent,
const jsonContent = JSON.parse(fileContent);
jsonSchemaValidator.validate(
jsonContent,
OpossumOutputFileSchema,
validationOptions,
);
return jsonContent;
} catch (err) {
throw new Error(
`Error: ${filePath.toString()} contains an invalid output file.\n Original error message: ${err?.toString()}`,
);
}

const resolvedExternalAttributions = (
outputJsonContent as Record<string, unknown>
).resolvedExternalAttributions;
return {
...(outputJsonContent as Record<string, unknown>),
resolvedExternalAttributions: resolvedExternalAttributions
? new Set(resolvedExternalAttributions as Array<string>)
: new Set(),
} as ParsedOpossumOutputFile;
}

function parseAndValidateJson(
content: string,
schema: typeof OpossumInputFileSchema | typeof OpossumOutputFileSchema,
): unknown {
const jsonContent = JSON.parse(content);
jsonSchemaValidator.validate(jsonContent, schema, validationOptions);
return jsonContent;
}
1 change: 1 addition & 0 deletions src/ElectronBackend/input/parseInputData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function serializeAttributions(
count,
followUp,
id,
relation,
resources,
source,
suffix,
Expand Down
6 changes: 6 additions & 0 deletions src/ElectronBackend/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export async function main(): Promise<void> {
},
);

ipcMain.handle(IpcChannel.Quit, () => {
mainWindow.close();
});
ipcMain.handle(IpcChannel.Relaunch, () => {
mainWindow.reload();
});
ipcMain.handle(
IpcChannel.ConvertInputFile,
getConvertInputFileToDotOpossumAndOpenListener(mainWindow),
Expand Down
33 changes: 1 addition & 32 deletions src/ElectronBackend/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,37 +258,6 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
accelerator: 'CmdOrCtrl+A',
role: 'selectAll',
},
{ type: 'separator' },
{
icon: getIconBasedOnTheme(
'icons/search-white.png',
'icons/search-black.png',
),
label: 'Search for Files and Directories',
accelerator: 'CmdOrCtrl+F',
click(): void {
if (isFileLoaded(getGlobalBackendState())) {
webContents.send(AllowedFrontendChannels.ShowSearchPopup, {
showSearchPopup: true,
});
}
},
},
{
icon: getIconBasedOnTheme(
'icons/location-searching-white.png',
'icons/location-searching-black.png',
),
label: 'Locate Signals',
accelerator: 'CmdOrCtrl+L',
click(): void {
if (isFileLoaded(getGlobalBackendState())) {
webContents.send(AllowedFrontendChannels.ShowLocatorPopup, {
showSearchPopup: true,
});
}
},
},
],
},
{
Expand Down Expand Up @@ -356,7 +325,7 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
);
void UserSettings.set('qaMode', false);
},
visible: qaMode,
visible: !!qaMode,
},
],
},
Expand Down
Loading

0 comments on commit 11e2df2

Please sign in to comment.