Skip to content

Commit

Permalink
IBX-9109: Enabling TypeScript (ts-loader) with Webpack Encore
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti committed Oct 17, 2024
1 parent 8ee5000 commit c284d43
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bundle/Resources/encore/ibexa.js.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module.exports = (Encore) => {
path.resolve(__dirname, '../public/js/scripts/button.content.edit.js'),
path.resolve(__dirname, '../public/js/scripts/admin.search.filters.js'),
path.resolve(__dirname, '../public/js/scripts/admin.search.sorting.js'),
path.resolve(__dirname, '../public/js/scripts/admin.search.js'),
path.resolve(__dirname, '../public/ts/admin.search.ts'),
path.resolve(__dirname, '../public/js/scripts/udw/select.location.js'),
path.resolve(__dirname, '../public/js/scripts/button.translation.edit.js'),
])
Expand Down
26 changes: 26 additions & 0 deletions src/bundle/Resources/public/ts/admin.search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function (document) {
const searchForm = document.querySelector('.ibexa-search-form') as HTMLFormElement | null;
const searchInput = document.querySelector('.ibexa-search-form__search-input') as HTMLInputElement | null;
const headerSearchInput = document.querySelector('.ibexa-global-search__input') as HTMLInputElement | null;
const languageSelector = document.querySelector('.ibexa-filters__item--language-selector .ibexa-filters__select') as HTMLSelectElement | null;
const headerSearchSubmitBtn = document.querySelector('.ibexa-main-header .ibexa-input-text-wrapper__action-btn--search') as HTMLButtonElement | null;

if (!headerSearchInput || !searchInput || !searchForm) {
return;
}

const submitForm = () => {
searchInput.value = headerSearchInput.value;
searchForm.submit();
};
const handleHeaderSearchBtnClick = (event: MouseEvent) => {
event.preventDefault();

submitForm();
};

headerSearchInput.value = searchInput.value;

headerSearchSubmitBtn?.addEventListener('click', handleHeaderSearchBtnClick, false);
languageSelector?.addEventListener('change', submitForm, false);
})(document);
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

import Icon from '../icon/icon';

const Thumbnail = ({ thumbnailData, iconExtraClasses, contentTypeIconPath }) => {
interface ThumbnailProps {
thumbnailData: {
mimeType: string,
resource: string,
}
iconExtraClasses?: string,
contentTypeIconPath?: string | null,
}

const Thumbnail = ({ thumbnailData, iconExtraClasses = '', contentTypeIconPath = null }: ThumbnailProps) => {
const renderContentTypeIcon = () => {
if (!contentTypeIconPath) {
return null;
Expand Down Expand Up @@ -32,18 +38,4 @@ const Thumbnail = ({ thumbnailData, iconExtraClasses, contentTypeIconPath }) =>
);
};

Thumbnail.propTypes = {
thumbnailData: PropTypes.shape({
mimeType: PropTypes.string.isRequired,
resource: PropTypes.string.isRequired,
}).isRequired,
iconExtraClasses: PropTypes.string,
contentTypeIconPath: PropTypes.string,
};

Thumbnail.defaultProps = {
iconExtraClasses: null,
contentTypeIconPath: null,
};

export default Thumbnail;
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "ts-config-ibexa/tsconfig.json",
}

0 comments on commit c284d43

Please sign in to comment.