diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5fec189c..f77352d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,49 +18,8 @@ permissions: contents: write jobs: - deploy-test: - name: 🚀 Deploy to test env (fly.io) - runs-on: ubuntu-latest - if: ${{ github.base_ref == 'main' || (github.ref == 'refs/heads/main' && github.event_name == 'push') }} - steps: - - name: ⬇️ Checkout repo - uses: actions/checkout@v3 - - uses: superfly/flyctl-actions/setup-flyctl@master - - - name: 👀 Read app name - uses: SebRollen/toml-action@v1.0.0 - id: app_name - with: - file: "fly.toml" - field: "app" - - - name: 🚀 Deploy Test - run: flyctl deploy --remote-only --wait-timeout=300 --ha=false - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - - manual-approval: - name: Manual Approval - runs-on: ubuntu-latest - needs: deploy-test - if: success() - - permissions: - issues: write - - steps: - - name: Await Manual Approval - uses: trstringer/manual-approval@v1 - with: - secret: ${{ github.TOKEN }} - approvers: DmitryPopov - minimum-approvals: 1 - issue-title: "Manual Approval Required for Release" - issue-body: "Please approve or deny the deployment." - build: name: 🛠 Build - needs: manual-approval runs-on: ubuntu-22.04 if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' }} permissions: diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8eba52..2138071a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,141 @@ +## [v1.65.23](https://github.com/wanderer-industries/wanderer/compare/v1.65.22...v1.65.23) (2025-06-04) + + + + +### Bug Fixes: + +* Core: Added back arm docker image build + +## [v1.65.22](https://github.com/wanderer-industries/wanderer/compare/v1.65.21...v1.65.22) (2025-06-04) + + + + +### Bug Fixes: + +* Core: Fix character tracking issues + +## [v1.65.21](https://github.com/wanderer-industries/wanderer/compare/v1.65.20...v1.65.21) (2025-06-01) + + + + +### Bug Fixes: + +* Core: Fix connection pool errors + +## [v1.65.20](https://github.com/wanderer-industries/wanderer/compare/v1.65.19...v1.65.20) (2025-06-01) + + + + +### Bug Fixes: + +* Core: fix waypoint set timeout errors + +## [v1.65.19](https://github.com/wanderer-industries/wanderer/compare/v1.65.18...v1.65.19) (2025-06-01) + + + + +### Bug Fixes: + +* Core: fix updating character online + +## [v1.65.18](https://github.com/wanderer-industries/wanderer/compare/v1.65.17...v1.65.18) (2025-05-30) + + + + +### Bug Fixes: + +* Core: fix updating systems and connections + +## [v1.65.17](https://github.com/wanderer-industries/wanderer/compare/v1.65.16...v1.65.17) (2025-05-29) + + + + +### Bug Fixes: + +* Core: fix updating systems and connections + +* Comments: fix error loading comments + +## [v1.65.16](https://github.com/wanderer-industries/wanderer/compare/v1.65.15...v1.65.16) (2025-05-29) + + + + +### Bug Fixes: + +* Map: Allow lock systems for members + +## [v1.65.15](https://github.com/wanderer-industries/wanderer/compare/v1.65.14...v1.65.15) (2025-05-28) + + + + +## [v1.65.14](https://github.com/wanderer-industries/wanderer/compare/v1.65.13...v1.65.14) (2025-05-28) + + + + +## [v1.65.13](https://github.com/wanderer-industries/wanderer/compare/v1.65.12...v1.65.13) (2025-05-28) + + + + +### Bug Fixes: + +* Signatures: small wh size is now passed from signature to connection + +## [v1.65.12](https://github.com/wanderer-industries/wanderer/compare/v1.65.11...v1.65.12) (2025-05-27) + + + + +### Bug Fixes: + +* Map: Fixed showing character ship + +## [v1.65.11](https://github.com/wanderer-industries/wanderer/compare/v1.65.10...v1.65.11) (2025-05-27) + + + + +### Bug Fixes: + +* Map: Fixed showing character ship + +## [v1.65.10](https://github.com/wanderer-industries/wanderer/compare/v1.65.9...v1.65.10) (2025-05-27) + + + + +### Bug Fixes: + +* Map: Fixed sorting for characters in Local + +* Map: Rally: fixed conflict style of status and rally + +* Core: Fixed character token refresh + +* Map: Add Rally point. Change placement of settings in Map User Settings. Add ability to placement minimap. + +* Map: Routes - hide user routes btn from context if subscriptions is not active or widget is closed. Also now hidden widget will show again in place where it was on moment of hide (except cases when screen size has changed. + +* Map: PINGS - Rally point first prototype + +## [v1.65.9](https://github.com/wanderer-industries/wanderer/compare/v1.65.8...v1.65.9) (2025-05-26) + + + + ## [v1.65.8](https://github.com/wanderer-industries/wanderer/compare/v1.65.7...v1.65.8) (2025-05-26) diff --git a/assets/.eslintrc.cjs b/assets/.eslintrc.cjs index c22d415d..e19b7830 100644 --- a/assets/.eslintrc.cjs +++ b/assets/.eslintrc.cjs @@ -17,5 +17,6 @@ module.exports = { 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 'react/react-in-jsx-scope': 'off', '@typescript-eslint/ban-ts-comment': 'off', + "linebreak-style": "off", }, }; diff --git a/assets/.prettierrc b/assets/.prettierrc index 33263743..6dcb9705 100644 --- a/assets/.prettierrc +++ b/assets/.prettierrc @@ -7,5 +7,5 @@ "semi": true, "tabWidth": 2, "useTabs": false, - "endOfLine": "lf" + "endOfLine": "auto" } diff --git a/assets/js/hooks/Mapper/common-styles/fixes.scss b/assets/js/hooks/Mapper/common-styles/fixes.scss index 8a23afa6..ccd456ed 100644 --- a/assets/js/hooks/Mapper/common-styles/fixes.scss +++ b/assets/js/hooks/Mapper/common-styles/fixes.scss @@ -198,3 +198,17 @@ } } + +.p-autocomplete .p-autocomplete-multiple-container:not(.p-disabled).p-focus { + box-shadow: 0 0 0 1px #335c7e; + border-color: #335c7e; +} + +.p-inputtext:enabled:focus { + box-shadow: 0 0 0 1px #335c7e; + border-color: #335c7e; +} + +.p-inputtext:enabled:hover { + border-color: #335c7e; +} diff --git a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/ContextMenuSystem.tsx b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/ContextMenuSystem.tsx index 10529547..dd7f7190 100644 --- a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/ContextMenuSystem.tsx +++ b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/ContextMenuSystem.tsx @@ -1,6 +1,6 @@ import React, { RefObject } from 'react'; import { ContextMenu } from 'primereact/contextmenu'; -import { SolarSystemRawType } from '@/hooks/Mapper/types'; +import { PingType, SolarSystemRawType } from '@/hooks/Mapper/types'; import { useContextMenuSystemItems } from '@/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemItems.tsx'; import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts'; @@ -19,6 +19,7 @@ export interface ContextMenuSystemProps { onSystemStatus(val: number): void; onSystemLabels(val: string): void; onCustomLabelDialog(): void; + onTogglePing(type: PingType, solar_system_id: string, hasPing: boolean): void; onWaypointSet: WaypointSetContextHandler; } diff --git a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/index.ts b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/index.ts index fd80b969..404922d3 100644 --- a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/index.ts +++ b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/index.ts @@ -1,3 +1,4 @@ export * from './useTagMenu'; export * from './useStatusMenu'; export * from './useLabelsMenu'; +export * from './useUserRoute'; diff --git a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/useUserRoute.tsx b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/useUserRoute.tsx new file mode 100644 index 00000000..c316eb0b --- /dev/null +++ b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/hooks/useUserRoute.tsx @@ -0,0 +1,42 @@ +import { MapUserAddIcon, MapUserDeleteIcon } from '@/hooks/Mapper/icons'; +import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; +import { useCallback, useRef } from 'react'; +import { WidgetsIds } from '@/hooks/Mapper/components/mapInterface/constants.tsx'; + +interface UseUserRouteProps { + systemId: string | undefined; + userHubs: string[]; + onUserHubToggle(): void; +} + +export const useUserRoute = ({ userHubs, systemId, onUserHubToggle }: UseUserRouteProps) => { + const { + data: { isSubscriptionActive }, + windowsSettings, + } = useMapRootState(); + + const ref = useRef({ userHubs, systemId, onUserHubToggle, isSubscriptionActive, windowsSettings }); + ref.current = { userHubs, systemId, onUserHubToggle, isSubscriptionActive, windowsSettings }; + + return useCallback(() => { + const { userHubs, systemId, onUserHubToggle, isSubscriptionActive, windowsSettings } = ref.current; + + const isVisibleUserRoutes = windowsSettings.visible.some(x => x === WidgetsIds.userRoutes); + + if (!isSubscriptionActive || !isVisibleUserRoutes || !systemId) { + return []; + } + + return [ + { + label: !userHubs.includes(systemId) ? 'Add User Route' : 'Remove User Route', + icon: !userHubs.includes(systemId) ? ( + + ) : ( + + ), + command: onUserHubToggle, + }, + ]; + }, [windowsSettings]); +}; diff --git a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemHandlers.ts b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemHandlers.ts index 5df749a2..7c1afd7f 100644 --- a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemHandlers.ts +++ b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemHandlers.ts @@ -5,6 +5,7 @@ import { SolarSystemRawType } from '@/hooks/Mapper/types'; import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts'; import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts'; import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks'; +// import { PingType } from '@/hooks/Mapper/types/ping.ts'; interface UseContextMenuSystemHandlersProps { hubs: string[]; @@ -93,6 +94,22 @@ export const useContextMenuSystemHandlers = ({ setSystem(undefined); }, []); + // const onTogglePingRally = useCallback(() => { + // const { userHubs, system, outCommand } = ref.current; + // if (!system) { + // return; + // } + // + // outCommand({ + // type: OutCommand.openPing, + // data: { + // solar_system_id: system, + // type: PingType.Rally, + // }, + // }); + // setSystem(undefined); + // }, []); + const onSystemTag = useCallback((tag?: string) => { const { system, outCommand } = ref.current; if (!system) { @@ -198,6 +215,7 @@ export const useContextMenuSystemHandlers = ({ onLockToggle, onHubToggle, onUserHubToggle, + // onTogglePingRally, onSystemTag, onSystemTemporaryName, onSystemStatus, diff --git a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemItems.tsx b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemItems.tsx index be7ebf7a..66af65b5 100644 --- a/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemItems.tsx +++ b/assets/js/hooks/Mapper/components/contexts/ContextMenuSystem/useContextMenuSystemItems.tsx @@ -1,4 +1,9 @@ -import { useLabelsMenu, useStatusMenu, useTagMenu } from '@/hooks/Mapper/components/contexts/ContextMenuSystem/hooks'; +import { + useLabelsMenu, + useStatusMenu, + useTagMenu, + useUserRoute, +} from '@/hooks/Mapper/components/contexts/ContextMenuSystem/hooks'; import { useMemo } from 'react'; import { getSystemById } from '@/hooks/Mapper/helpers'; import classes from './ContextMenuSystem.module.scss'; @@ -10,13 +15,19 @@ import { useMapCheckPermissions } from '@/hooks/Mapper/mapRootProvider/hooks/api import { UserPermission } from '@/hooks/Mapper/types/permissions.ts'; import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts'; import { getSystemStaticInfo } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic'; -import { MapAddIcon, MapDeleteIcon, MapUserAddIcon, MapUserDeleteIcon } from '@/hooks/Mapper/icons'; +import { MapAddIcon, MapDeleteIcon } from '@/hooks/Mapper/icons'; +import { PingType } from '@/hooks/Mapper/types'; +import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; +import clsx from 'clsx'; +import { MenuItem } from 'primereact/menuitem'; +import { MenuItemWithInfo, WdMenuItem } from '@/hooks/Mapper/components/ui-kit'; export const useContextMenuSystemItems = ({ onDeleteSystem, onLockToggle, onHubToggle, onUserHubToggle, + onTogglePing, onSystemTag, onSystemStatus, onSystemLabels, @@ -33,11 +44,33 @@ export const useContextMenuSystemItems = ({ const getLabels = useLabelsMenu(systems, systemId, onSystemLabels, onCustomLabelDialog); const getWaypointMenu = useWaypointMenu(onWaypointSet); const canLockSystem = useMapCheckPermissions([UserPermission.LOCK_SYSTEM]); + const canManageSystem = useMapCheckPermissions([UserPermission.UPDATE_SYSTEM]); + const canDeleteSystem = useMapCheckPermissions([UserPermission.DELETE_SYSTEM]); + const getUserRoutes = useUserRoute({ userHubs, systemId, onUserHubToggle }); - return useMemo(() => { + const { + data: { pings, isSubscriptionActive }, + } = useMapRootState(); + + const ping = useMemo(() => (pings.length === 1 ? pings[0] : undefined), [pings]); + const isShowPingBtn = useMemo(() => { + if (!isSubscriptionActive) { + return false; + } + + if (pings.length === 0) { + return true; + } + + return pings[0].solar_system_id === systemId; + }, [isSubscriptionActive, pings, systemId]); + + return useMemo((): MenuItem[] => { const system = systemId ? getSystemById(systems, systemId) : undefined; const systemStaticInfo = getSystemStaticInfo(systemId)!; + const hasPing = ping?.solar_system_id === systemId; + if (!system || !systemId) { return []; } @@ -72,55 +105,96 @@ export const useContextMenuSystemItems = ({ ), command: onHubToggle, }, + ...getUserRoutes(), + + { separator: true }, { - label: !userHubs.includes(systemId) ? 'Add User Route' : 'Remove User Route', - icon: !userHubs.includes(systemId) ? ( - - ) : ( - - ), - command: onUserHubToggle, + command: () => onTogglePing(PingType.Rally, systemId, hasPing), + disabled: !isShowPingBtn, + template: () => { + const iconClasses = clsx({ + 'pi text-cyan-400 hero-signal': !hasPing, + 'pi text-red-400 hero-signal-slash': hasPing, + }); + + if (isShowPingBtn) { + return {!hasPing ? 'Ping: RALLY' : 'Cancel: RALLY'}; + } + + return ( + + + {!hasPing ? 'Ping: RALLY' : 'Cancel: RALLY'} + + + ); + }, }, - ...(system.locked - ? canLockSystem - ? [ - { - label: 'Unlock', - icon: PrimeIcons.LOCK_OPEN, - command: onLockToggle, - }, - ] - : [] - : [ - ...(canLockSystem - ? [ - { - label: 'Lock', - icon: PrimeIcons.LOCK, - command: onLockToggle, - }, - ] - : []), + ...(system.locked && canLockSystem + ? [ + { + label: 'Unlock', + icon: PrimeIcons.LOCK_OPEN, + command: onLockToggle, + }, + ] + : []), + ...(!system.locked && canManageSystem + ? [ + { + label: 'Lock', + icon: PrimeIcons.LOCK, + command: onLockToggle, + }, + ] + : []), + + ...(canDeleteSystem && !system.locked + ? [ { separator: true }, { - label: 'Delete', - icon: PrimeIcons.TRASH, command: onDeleteSystem, + disabled: hasPing, + template: () => { + if (!hasPing) { + return Delete; + } + + return ( + + + Delete + + + ); + }, }, - ]), + ] + : []), ]; }, [ - canLockSystem, - systems, systemId, + systems, getTags, getStatus, getLabels, getWaypointMenu, + getUserRoutes, hubs, onHubToggle, - onOpenSettings, + canLockSystem, onLockToggle, + canDeleteSystem, onDeleteSystem, + onOpenSettings, + onTogglePing, + ping, + isShowPingBtn, ]); }; diff --git a/assets/js/hooks/Mapper/components/contexts/components/FastSystemActions/FastSystemActions.tsx b/assets/js/hooks/Mapper/components/contexts/components/FastSystemActions/FastSystemActions.tsx index 41a09732..6f9b0ffe 100644 --- a/assets/js/hooks/Mapper/components/contexts/components/FastSystemActions/FastSystemActions.tsx +++ b/assets/js/hooks/Mapper/components/contexts/components/FastSystemActions/FastSystemActions.tsx @@ -1,5 +1,5 @@ import { useCallback, useRef } from 'react'; -import { LayoutEventBlocker, WdImageSize, WdImgButton } from '@/hooks/Mapper/components/ui-kit'; +import { LayoutEventBlocker, TooltipPosition, WdImageSize, WdImgButton } from '@/hooks/Mapper/components/ui-kit'; import { ANOIK_ICON, DOTLAN_ICON, ZKB_ICON } from '@/hooks/Mapper/icons'; import classes from './FastSystemActions.module.scss'; @@ -59,9 +59,21 @@ export const FastSystemActions = ({ return (
- - - + + +
@@ -69,14 +81,14 @@ export const FastSystemActions = ({ textSize={WdImageSize.off} className={PrimeIcons.COPY} onClick={copySystemNameToClipboard} - tooltip={{ content: 'Copy system name' }} + tooltip={{ position: TooltipPosition.top, content: 'Copy system name' }} /> {showEdit && ( )}
diff --git a/assets/js/hooks/Mapper/components/map/Map.tsx b/assets/js/hooks/Mapper/components/map/Map.tsx index 0494a545..87e4cdfc 100644 --- a/assets/js/hooks/Mapper/components/map/Map.tsx +++ b/assets/js/hooks/Mapper/components/map/Map.tsx @@ -28,11 +28,12 @@ import { import { getBehaviorForTheme } from './helpers/getThemeBehavior'; import { OnMapAddSystemCallback, OnMapSelectionChange } from './map.types'; import { SESSION_KEY } from '@/hooks/Mapper/constants.ts'; -import { SolarSystemConnection, SolarSystemRawType } from '@/hooks/Mapper/types'; +import { PingData, SolarSystemConnection, SolarSystemRawType } from '@/hooks/Mapper/types'; import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts'; import { NodeSelectionMouseHandler } from '@/hooks/Mapper/components/contexts/types.ts'; import clsx from 'clsx'; import { useBackgroundVars } from './hooks/useBackgroundVars'; +import type { PanelPosition } from '@reactflow/core'; const DEFAULT_VIEW_PORT = { zoom: 1, x: 0, y: 0 }; @@ -95,6 +96,8 @@ interface MapCompProps { isShowBackgroundPattern?: boolean; isSoftBackground?: boolean; theme?: string; + pings: PingData[]; + minimapPlacement?: PanelPosition; } const MapComp = ({ @@ -112,6 +115,8 @@ const MapComp = ({ isSoftBackground, theme, onAddSystem, + pings, + minimapPlacement = 'bottom-right', }: MapCompProps) => { const { getNodes } = useReactFlow(); const [nodes, , onNodesChange] = useNodesState>(initialNodes); @@ -206,8 +211,9 @@ const MapComp = ({ ...x, showKSpaceBG: showKSpaceBG, isThickConnections: isThickConnections, + pings, })); - }, [showKSpaceBG, isThickConnections, update]); + }, [showKSpaceBG, isThickConnections, pings, update]); return ( <> @@ -270,7 +276,9 @@ const MapComp = ({ // onlyRenderVisibleElements selectionMode={SelectionMode.Partial} > - {isShowMinimap && } + {isShowMinimap && ( + + )} {isShowBackgroundPattern && } {/* + + + + + ); +}; diff --git a/assets/js/hooks/Mapper/components/mapInterface/components/SystemPingDialog/index.ts b/assets/js/hooks/Mapper/components/mapInterface/components/SystemPingDialog/index.ts new file mode 100644 index 00000000..6eb7bcc4 --- /dev/null +++ b/assets/js/hooks/Mapper/components/mapInterface/components/SystemPingDialog/index.ts @@ -0,0 +1 @@ +export * from './SystemPingDialog'; diff --git a/assets/js/hooks/Mapper/components/mapInterface/components/index.ts b/assets/js/hooks/Mapper/components/mapInterface/components/index.ts index 75d50c2e..740698d3 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/components/index.ts +++ b/assets/js/hooks/Mapper/components/mapInterface/components/index.ts @@ -2,3 +2,4 @@ export * from './Widget'; export * from './SystemSettingsDialog'; export * from './SystemCustomLabelDialog'; export * from './SystemLinkSignatureDialog'; +export * from './PingsInterface'; diff --git a/assets/js/hooks/Mapper/components/mapInterface/constants.tsx b/assets/js/hooks/Mapper/components/mapInterface/constants.tsx index 093724d7..7e06f3c0 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/constants.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/constants.tsx @@ -62,7 +62,7 @@ export const DEFAULT_WIDGETS: WindowProps[] = [ }, { id: WidgetsIds.userRoutes, - position: { x: 10, y: 530 }, + position: { x: 10, y: 10 }, size: { width: 510, height: 200 }, zIndex: 0, content: () => , diff --git a/assets/js/hooks/Mapper/components/mapInterface/helpers/sortCharacters.ts b/assets/js/hooks/Mapper/components/mapInterface/helpers/sortCharacters.ts index 175d93e3..f547c56f 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/helpers/sortCharacters.ts +++ b/assets/js/hooks/Mapper/components/mapInterface/helpers/sortCharacters.ts @@ -1,6 +1,10 @@ import { CharacterTypeRaw, WithIsOwnCharacter } from '@/hooks/Mapper/types'; export const sortCharacters = (a: CharacterTypeRaw & WithIsOwnCharacter, b: CharacterTypeRaw & WithIsOwnCharacter) => { + if (a.online === b.online) { + return a.name.localeCompare(b.name); + } + if (a.online !== b.online) { return a.online && !b.online ? -1 : 1; } diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components/LocalCharactersItemTemplate/LocalCharactersItemTemplate.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components/LocalCharactersItemTemplate/LocalCharactersItemTemplate.tsx index dcc466c4..a25663c3 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components/LocalCharactersItemTemplate/LocalCharactersItemTemplate.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components/LocalCharactersItemTemplate/LocalCharactersItemTemplate.tsx @@ -1,8 +1,8 @@ -import classes from './LocalCharactersItemTemplate.module.scss'; -import clsx from 'clsx'; -import { CharacterCard } from '@/hooks/Mapper/components/ui-kit'; import { CharItemProps } from '@/hooks/Mapper/components/mapInterface/widgets/LocalCharacters/components'; +import { CharacterCard } from '@/hooks/Mapper/components/ui-kit'; +import clsx from 'clsx'; import { VirtualScrollerTemplateOptions } from 'primereact/virtualscroller'; +import classes from './LocalCharactersItemTemplate.module.scss'; export type LocalCharactersItemTemplateProps = { showShipName: boolean } & CharItemProps & VirtualScrollerTemplateOptions; @@ -22,7 +22,7 @@ export const LocalCharactersItemTemplate = ({ showShipName, ...options }: LocalC )} style={{ height: `${options.props.itemSize}px` }} > - + ); }; diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx index 4d1775d7..dbdd9a09 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, forwardRef, useContext, useImperativeHandle, useState } from 'react'; +import React, { createContext, forwardRef, useContext } from 'react'; import { RoutesImperativeHandle, RoutesProviderInnerProps, @@ -15,17 +15,14 @@ const RoutesContext = createContext({ data: {}, }); -export const RoutesProvider = forwardRef(({ children, ...props }, ref) => { - const [loading, setLoading] = useState(false); +// INFO: this component have imperative handler but now it not using. +export const RoutesProvider = forwardRef( + ({ children, ...props } /*, ref*/) => { + // useImperativeHandle(ref, () => ({})); - useImperativeHandle(ref, () => ({ - stopLoading() { - setLoading(false); - }, - })); - - return {children}; -}); + return {children}; + }, +); RoutesProvider.displayName = 'RoutesProvider'; export const useRouteProvider = () => { diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx index 6ac4ea20..b38c8aa3 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx @@ -3,16 +3,15 @@ import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { LayoutEventBlocker, LoadingWrapper, - SystemViewStandalone, + SystemView, TooltipPosition, WdCheckbox, WdImgButton, } from '@/hooks/Mapper/components/ui-kit'; import { useLoadSystemStatic } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts'; + import { forwardRef, MouseEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { getSystemById } from '@/hooks/Mapper/helpers/getSystemById.ts'; import classes from './RoutesWidget.module.scss'; -import { useLoadRoutes } from './hooks'; import { RoutesList } from './RoutesList'; import clsx from 'clsx'; import { Route } from '@/hooks/Mapper/types/routes.ts'; @@ -42,24 +41,13 @@ export const RoutesWidgetContent = () => { const { data: { selectedSystems, systems, isSubscriptionActive }, } = useMapRootState(); - const { hubs = [], routesList, isRestricted } = useRouteProvider(); + const { hubs = [], routesList, isRestricted, loading } = useRouteProvider(); const [systemId] = selectedSystems; - const { loading } = useLoadRoutes(); - - const { systems: systemStatics, loadSystems, lastUpdateKey } = useLoadSystemStatic({ systems: hubs ?? [] }); + const { systems: systemStatics, loadSystems } = useLoadSystemStatic({ systems: hubs ?? [] }); const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers(); - const preparedHubs = useMemo(() => { - return hubs.map(x => { - const sys = getSystemById(systems, x.toString()); - - return { ...systemStatics.get(parseInt(x))!, ...(sys && { customName: sys.name ?? '' }) }; - }); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [hubs, systems, systemStatics, lastUpdateKey]); - const preparedRoutes: Route[] = useMemo(() => { return ( routesList?.routes @@ -125,9 +113,7 @@ export const RoutesWidgetContent = () => {
{preparedRoutes.map(route => { - const sys = preparedHubs.find(x => x.solar_system_id === route.destination)!; - - // TODO do not delte this console log + // TODO do not delete this console log // eslint-disable-next-line no-console // console.log('JOipP', `Check sys [${route.destination}]:`, sys); @@ -144,12 +130,12 @@ export const RoutesWidgetContent = () => { }} /> -
{route.has_connection ? route.systems?.length ?? 2 : ''}
diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks/useLoadRoutes.ts b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks/useLoadRoutes.ts index 85b4629d..630e333b 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks/useLoadRoutes.ts +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks/useLoadRoutes.ts @@ -1,7 +1,8 @@ -import { useCallback, useEffect, useRef } from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; -import { useRouteProvider } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx'; import { RoutesType } from '@/hooks/Mapper/mapRootProvider/types.ts'; +import { LoadRoutesCommand } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts'; +import { RoutesList } from '@/hooks/Mapper/types/routes.ts'; function usePrevious(value: T): T | undefined { const ref = useRef(); @@ -13,8 +14,22 @@ function usePrevious(value: T): T | undefined { return ref.current; } -export const useLoadRoutes = () => { - const { data: routesSettings, loadRoutesCommand, hubs, routesList, loading, setLoading } = useRouteProvider(); +type UseLoadRoutesProps = { + loadRoutesCommand: LoadRoutesCommand; + hubs: string[]; + routesList: RoutesList | undefined; + data: RoutesType; + deps?: unknown[]; +}; + +export const useLoadRoutes = ({ + data: routesSettings, + loadRoutesCommand, + hubs, + routesList, + deps = [], +}: UseLoadRoutesProps) => { + const [loading, setLoading] = useState(false); const { data: { selectedSystems, systems, connections }, @@ -55,7 +70,8 @@ export const useLoadRoutes = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error .map(x => routesSettings[x]), + ...deps, ]); - return { loading, loadRoutes }; + return { loading, loadRoutes, setLoading }; }; diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts index 590e63de..5207104b 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts @@ -10,17 +10,14 @@ export type RoutesWidgetProps = { update: (d: RoutesType) => void; hubs: string[]; routesList: RoutesList | undefined; + loading: boolean; - loadRoutesCommand: LoadRoutesCommand; addHubCommand: AddHubCommand; toggleHubCommand: ToggleHubCommand; isRestricted?: boolean; }; -export type RoutesProviderInnerProps = RoutesWidgetProps & { - loading: boolean; - setLoading(loading: boolean): void; -}; +export type RoutesProviderInnerProps = RoutesWidgetProps; export type RoutesImperativeHandle = { stopLoading: () => void; diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesPublic/WRoutesPublic.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesPublic/WRoutesPublic.tsx index 7aeaf957..c77193f9 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesPublic/WRoutesPublic.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesPublic/WRoutesPublic.tsx @@ -2,7 +2,6 @@ import { Commands, OutCommand } from '@/hooks/Mapper/types'; import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { AddHubCommand, - LoadRoutesCommand, RoutesImperativeHandle, } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/types.ts'; import { useCallback, useRef } from 'react'; @@ -13,24 +12,11 @@ export const WRoutesPublic = () => { const { outCommand, storedSettings: { settingsRoutes, settingsRoutesUpdate }, - data: { hubs, routes }, + data: { hubs, routes, loadingPublicRoutes }, } = useMapRootState(); const ref = useRef(null); - const loadRoutesCommand: LoadRoutesCommand = useCallback( - async (systemId, routesSettings) => { - outCommand({ - type: OutCommand.getRoutes, - data: { - system_id: systemId, - routes_settings: routesSettings, - }, - }); - }, - [outCommand], - ); - const addHubCommand: AddHubCommand = useCallback( async systemId => { if (hubs.includes(systemId)) { @@ -72,10 +58,10 @@ export const WRoutesPublic = () => { ref={ref} title="Routes" data={settingsRoutes} + loading={loadingPublicRoutes} update={settingsRoutesUpdate} hubs={hubs} routesList={routes} - loadRoutesCommand={loadRoutesCommand} addHubCommand={addHubCommand} toggleHubCommand={toggleHubCommand} /> diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesUser/WRoutesUser.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesUser/WRoutesUser.tsx index 4bfc2dff..28af7121 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesUser/WRoutesUser.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/WRoutesUser/WRoutesUser.tsx @@ -8,6 +8,7 @@ import { import { useCallback, useRef } from 'react'; import { RoutesWidget } from '@/hooks/Mapper/components/mapInterface/widgets'; import { useMapEventListener } from '@/hooks/Mapper/events'; +import { useLoadRoutes } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/hooks'; export const WRoutesUser = () => { const { @@ -61,9 +62,17 @@ export const WRoutesUser = () => { [userHubs, outCommand], ); + // INFO: User routes loading only if open widget with user routes + const { loading, setLoading } = useLoadRoutes({ + data: settingsRoutes, + hubs: userHubs, + loadRoutesCommand, + routesList: userRoutes, + }); + useMapEventListener(event => { if (event.name === Commands.userRoutes) { - ref.current?.stopLoading(); + setLoading(false); } return true; }); @@ -76,7 +85,7 @@ export const WRoutesUser = () => { update={settingsRoutesUpdate} hubs={userHubs} routesList={userRoutes} - loadRoutesCommand={loadRoutesCommand} + loading={loading} addHubCommand={addHubCommand} toggleHubCommand={toggleHubCommand} isRestricted diff --git a/assets/js/hooks/Mapper/components/mapRootContent/MapRootContent.tsx b/assets/js/hooks/Mapper/components/mapRootContent/MapRootContent.tsx index 629db822..f301ebf1 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/MapRootContent.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/MapRootContent.tsx @@ -13,6 +13,7 @@ import { useCharacterActivityHandlers } from './hooks/useCharacterActivityHandle import { TrackingDialog } from '@/hooks/Mapper/components/mapRootContent/components/TrackingDialog'; import { useMapEventListener } from '@/hooks/Mapper/events'; import { Commands } from '@/hooks/Mapper/types'; +import { PingsInterface } from '@/hooks/Mapper/components/mapInterface/components'; export interface MapRootContentProps {} @@ -62,17 +63,21 @@ export const MapRootContent = ({}: MapRootContentProps) => { onShowOnTheMap={handleShowOnTheMap} onShowMapSettings={handleShowMapSettings} onShowTrackingDialog={handleShowTrackingDialog} + additionalContent={} /> ) : (
- +
+ + +
{mapInterface}
diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx index 87ae195e..cf581d83 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx @@ -15,7 +15,10 @@ export interface MapContextMenuProps { } export const MapContextMenu = ({ onShowOnTheMap, onShowMapSettings, onShowTrackingDialog }: MapContextMenuProps) => { - const { outCommand, setInterfaceSettings } = useMapRootState(); + const { + outCommand, + storedSettings: { setInterfaceSettings }, + } = useMapRootState(); const canTrackCharacters = useMapCheckPermissions([UserPermission.TRACK_CHARACTER]); diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettings.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettings.tsx index f0fc4e9c..26b8c113 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettings.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettings.tsx @@ -4,13 +4,7 @@ import { useCallback, useRef, useState } from 'react'; import { TabPanel, TabView } from 'primereact/tabview'; import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { OutCommand } from '@/hooks/Mapper/types'; -import { - CONNECTIONS_CHECKBOXES_PROPS, - SIGNATURES_CHECKBOXES_PROPS, - SYSTEMS_CHECKBOXES_PROPS, - THEME_SETTING, - UI_CHECKBOXES_PROPS, -} from './constants.ts'; +import { CONNECTIONS_CHECKBOXES_PROPS, SIGNATURES_CHECKBOXES_PROPS, SYSTEMS_CHECKBOXES_PROPS } from './constants.ts'; import { MapSettingsProvider, useMapSettings, @@ -34,6 +28,8 @@ export const MapSettingsComp = ({ visible, onHide }: MapSettingsProps) => { refVars.current = { outCommand, onHide, visible }; const handleShow = useCallback(async () => { + // TODO: need fix it - add type? + // @ts-ignore const { user_settings } = await refVars.current.outCommand({ type: OutCommand.getUserSettings, data: null, @@ -88,17 +84,9 @@ export const MapSettingsComp = ({ visible, onHide }: MapSettingsProps) => { {renderSettingsList(SIGNATURES_CHECKBOXES_PROPS)} - - {renderSettingsList(UI_CHECKBOXES_PROPS)} - - - - - {renderSettingItem(THEME_SETTING)} - diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettingsProvider.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettingsProvider.tsx index 89460db7..7debd4c5 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettingsProvider.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/MapSettingsProvider.tsx @@ -88,8 +88,9 @@ export const MapSettingsProvider = ({ children }: { children: ReactNode }) => { if (item.type === 'dropdown' && item.options) { return ( -
- +
+ +
{ const { renderSettingItem } = useMapSettings(); - const renderSettingsList = (list: SettingsListItem[]) => { - return list.map(renderSettingItem); - }; + const renderSettingsList = useCallback( + (list: SettingsListItem[]) => { + return list.map(renderSettingItem); + }, + [renderSettingItem], + ); - return
{renderSettingsList(COMMON_CHECKBOXES_PROPS)}
; + return ( +
+
+
{renderSettingsList(UI_CHECKBOXES_PROPS)}
+
+ +
+ +
{renderSettingItem(MINI_MAP_PLACEMENT)}
+
{renderSettingItem(PINGS_PLACEMENT)}
+
{renderSettingItem(THEME_SETTING)}
+
+ ); }; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx index 9edd4172..1f2eba20 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx @@ -10,9 +10,9 @@ interface PrettySwitchboxProps { export const PrettySwitchbox = ({ checked, setChecked, label }: PrettySwitchboxProps) => { return ( -