Skip to content

сторонний контрол для отображения дерева задач#2

Open
vadimpain wants to merge 3 commits intomainfrom
dev-remote-component
Open

сторонний контрол для отображения дерева задач#2
vadimpain wants to merge 3 commits intomainfrom
dev-remote-component

Conversation

@vadimpain
Copy link
Copy Markdown
Collaborator

No description provided.

@vadimpain vadimpain self-assigned this Feb 13, 2026
Comment thread remote_component-tree-view/README.md Outdated
@@ -0,0 +1,10 @@
# Introduction
Пример сторонних контролов для вебклиента с использованием Webpack Module Federation и React
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

опечатка? веб-клиента

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

поправил

name: 'Tree',
// Загрузчики контрола. Загрузчик - это функция, принимающая информацию о контексте и точку доступа к API.
// Задача загрузчика - смонтировать корневой UI-компонент контрола в указанный DOM-элемент.
// Один и тот же контрол может отображаться в разных контекстах (карточка и обложка модуля). Если контрол должен отображаться и в карточке и в обложке,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

пропущена запятая: и в карточке, и в обложке

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

поправил

// то для него следует создать разные загрузчики для этих контекстов (*-cover-loader и *-card-loader).
loaders: [
{
// Имя загручика должно соответствовать имени загрузчика в файле component.loaders.ts.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

опечатка: загрузчика

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

поправил

@vadimpain vadimpain requested a review from iamktn April 2, 2026 05:32
Copy link
Copy Markdown

@iam-ktn iam-ktn left a comment

Choose a reason for hiding this comment

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

  1. В целом ничего криминального нет, есть несколько рекомендаций
  2. Платформа рекомендует webpack использовать? Если будет время можно попробовать перевести на vite - сильно быстрее будет собираться
  3. Можно попробовать использовать библиотеку стилей (но это так, в качестве упражнения)

@@ -0,0 +1,25 @@
{
"gantt": {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Локализация, да и сам пакет не используется? Лучше убрать

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain

  1. .ts?
  2. По разделению файлов. У тебя есть 2 ответственности в файле сейчас - базовые REST-запросы и специальная логика для получения дерева поручений. Предлагаю такую структуру:
/src/utils/request.ts // Тут будет базовый метод
/src/action-items/action-items.client.ts // Тут запросы к конкретным endpoint-ам

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

добавить типизацию

return response.json();
}

function executeGetRequest(url: string, async: boolean = false) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Предлагаю оставить только асинхронные вызовы

return request;
}

export function GetAllActionItemExecutionTaskForLeadTask(taskId: number) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain camelCase. И в следующем методе тоже

@@ -0,0 +1,43 @@
export const GetIntServiceUrl = () => window.location.origin + "/integration/OData/";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Лучше baseUrl хранить в конфиге ну или в крайнем случае запрашивать отдельным get-ом. Есть какие-то рекомендации от платформы?

const response = await executeGetRequestAsync(url);
console.log(response);
return response.value;
} catch (error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain NBD: потом желательно обработку ошибок сделать визуальной - через попапы (как в самой системе). И тут же тоже могут быть разные причины (сетевая проблемы, в ответе пришел не JSON и т.п.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Предлагаю обсудить стилизацию. Можно попробовать какой-нибудь фреймворк, где стили встроены в код компоненты - antd, MUI

};

// Компоненты
const NodeContent: React.FC<{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Давай вынесем в отдельную компоненту?

type StatusKey = 'Completed' | 'InProcess' | 'InProcessCurrent' | 'Aborted';

// Конфигурация стилей и иконок для статусов
const STATUS_CONFIG = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Map<StatusKey, { border: string; icon: string | null }> ?

} as const satisfies Record<StatusKey, { border: string; icon: string | null }>;

// Хуки и утилиты
const useTreeData = (entityId: number) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain NBD: Для читаемости можно вынести в store. Тогда в коде загрузка будет выглядеть как-то так:

useEffect(() => {
  itemsStore.loadItems(entityId)
}, [entityId]);


...

if (itemsStore.isLoading) return <Spin />; // Или другой лоадер

itemsStore.data.forEach(item => {
// Render
})

Сейчас, конечно, выгода не очевидна этого. Давай обсудим

const [isLoading, setIsLoading] = useState(false);

const fetchData = useCallback(async () => {
setIsLoading(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vadimpain Еще тут бы хорошо делать setError(null); Сейчас этот стейт нигде не сбрасывается

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants