Skip to content

Commit

Permalink
FIX Add default link type title and icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Jan 19, 2024
1 parent 4bc4883 commit e61d2c5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions client/src/components/LinkField/LinkField.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ const LinkField = ({
if (!linkData) {
continue;
}
const type = types.hasOwnProperty(data[linkID]?.typeKey) ? types[data[linkID]?.typeKey] : {};

links.push(<LinkPickerTitle
key={linkID}
id={linkID}
title={data[linkID]?.Title}
description={data[linkID]?.description}
versionState={data[linkID]?.versionState}
typeTitle={type.title || ''}
typeIcon={type.icon}
typeTitle={data[linkID]?.menuTitle}
typeIcon={data[linkID]?.icon}
onDelete={onDelete}
onClick={() => { setEditingID(linkID); }}
canDelete={data[linkID]?.canDelete ? true : false}
Expand Down Expand Up @@ -278,6 +278,7 @@ const LinkField = ({
onSuccess={onModalSuccess}
onClosed={onModalClosed}
linkID={editingID}
title={data[editingID]?.menuTitle}
/>
}
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/LinkPicker/LinkPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const LinkPicker = ({ types, onModalSuccess, onModalClosed, canCreate }) => {
isOpen={shouldOpenModal}
onSuccess={handleSuccess}
onClosed={handleClosed}
title={types[typeKey].title}
/>
}
</div>
Expand Down
7 changes: 4 additions & 3 deletions client/src/containers/LinkModalContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
/**
* Contains the LinkModal and determines which modal component to render based on the link type.
*/
const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onClosed }) => {
const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onClosed, title }) => {
if (!typeKey) {
return false;
}
Expand All @@ -18,7 +18,7 @@ const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onC
const LinkModal = loadComponent(`LinkModal.${handlerName}`);

return <LinkModal
typeTitle={type.title || ''}
typeTitle={title}
typeKey={typeKey}
linkID={linkID}
isOpen={isOpen}
Expand All @@ -28,12 +28,13 @@ const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onC
}

LinkModalContainer.propTypes = {
types: PropTypes.object.isRequired,
types: PropTypes.string.isRequired,
typeKey: PropTypes.string.isRequired,
linkID: PropTypes.number,
isOpen: PropTypes.bool.isRequired,
onSuccess: PropTypes.func.isRequired,
onClosed: PropTypes.func.isRequired,
title: PropTypes.string.isRequired,
};

export default LinkModalContainer;
2 changes: 2 additions & 0 deletions src/Controllers/LinkFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ private function getLinkData(Link $link): array
$this->jsonError(403, _t(__CLASS__ . '.UNAUTHORIZED', 'Unauthorized'));
}
$data = $link->jsonSerialize();
$data['icon'] = $link->getIcon();
$data['menuTitle'] = $link->getMenuTitle();
$data['canDelete'] = $link->canDelete();
$data['description'] = $link->getDescription();
$data['versionState'] = $link->getVersionedState();
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Traits/AllowedLinkClassesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getTypesProps(): string
'title' => $type->getMenuTitle(),
'handlerName' => $type->LinkTypeHandlerName(),
'priority' => $class::config()->get('menu_priority'),
'icon' => $class::config()->get('icon'),
'icon' => $type->getIcon(),
];
}
uasort($typesList, function ($a, $b) {
Expand Down
5 changes: 5 additions & 0 deletions src/Models/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,9 @@ public function getMenuTitle(): string
{
return $this->i18n_singular_name();
}

public function getIcon(): string
{
return $this->config()->get('icon');
}
}

0 comments on commit e61d2c5

Please sign in to comment.