Skip to content

Commit

Permalink
Merge pull request #74 from opossum-tool/rename_button_texts
Browse files Browse the repository at this point in the history
rename button texts
  • Loading branch information
benedikt-richter committed Oct 7, 2021
2 parents a7365f7 + 3ee3f55 commit dcfdbd1
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 124 deletions.
10 changes: 5 additions & 5 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ The `Attribution Details Column`, if editable, shows the following buttons:

- _SAVE_, saves the edited information for the selected resource only, removing the **pre-selected** attribute if
present.
- _SAVE FOR ALL_, (shown only if the attribution of the selected resource is also linked to other resources) saves the
- _SAVE GLOBALLY_, (shown only if the attribution of the selected resource is also linked to other resources) saves the
changes for all the linked resources. The same can also be done by pressing _Ctrl + S_.
- _CONFIRM_, removes the **pre-selected** attribute from the attribution for the selected resource only.
- _CONFIRM FOR ALL_, (shown only if the attribution of the selected resource is also linked to other resources) removes
- _CONFIRM GLOBALLY_, (shown only if the attribution of the selected resource is also linked to other resources) removes
the **pre-selected** attribute from the attribution for all linked resources.
- _..._, opens a menu with the following buttons:
- _Undo_, discards the changes,
- _Delete_, deletes the attribution of the selected resource only.
- _Delete For All_, (shown only if the attribution of the selected resource is also linked to other resources)
- _Delete Globally_, (shown only if the attribution of the selected resource is also linked to other resources)
deletes the attribution for all the linked resources.

The _SAVE_ / _SAVE FOR ALL_ and _Undo_ buttons are disabled if no change has been made.
The _SAVE_ / _SAVE GLOBALLY_ and _Undo_ buttons are disabled if no change has been made.

When all fields except for the _confidence_ field are empty, pressing the _SAVE_ or the _SAVE FOR ALL_ button deletes
When all fields except for the _confidence_ field are empty, pressing the _SAVE_ or the _SAVE GLOBALLY_ button deletes
the respective attribution.

The `Attribution Details Column`, when a signal is selected, shows the _HIDE_ button. It can be used to hide the given
Expand Down
20 changes: 10 additions & 10 deletions src/Frontend/Components/AttributionColumn/AttributionColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface AttributionColumnProps {
isEditable: boolean;
areButtonsHidden?: boolean;
displayPackageInfo: PackageInfo;
showSaveForAllButton?: boolean;
showSaveGloballyButton?: boolean;
hideDeleteButtons?: boolean;
showParentAttributions?: boolean;
showManualAttributionData: boolean;
Expand All @@ -70,9 +70,9 @@ interface AttributionColumnProps {
propertyToUpdate: string
): (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
onSaveButtonClick(): void;
onSaveForAllButtonClick(): void;
onSaveGloballyButtonClick(): void;
onDeleteButtonClick(): void;
onDeleteForAllButtonClick(): void;
onDeleteGloballyButtonClick(): void;
saveFileRequestListener(): void;
setTemporaryPackageInfo(packageInfo: PackageInfo): void;
}
Expand Down Expand Up @@ -132,11 +132,11 @@ export function AttributionColumn(props: AttributionColumnProps): ReactElement {
},
{
buttonText: temporaryPackageInfo.preSelected
? ButtonText.ConfirmForAll
: ButtonText.SaveForAll,
? ButtonText.ConfirmGlobally
: ButtonText.SaveGlobally,
disabled: isSavingDisabled,
onClick: props.onSaveForAllButtonClick,
hidden: !Boolean(props.showSaveForAllButton),
onClick: props.onSaveGloballyButtonClick,
hidden: !Boolean(props.showSaveGloballyButton),
},
];

Expand All @@ -154,11 +154,11 @@ export function AttributionColumn(props: AttributionColumnProps): ReactElement {
hidden: Boolean(props.hideDeleteButtons),
},
{
buttonText: ButtonText.DeleteForAll,
onClick: props.onDeleteForAllButtonClick,
buttonText: ButtonText.DeleteGlobally,
onClick: props.onDeleteGloballyButtonClick,
hidden:
Boolean(props.hideDeleteButtons) ||
!Boolean(props.showSaveForAllButton),
!Boolean(props.showSaveGloballyButton),
},
{
buttonText: ButtonText.MarkForReplacement,
Expand Down
3 changes: 2 additions & 1 deletion src/Frontend/Components/AttributionColumn/ButtonRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToggleButton } from '../ToggleButton/ToggleButton';
import { ButtonGroup, MainButtonConfig } from '../ButtonGroup/ButtonGroup';
import MuiTypography from '@material-ui/core/Typography';
import { ContextMenuItem } from '../ContextMenu/ContextMenu';
import { ButtonText } from '../../enums/enums';

