Skip to content

Commit

Permalink
ENH Change clear text to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 8, 2024
1 parent bdf0b36 commit 9d204fc
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

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

2 changes: 1 addition & 1 deletion client/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
"LinkField.CONFIRM_DELETE": "Deleted link",
"LinkField.DELETE_ERROR": "Failed to delete link",
"LinkField.ADD_LINK": "Add Link",
"LinkField.CLEAR": "Clear"
"LinkField.Delete": "Delete"
});
}
2 changes: 1 addition & 1 deletion client/lang/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"LinkField.CONFIRM_DELETE": "Deleted link",
"LinkField.DELETE_ERROR": "Failed to delete link",
"LinkField.ADD_LINK": "Add Link",
"LinkField.CLEAR": "Clear",
"LinkField.DELETE": "Delete",
"LinkField.LINK_DRAFT_TITLE": "Link has draft changes",
"LinkField.LINK_DRAFT_LABEL": "Draft",
"LinkField.LINK_MODIFIED_TITLE": "Link has unpublished changes",
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/LinkField/LinkField.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ const LinkField = ({
}

/**
* Update the component when the 'Clear' button in the LinkPicker is clicked
* Update the component when the 'Delete' button in the LinkPicker is clicked
*/
const onClear = (linkID) => {
const onDelete = (linkID) => {
let endpoint = `${Config.getSection(section).form.linkForm.deleteUrl}/${linkID}`;
const parsedURL = url.parse(endpoint);
const parsedQs = qs.parse(parsedURL.query);
Expand Down Expand Up @@ -167,7 +167,7 @@ const LinkField = ({
description={data[linkID]?.description}
versionState={data[linkID]?.versionState}
typeTitle={type.title || ''}
onClear={onClear}
onDelete={onDelete}
onClick={() => { setEditingID(linkID); }}
canDelete={data[linkID]?.canDelete ? true : false}
/>);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/LinkPicker/LinkPicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
padding-left: 3.5rem;
}

.link-picker__clear {
.link-picker__delete {
flex-grow: 0;
}

Expand Down
7 changes: 4 additions & 3 deletions client/src/components/LinkPicker/LinkPickerTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const LinkPickerTitle = ({
description,
versionState,
typeTitle,
onClear,
onDelete,
onClick,
canDelete
}) => {
Expand All @@ -47,6 +47,7 @@ const LinkPickerTitle = ({
classes[` link-picker__link--${versionState}`] = true;
}
const className = classnames(classes);
const deleteText = i18n._t('LinkField.DELETE', 'Delete');
return <div className={className}>
<Button className="link-picker__button font-icon-link" color="secondary" onClick={stopPropagation(onClick)}>
<div className="link-picker__link-detail">
Expand All @@ -61,7 +62,7 @@ const LinkPickerTitle = ({
</div>
</Button>
{canDelete &&
<Button className="link-picker__clear" color="link" onClick={stopPropagation(() => onClear(id))}>{i18n._t('LinkField.CLEAR', 'Clear')}</Button>
<Button className="link-picker__delete" color="link" onClick={stopPropagation(() => onDelete(id))}>{deleteText}</Button>
}
</div>
};
Expand All @@ -72,7 +73,7 @@ LinkPickerTitle.propTypes = {
description: PropTypes.string,
versionState: PropTypes.string,
typeTitle: PropTypes.string.isRequired,
onClear: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onClick: PropTypes.func.isRequired,
canDelete: PropTypes.bool.isRequired,
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/LinkPicker/tests/LinkPicker-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ onSelect.toString = () => 'onSelect';
const onEdit = action('onEdit');
onEdit.toString = () => 'onEdit';

const onClear = action('onClear');
onClear.toString = () => 'onClear';
const onDelete = action('onDelete');
onDelete.toString = () => 'onDelete';

const props = {
types,
onSelect,
onClear,
onDelete,
onEdit
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function makeProps(obj = {}) {
description: 'My description',
versionState: 'draft',
typeTitle: 'Phone',
onClear: () => {},
onDelete: () => {},
onClick: () => {},
...obj
};
Expand All @@ -22,13 +22,13 @@ test('LinkPickerTitle render() should display clear button if can delete', () =>
canDelete: true
})}
/>);
expect(container.querySelectorAll('.link-picker__clear')).toHaveLength(1);
expect(container.querySelectorAll('.link-picker__delete')).toHaveLength(1);
});

test('LinkPickerTitle render() should not display clear button if cannot delete', () => {
const { container } = render(<LinkPickerTitle {...makeProps({
canDelete: false
})}
/>);
expect(container.querySelectorAll('.link-picker__clear')).toHaveLength(0);
expect(container.querySelectorAll('.link-picker__delete')).toHaveLength(0);
});

0 comments on commit 9d204fc

Please sign in to comment.