Skip to content

Commit

Permalink
Merge pull request #2568 from alexzurbonsen/fix-displayed-original-li…
Browse files Browse the repository at this point in the history
…cense-info

fix: don't show original license info if signal is of type first party
  • Loading branch information
mstykow authored Feb 14, 2024
2 parents 7f18b88 + 61e655e commit 296cef6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/Frontend/Components/DiffPopup/DiffPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
import { AttributionForm } from '../AttributionColumn/AttributionForm';
import { NotificationPopup } from '../NotificationPopup/NotificationPopup';
import { DiffPopupContainer } from './DiffPopup.style';
import { useAttributionFormConfigs } from './DiffPopup.util';
import {
stripLicenseInfoIfFirstParty,
useAttributionFormConfigs,
} from './DiffPopup.util';

interface DiffPopupProps {
original: PackageInfo;
Expand All @@ -38,8 +41,8 @@ export function DiffPopup({
bufferPackageInfo,
setBufferPackageInfo,
} = useAttributionFormConfigs({
original,
current,
original: stripLicenseInfoIfFirstParty(original),
current: stripLicenseInfoIfFirstParty(current),
});

function handleApplyChanges({
Expand Down Expand Up @@ -120,7 +123,7 @@ export function DiffPopup({
return (
<DiffPopupContainer>
<AttributionForm
packageInfo={original}
packageInfo={stripLicenseInfoIfFirstParty(original)}
variant={'diff'}
label={'original'}
config={originalFormConfig}
Expand Down
22 changes: 12 additions & 10 deletions src/Frontend/Components/DiffPopup/DiffPopup.util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@ export function useAttributionFormConfigs({
original: PackageInfo;
current: PackageInfo;
}) {
const [bufferPackageInfo, setBufferPackageInfo] = useState(
current.firstParty
? {
...current,
copyright: undefined,
licenseName: undefined,
licenseText: undefined,
}
: current,
);
const [bufferPackageInfo, setBufferPackageInfo] = useState(current);

const getEndIcon = useCallback(
({
Expand Down Expand Up @@ -213,3 +204,14 @@ export function useAttributionFormConfigs({
setBufferPackageInfo,
};
}

export function stripLicenseInfoIfFirstParty(packageInfo: PackageInfo) {
return packageInfo.firstParty
? {
...packageInfo,
copyright: undefined,
licenseName: undefined,
licenseText: undefined,
}
: packageInfo;
}

0 comments on commit 296cef6

Please sign in to comment.