const useStyles = makeStyles({
root: {
Expand Down Expand Up @@ -58,7 +59,7 @@ export function ButtonRow(props: ButtonRowProps): ReactElement {
/>
) : (
<ToggleButton
buttonText={'hide'}
buttonText={ButtonText.Hide}
className={classes.resolveButton}
selected={props.selectedPackageIsResolved}
handleChange={props.resolvedToggleHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setSelectedResourceId('test_id'));
Expand Down Expand Up @@ -138,11 +138,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setSelectedResourceId('test_id'));
Expand All @@ -162,11 +162,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setTemporaryPackageInfo(testTemporaryPackageInfo));
Expand All @@ -185,11 +185,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setTemporaryPackageInfo(testTemporaryPackageInfo));
Expand Down Expand Up @@ -223,11 +223,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);

Expand All @@ -250,11 +250,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
const testFrequentLicenses: FrequentLicences = {
Expand All @@ -278,11 +278,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
const testFrequentLicenses: FrequentLicences = {
Expand All @@ -309,11 +309,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);

Expand All @@ -338,11 +338,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={true}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setTemporaryPackageInfo(testTemporaryPackageInfo));
Expand Down Expand Up @@ -391,11 +391,11 @@ describe('The AttributionColumn', () => {
setUpdateTemporaryPackageInfoFor={(): (() => void) => doNothing}
onSaveButtonClick={doNothing}
setTemporaryPackageInfo={(): (() => void) => doNothing}
onSaveForAllButtonClick={doNothing}
onSaveGloballyButtonClick={doNothing}
showManualAttributionData={false}
saveFileRequestListener={doNothing}
onDeleteButtonClick={doNothing}
onDeleteForAllButtonClick={doNothing}
onDeleteGloballyButtonClick={doNothing}
/>
);
store.dispatch(setResources({}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ResourcesList } from '../ResourcesList/ResourcesList';
import { setUpdateTemporaryPackageInfoForCreator } from '../ResourceDetailsAttributionColumn/resource-details-attribution-column-helpers';
import { isEqual } from 'lodash';
import {
deleteAttributionForAllAndSave,
deleteAttributionGloballyAndSave,
savePackageInfo,
savePackageInfoIfSavingIsNotDisabled,
} from '../../state/actions/resource-actions/save-actions';
Expand Down Expand Up @@ -85,7 +85,7 @@ export function AttributionDetailsViewer(): ReactElement | null {

function deleteAttribution(): void {
if (temporaryPackageInfo.preSelected) {
dispatch(deleteAttributionForAllAndSave(selectedAttributionId));
dispatch(deleteAttributionGloballyAndSave(selectedAttributionId));
} else {
dispatch(openPopup(PopupType.ConfirmDeletionPopup));
}
Expand All @@ -111,9 +111,9 @@ export function AttributionDetailsViewer(): ReactElement | null {
displayPackageInfo={temporaryPackageInfo}
setUpdateTemporaryPackageInfoFor={setUpdateTemporaryPackageInfoFor}
onSaveButtonClick={dispatchSavePackageInfo}
onSaveForAllButtonClick={(): void => {}}
onSaveGloballyButtonClick={(): void => {}}
onDeleteButtonClick={deleteAttribution}
onDeleteForAllButtonClick={(): void => {}}
onDeleteGloballyButtonClick={(): void => {}}
setTemporaryPackageInfo={(packageInfo: PackageInfo): void => {
dispatch(setTemporaryPackageInfo(packageInfo));
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Button group', () => {
onClick: doNothing,
},
{
buttonText: ButtonText.SaveForAll,
buttonText: ButtonText.SaveGlobally,
disabled: true,
onClick: doNothing,
hidden: true,
Expand All @@ -64,6 +64,6 @@ describe('Button group', () => {
fireEvent.click(screen.getByLabelText('button-context-menu'));

screen.getByText(ButtonText.Save);
expect(screen.queryByText(ButtonText.SaveForAll)).toBe(null);
expect(screen.queryByText(ButtonText.SaveGlobally)).toBe(null);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import React, { ReactElement } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { ConfirmationPopup } from '../ConfirmationPopup/ConfirmationPopup';
import { deleteAttributionForAllAndSave } from '../../state/actions/resource-actions/save-actions';
import { deleteAttributionGloballyAndSave } from '../../state/actions/resource-actions/save-actions';
import { getAttributionIdOfDisplayedPackageInManualPanel } from '../../state/selectors/audit-view-resource-selectors';

export function ConfirmDeletionForAllPopup(): ReactElement {
export function ConfirmDeletionGloballyPopup(): ReactElement {
const attributionIdOfSelectedPackageInManualPanel: string | null =
useSelector(getAttributionIdOfDisplayedPackageInManualPanel);

const dispatch = useDispatch();

function deleteAttributionForAll(): void {
function deleteAttributionGlobally(): void {
if (attributionIdOfSelectedPackageInManualPanel) {
dispatch(
deleteAttributionForAllAndSave(
deleteAttributionGloballyAndSave(
attributionIdOfSelectedPackageInManualPanel
)
);
Expand All @@ -27,7 +27,7 @@ export function ConfirmDeletionForAllPopup(): ReactElement {

return (
<ConfirmationPopup
onConfirmation={deleteAttributionForAll}
onConfirmation={deleteAttributionGlobally}
content={'Do you really want to delete this attribution for all files?'}
header={'Confirm Deletion'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import { renderComponentWithStore } from '../../../test-helpers/render-component-with-store';
import { screen } from '@testing-library/react';
import React from 'react';
import { ConfirmDeletionForAllPopup } from '../ConfirmDeletionForAllPopup';
import { ConfirmDeletionGloballyPopup } from '../ConfirmDeletionGloballyPopup';

describe('The ConfirmDeletionForAllPopup', () => {
describe('The ConfirmDeletionGloballyPopup', () => {
test('renders', () => {
const expectedContent =
'Do you really want to delete this attribution for all files?';
const expectedHeader = 'Confirm Deletion';

renderComponentWithStore(<ConfirmDeletionForAllPopup />);
renderComponentWithStore(<ConfirmDeletionGloballyPopup />);

expect(screen.queryByText(expectedContent)).toBeTruthy();
expect(screen.queryByText(expectedHeader)).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../../state/selectors/audit-view-resource-selectors';
import {
deleteAttributionAndSave,
deleteAttributionForAllAndSave,
deleteAttributionGloballyAndSave,
} from '../../state/actions/resource-actions/save-actions';
import { getSelectedAttributionId } from '../../state/selectors/attribution-view-resource-selectors';
import { View } from '../../enums/enums';
Expand All @@ -38,7 +38,7 @@ export function ConfirmDeletionPopup(): ReactElement {
);
}
} else {
dispatch(deleteAttributionForAllAndSave(selectedAttributionId));
dispatch(deleteAttributionGloballyAndSave(selectedAttributionId));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/Components/ContextMenu/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BUTTON_TITLE_TO_ICON_MAP: {
[buttonText in ButtonText]?: JSX.Element;
} = {
[ButtonText.Delete]: <DeleteIcon fontSize="small" />,
[ButtonText.DeleteForAll]: <DeleteForeverIcon fontSize="small" />,
[ButtonText.DeleteGlobally]: <DeleteForeverIcon fontSize="small" />,
[ButtonText.Undo]: <UndoIcon fontSize="small" />,
[ButtonText.MarkForReplacement]: (
<CheckBoxOutlineBlankIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('The ContextMenu', () => {
onClick: onClickMock,
},
{
buttonText: ButtonText.SaveForAll,
buttonText: ButtonText.SaveGlobally,
disabled: false,
onClick: doNothing,
hidden: true,
Expand All @@ -34,7 +34,7 @@ describe('The ContextMenu', () => {

expect(screen.getByText(ButtonText.Undo));
expect(screen.getByText(ButtonText.Save));
expect(screen.queryByText(ButtonText.SaveForAll)).toBe(null);
expect(screen.queryByText(ButtonText.SaveGlobally)).toBe(null);

const buttonDisabledAttribute = screen
.getByLabelText('button-context-menu')
Expand All @@ -55,7 +55,7 @@ describe('The ContextMenu', () => {
onClick: doNothing,
},
{
buttonText: ButtonText.SaveForAll,
buttonText: ButtonText.SaveGlobally,
disabled: false,
onClick: doNothing,
hidden: true,
Expand Down

0 comments on commit dcfdbd1

Please sign in to comment.