pinkmine/frontend/src/kanban-board/kanban-boards.tsx
Pavel Gnedov b9899bc032 Настройка в react приложении профилей для разработки и продакшена
- для разработки включен hotreload
- на бакенде включен CORS
2023-07-03 08:06:01 +07:00

54 lines
No EOL
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import * as KB from './kanban-board';
import { IPageStore, PageStoreLoadData } from './store';
import { observer } from 'mobx-react-lite';
import * as TopRightMenuNs from '../misc-components/top-right-menu';
import { SetIssuesReadingTimestamp } from '../utils/unreaded-provider';
import axios from 'axios';
import * as ServiceActionsButtons from '../utils/service-actions-buttons';
export type Props = {
store: IPageStore
}
export const KanbanBoards = observer((props: Props) => {
const data = props.store.data;
if (!props.store.loaded || !data) {
return <div>Loading...</div>
}
const list: any[] = [];
for (let i = 0; i < data.length; i++) {
const boardData = data[i];
const key = boardData.metainfo.title;
const board = <KB.KanbanBoard store={boardData} key={key} />;
list.push(board);
}
const topRightMenuStore = TopRightMenuNs.Store.create({visible: false});
const onAllReadClick = (e: React.MouseEvent) => {
e.stopPropagation();
SetIssuesReadingTimestamp(props.store.issueIds);
PageStoreLoadData(props.store);
};
let treeRefreshMenuItem: JSX.Element = <></>;
if (props.store.canTreeRefresh) {
const onTreeRefreshClick = (e: React.MouseEvent) => {
if (e.target !== e.currentTarget) return;
e.stopPropagation();
axios.get(`${process.env.REACT_APP_BACKEND}simple-kanban-board/tree/${props.store.name}/refresh`);
}
treeRefreshMenuItem = <button onClick={onTreeRefreshClick}>Force tree refresh</button>;
}
return (
<>
<TopRightMenuNs.TopRightMenu store={topRightMenuStore}>
<button onClick={onAllReadClick}>Всё прочитано</button>
{treeRefreshMenuItem}
<ServiceActionsButtons.IssuesForceRefreshButton/>
<ServiceActionsButtons.GetIssuesQueueSizeButton/>
</TopRightMenuNs.TopRightMenu>
{list}
</>
);
});
export default KanbanBoards;