Skip to content
New issue

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

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

Already on GitHub? # to your account

IBX-6398: UDW as standalone as GH package #1010

Merged
merged 34 commits into from
Dec 14, 2023
Merged

Conversation

lucasOsti
Copy link
Contributor

@lucasOsti lucasOsti commented Nov 24, 2023

@adamwojs adamwojs changed the title Ibx 6398 udw as gh package IBX-06398: UDW as standalone as GH package Nov 25, 2023
@adamwojs adamwojs changed the title IBX-06398: UDW as standalone as GH package IBX-6398: UDW as standalone as GH package Nov 25, 2023
@lucasOsti lucasOsti force-pushed the IBX-6398-UDW-as-GH-package branch from 300f85d to da3193a Compare November 27, 2023 15:53
@lucasOsti lucasOsti force-pushed the IBX-6398-UDW-as-GH-package branch 2 times, most recently from 86cdf23 to 10eb46f Compare December 7, 2023 09:54
}

const iconSetPath = adminUiConfig.iconPaths.iconSets[iconSet];
return `${iconSetPath}#${path}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return `${iconSetPath}#${path}`;
return `${iconSetPath}#${path}`;

import { getJsonFromResponse } from './request.helper';
import { showErrorNotification } from './notification.helper';
import { getRestInfo, getTranslator } from './context.helper';
import { getRequestHeaders, getRequestMode } from '../../../../../ui-dev/src/modules/common/services/common.service';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would you say on using alias here as well? @ibexa-admin-ui/src/bundle/ui-dev/src/modules/common/services/common.service?
That's something we could do in future in other places as well, to avoid that many ../ (and remove thinking "is it enough ../ or I need one more? and moving files between directories)
@dew326 @Gengar-i @tischsoic @lucasOsti

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current upside of using ../../.. is that VS Code understands where a file is. If you use an alias, this file won't be recognized

@@ -355,6 +356,7 @@ export default class ContentTreeModule extends Component {

render() {
const { onClickItem, subitemsLimit, subitemsLoadLimit, treeMaxDepth, userId, resizable } = this.props;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why new line here?

@@ -1,5 +1,7 @@
import React, { useContext, useState, useEffect, useRef } from 'react';

import { getIconPath } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/icon.helper';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move it to line 21/22, to other helpers? :)

@@ -1,13 +1,14 @@
import React, { useContext } from 'react';

import { getIconPath } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/icon.helper';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -1,10 +1,14 @@
import React, { useContext, useEffect, useMemo, useRef } from 'react';

import { formatShortDateTime } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/timezone.helper';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to other helpers, they're so sad being separated 😢

@@ -1,11 +1,12 @@
import React, { useContext, useEffect } from 'react';

import { getIconPath } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/icon.helper';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above (I think)

parse as parseTooltips,
hideAll as hideAllTooltips,
} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper';
import { getAdminUiConfig, getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These helpers are happy, they're together till the end of time! 🥳

Sorry, to much code, my brain explodes...

selectedLabel: () => {
return (
<div className="c-simple-dropdown__option-label">
{getTranslator.trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{getTranslator.trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}
{getTranslator().trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}

selectedLabel: () => {
return (
<div className="c-simple-dropdown__option-label">
{getTranslator.trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{getTranslator.trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}
{getTranslator().trans(/*@Desc("Sort by date")*/ 'sorting.date.selected_label', {}, 'ibexa_universal_discovery_widget')}

@@ -222,5 +222,10 @@ services:
Ibexa\Bundle\AdminUi\Controller\Permission\LanguageLimitationController:
parent: Ibexa\Contracts\AdminUi\Controller\Controller
autowire: true


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +65 to +67
isWindows,
isMac,
isLinux,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isWindows,
isMac,
isLinux,
get isWindows() { return isWindows(); }

@lucasOsti, @GrabowskiM, @tischsoic, @dew326
What do you think about this approach?
I can add it in seperate PR.
So we can get property like helper.isWindows instead of helper.isWindows() when we only return bool true or false

Copy link
Contributor

@tischsoic tischsoic Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that avoiding () is enough to replace function with getter. What if e.g. in the future we would like to pass a parameter?

hide: delayHide ? parseInt(delayHide, 10) : 75,
};
const extraClass = tooltipNode.dataset.tooltipExtraClass ?? '';
const placement = tooltipNode.dataset.tooltipPlacement ?? 'bottom';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const placement = tooltipNode.dataset.tooltipPlacement ?? 'bottom';
const placement = tooltipNode.dataset.bsPlacement ?? 'bottom';

There suppose to be other property. I checked bootstrap docks they are using:
data-placement="top"
and in BS 5.0:
data-bs-placement="top"

const { Translator } = window;

const PaginationInfo = ({ totalCount, viewingCount, extraClasses }) => {
const PaginationInfo = ({ totalCount, viewingCount, extraClasses, Translator }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Translator = getTranslator(); maybe?

const iframeRef = createRef();
const iframeUrl = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const iframeUrl = () => {
const iframe = {
get url() {
const { locationId, languageCode, contentTypeIdentifier } = contentOnTheFlyData;
return Routing.generate('ibexa.content.on_the_fly.create', {
locationId,
languageCode,
contentTypeIdentifier,
});
}
};
// Use
console.log(iframe.url);

@GrabowskiM will be happy :>
We can also move ref here

@lucasOsti lucasOsti force-pushed the IBX-6398-UDW-as-GH-package branch 2 times, most recently from 1fedbe0 to 216b298 Compare December 7, 2023 19:33
Comment on lines +48 to +55
export const getAdminUiConfig = () => adminUiConfig;
export const getBootstrap = () => bootstrap;
export const getFlatpickr = () => flatpickr;
export const getMoment = () => moment;
export const getPopper = () => Popper;
export const getRouting = () => Routing;
export const getTranslator = () => Translator;
export const getRestInfo = () => restInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have one function getContext and we would have:

import { getContext } from './context.helper';

const { Translator, moment } = getContext();

import * as tooltips from './tooltips.helper';
import * as user from './user.helper';

(function (ibexa) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need IIFE? I think given we have modules this is not needed.

Comment on lines +22 to +24
ibexa.addConfig('helpers.contentType', contentType);
ibexa.addConfig('helpers.cookies', cookies);
ibexa.addConfig('helpers.formError', formError);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, why we have config.loader.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I create config.loader.js file wherever something was added to window.ibexa via the addConfig method

}
};

export const getAdminUiConfig = () => adminUiConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I proposed on Slack, we can avoid such functions by adding export default on object with getters and setters. (could be done in a followup PR). Example:
Screenshot 2023-12-08 at 12 36 52

@lucasOsti lucasOsti force-pushed the IBX-6398-UDW-as-GH-package branch from 3c3af15 to d46625f Compare December 13, 2023 11:33
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

3 New issues
0 Security Hotspots
No data about Coverage
2.2% Duplication on New Code

See analysis details on SonarCloud

@micszo micszo removed their assignment Dec 14, 2023
@lucasOsti lucasOsti merged commit 15704ef into main Dec 14, 2023
16 of 19 checks passed
@webhdx webhdx deleted the IBX-6398-UDW-as-GH-package branch December 14, 2023 10:54
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.