Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9109: Enabling TypeScript (ts-loader) with Webpack Encore #1373

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recipesEndpoint": "https://api.github.com/repos/ibexa/recipes-dev/contents/index.json?ref=flex/pull-145",
"packages": []
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"prettier": "eslint-config-ibexa/prettier",
"dependencies": {},
"devDependencies": {
"eslint-config-ibexa": "https://github.com/ibexa/eslint-config-ibexa.git#~v1.1.1"
"eslint-config-ibexa": "https://github.com/ibexa/eslint-config-ibexa.git#IBX-9109-enabling-typescript"
},
"scripts": {
"test": "yarn prettier-test && yarn eslint-test",
"fix": "yarn prettier-test --write && yarn eslint-test --fix",
"eslint-test": "eslint \"./src/bundle/Resources/**/*.js\" \"./src/bundle/ui-dev/**/*.js\"",
"prettier-test": "yarn prettier \"./src/bundle/Resources/**/*.{js,scss}\" \"./src/bundle/ui-dev/**/*.js\" --check"
"eslint-test": "eslint \"./src/bundle/Resources/**/*.{js,ts}\" \"./src/bundle/ui-dev/**/*.{js,tsx}\"",
"prettier-test": "yarn prettier \"./src/bundle/Resources/**/*.{js,ts,scss}\" \"./src/bundle/ui-dev/**/*.{js,tsx}\" --check"
}
}
1 change: 1 addition & 0 deletions src/bundle/Resources/encore/ibexa.config.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
module.exports = (Encore) => {
Encore.addAliases({
'@ibexa-admin-ui': path.resolve('./vendor/ibexa/admin-ui'),
'@ibexa-admin-ui-helpers': path.resolve('./vendor/ibexa/admin-ui/src/bundle/Resources/public/js/scripts/helpers'),
'@ibexa-admin-ui-modules': path.resolve('./vendor/ibexa/admin-ui/src/bundle/ui-dev/src/modules'),
});
};
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
28 changes: 28 additions & 0 deletions src/bundle/Resources/public/ts/admin.search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(function (document: Document) {
const searchForm = document.querySelector<HTMLFormElement>('.ibexa-search-form');
const searchInput = document.querySelector<HTMLInputElement>('.ibexa-search-form__search-input');
const headerSearchInput = document.querySelector<HTMLInputElement>('.ibexa-global-search__input');
const languageSelector = document.querySelector<HTMLSelectElement>('.ibexa-filters__item--language-selector .ibexa-filters__select');
const headerSearchSubmitBtn = document.querySelector<HTMLButtonElement>(
'.ibexa-main-header .ibexa-input-text-wrapper__action-btn--search',
);

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,10 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';

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

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

const Thumbnail = ({ thumbnailData, iconExtraClasses, contentTypeIconPath }: ThumbnailProps) => {
const renderContentTypeIcon = (): JSX.Element | null => {
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;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Popup from '../common/popup/popup.component';
import ActionButton from './components/action-btn/action.btn.js';
import Pagination from '../common/pagination/pagination.js';
import NoItemsComponent from './components/no-items/no.items.component.js';
import Icon from '../common/icon/icon.js';
import Icon from '../common/icon/icon';
import PaginationInfo from '../common/pagination/pagination.info.js';

import deepClone from '../common/helpers/deep.clone.helper.js';
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "ts-config-ibexa/tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@ibexa-admin-ui/*": ["./*"],
"@ibexa-admin-ui-helpers/*": ["src/bundle/Resources/public/js/scripts/helpers/*"]
}
},
}
Loading