Compare commits

..

6 Commits

Author SHA1 Message Date
CI
0194e25696 chore: release version v1.2.1 2024-10-02 12:48:06 +00:00
Dmitry Popov
189442e50f Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-02 16:47:34 +04:00
Dmitry Popov
d9bed070ec fix(ACL): Fix allowing to save map/access list with empty owner set 2024-10-02 16:47:29 +04:00
CI
a6193da8b5 chore: release version v1.2.0 2024-09-29 19:01:16 +00:00
Aleksei Chichenkov
50d35b207d Merge pull request #14 from wanderer-industries/feat-wnd-13
feat(Map): Add ability to open jump planner from routes
2024-09-29 22:00:44 +03:00
achichenkov
19eb45bfa1 feat(Map): Add ability to open jump planner from routes
Fixes #13
2024-09-29 21:47:35 +03:00
19 changed files with 252 additions and 178 deletions

View File

@@ -2,6 +2,24 @@
<!-- changelog -->
## [v1.2.1](https://github.com/wanderer-industries/wanderer/compare/v1.2.0...v1.2.1) (2024-10-02)
### Bug Fixes:
* ACL: Fix allowing to save map/access list with empty owner set
## [v1.2.0](https://github.com/wanderer-industries/wanderer/compare/v1.1.0...v1.2.0) (2024-09-29)
### Features:
* Map: Add ability to open jump planner from routes
## [v1.1.0](https://github.com/wanderer-industries/wanderer/compare/v1.0.23...v1.1.0) (2024-09-29)
@@ -22,60 +40,37 @@
## [v1.0.22](https://github.com/wanderer-industries/wanderer/compare/v1.0.21...v1.0.22) (2024-09-25)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.21](https://github.com/wanderer-industries/wanderer/compare/v1.0.20...v1.0.21) (2024-09-24)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.20](https://github.com/wanderer-industries/wanderer/compare/v1.0.19...v1.0.20) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* core: Small fixes & improvements
## [v1.0.19](https://github.com/wanderer-industries/wanderer/compare/v1.0.18...v1.0.19) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* ACL: Fix adding empty members list
## [v1.0.18](https://github.com/wanderer-industries/wanderer/compare/v1.0.17...v1.0.18) (2024-09-22)
### Bug Fixes:
### Bug Fixes
* ACL: Cant delete ACL list after map deletion #5
## [v1.0.17](https://github.com/wanderer-industries/wanderer/compare/v1.0.16...v1.0.17) (2024-09-21)
## [v1.0.16](https://github.com/wanderer-industries/wanderer/compare/v1.0.15...v1.0.16) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* Map: commented console log
@@ -85,103 +80,58 @@
## [v1.0.15](https://github.com/wanderer-industries/wanderer/compare/v1.0.14...v1.0.15) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* map: Show a proper user notification if map was deleted/archived
## [v1.0.14](https://github.com/wanderer-industries/wanderer/compare/v1.0.13...v1.0.14) (2024-09-21)
## [v1.0.13](https://github.com/wanderer-industries/wanderer/compare/v1.0.12...v1.0.13) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* tracking: Ensure user has at least one character tracked to work with map
## [v1.0.12](https://github.com/wanderer-industries/wanderer/compare/v1.0.11...v1.0.12) (2024-09-20)
### Bug Fixes:
### Bug Fixes
* audit: Hide character for non-character map activities
## [v1.0.11](https://github.com/wanderer-industries/wanderer/compare/v1.0.10...v1.0.11) (2024-09-20)
## [v1.0.10](https://github.com/wanderer-industries/wanderer/compare/v1.0.9...v1.0.10) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* signatures: Fix update signatures error if no character tracked on map
## [v1.0.9](https://github.com/wanderer-industries/wanderer/compare/v1.0.8...v1.0.9) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* core: Fix system add error if it's already added on map
## [v1.0.8](https://github.com/wanderer-industries/wanderer/compare/v1.0.7...v1.0.8) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* docker: Fix DB connection in docker-compose internal network
## [v1.0.7](https://github.com/wanderer-industries/wanderer/compare/v1.0.6...v1.0.7) (2024-09-19)
## [v1.0.6](https://github.com/wanderer-industries/wanderer/compare/v1.0.5...v1.0.6) (2024-09-18)
## [v1.0.5](https://github.com/wanderer-industries/wanderer/compare/v1.0.4...v1.0.5) (2024-09-18)
## [v1.0.4](https://github.com/wanderer-industries/wanderer/compare/v1.0.3...v1.0.4) (2024-09-18)
### Bug Fixes:
### Bug Fixes
* core: skip search results for failed character info request
## [v1.0.3](https://github.com/wanderer-industries/wanderer/compare/v1.0.2...v1.0.3) (2024-09-18)
## [v1.0.2](https://github.com/wanderer-industries/wanderer/compare/v1.0.1...v1.0.2) (2024-09-18)
## [v1.0.1](https://github.com/wanderer-industries/wanderer/compare/v1.0.0...v1.0.1) (2024-09-18)

View File

@@ -8,17 +8,21 @@ import { getSystemById } from '@/hooks/Mapper/helpers';
import { useWaypointMenu } from '@/hooks/Mapper/components/contexts/hooks';
import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts';
import { FastSystemActions } from '@/hooks/Mapper/components/contexts/components';
import { useJumpPlannerMenu } from '@/hooks/Mapper/components/contexts/hooks/useJumpPlannerMenu';
import { Route } from '@/hooks/Mapper/types/routes.ts';
export interface ContextMenuSystemInfoProps {
systemStatics: Map<number, SolarSystemStaticInfoRaw>;
hubs: string[];
contextMenuRef: RefObject<ContextMenu>;
systemId: string | undefined;
systemIdFrom?: string | undefined;
systems: SolarSystemRawType[];
onOpenSettings(): void;
onHubToggle(): void;
onAddSystem(): void;
onWaypointSet: WaypointSetContextHandler;
routes: Route[];
}
export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
@@ -30,9 +34,12 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
onAddSystem,
onWaypointSet,
systemId,
systemIdFrom,
hubs,
routes,
}) => {
const getWaypointMenu = useWaypointMenu(onWaypointSet);
const getJumpPlannerMenu = useJumpPlannerMenu(systems, systemIdFrom);
const items: MenuItem[] = useMemo(() => {
const system = systemId ? systemStatics.get(parseInt(systemId)) : undefined;
@@ -55,7 +62,9 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
);
},
},
{ separator: true },
...getJumpPlannerMenu(system, routes),
...getWaypointMenu(systemId, system.system_class),
{
label: !hubs.includes(systemId) ? 'Add in Routes' : 'Remove from Routes',
@@ -72,7 +81,17 @@ export const ContextMenuSystemInfo: React.FC<ContextMenuSystemInfoProps> = ({
]
: []),
];
}, [systemId, systemStatics, systems, getWaypointMenu, hubs, onHubToggle, onAddSystem, onOpenSettings]);
}, [
systemId,
systemStatics,
systems,
getJumpPlannerMenu,
getWaypointMenu,
hubs,
onHubToggle,
onAddSystem,
onOpenSettings,
]);
return (
<>

View File

@@ -4,6 +4,7 @@ import { Commands, MapHandlers, OutCommand, OutCommandHandler } from '@/hooks/Ma
import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts';
import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts';
import * as React from 'react';
import { SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types';
interface UseContextMenuSystemHandlersProps {
hubs: string[];
@@ -15,16 +16,21 @@ export const useContextMenuSystemInfoHandlers = ({ hubs, outCommand, mapRef }: U
const contextMenuRef = useRef<ContextMenu | null>(null);
const [system, setSystem] = useState<string>();
const routeRef = useRef<(SolarSystemStaticInfoRaw | undefined)[]>([]);
const ref = useRef({ hubs, system, outCommand, mapRef });
ref.current = { hubs, system, outCommand, mapRef };
const open = useCallback((ev: React.SyntheticEvent, systemId: string) => {
setSystem(systemId);
ev.preventDefault();
ctxManager.next('ctxSysInfo', contextMenuRef.current);
contextMenuRef.current?.show(ev);
}, []);
const open = useCallback(
(ev: React.SyntheticEvent, systemId: string, route: (SolarSystemStaticInfoRaw | undefined)[]) => {
setSystem(systemId);
routeRef.current = route;
ev.preventDefault();
ctxManager.next('ctxSysInfo', contextMenuRef.current);
contextMenuRef.current?.show(ev);
},
[],
);
const onHubToggle = useCallback(() => {
const { hubs, system, outCommand } = ref.current;

View File

@@ -0,0 +1 @@
export * from './useJumpPlannerMenu.tsx';

View File

@@ -0,0 +1,129 @@
import { MenuItem } from 'primereact/menuitem';
import { PrimeIcons } from 'primereact/api';
import { useCallback } from 'react';
import { isPossibleSpace } from '@/hooks/Mapper/components/map/helpers/isKnownSpace.ts';
import { Route } from '@/hooks/Mapper/types/routes.ts';
import { SolarSystemRawType, SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types';
import { getSystemById } from '@/hooks/Mapper/helpers';
import { SOLAR_SYSTEM_CLASS_IDS } from '@/hooks/Mapper/components/map/constants.ts';
const imperialSpace = [SOLAR_SYSTEM_CLASS_IDS.hs, SOLAR_SYSTEM_CLASS_IDS.ls, SOLAR_SYSTEM_CLASS_IDS.ns];
const criminalSpace = [SOLAR_SYSTEM_CLASS_IDS.ls, SOLAR_SYSTEM_CLASS_IDS.ns];
enum JUMP_SHIP_TYPE {
BLACK_OPS = 'Marshal',
JUMP_FREIGHTER = 'Anshar',
RORQUAL = 'Rorqual',
CAPITAL = 'Thanatos',
SUPER_CAPITAL = 'Avatar',
}
export const openJumpPlan = (jumpShipType: JUMP_SHIP_TYPE, from: string, to: string) => {
return window.open(`https://evemaps.dotlan.net/jump/${jumpShipType},544/${from}:${to}`, '_blank');
};
const BRACKET_ICONS = {
npcsuperCarrier_32: '/icons/brackets/npcsuperCarrier_32.png',
carrier_32: '/icons/brackets/carrier_32.png',
battleship_32: '/icons/brackets/battleship_32.png',
freighter_32: '/icons/brackets/freighter_32.png',
};
const renderIcon = (icon: string) => {
return (
<div className="flex justify-center items-center mr-1.5 pt-px">
<img src={icon} style={{ width: 20, height: 20 }} />
</div>
);
};
export const useJumpPlannerMenu = (
systems: SolarSystemRawType[],
systemIdFrom?: string | undefined,
): ((systemId: SolarSystemStaticInfoRaw, routes: Route[]) => MenuItem[]) => {
return useCallback(
(destination: SolarSystemStaticInfoRaw) => {
if (!destination || !systemIdFrom) {
return [];
}
const origin = getSystemById(systems, systemIdFrom)?.system_static_info;
if (!origin) {
return [];
}
const isShowBOorJumpFreighter =
isPossibleSpace(imperialSpace, origin.system_class) && isPossibleSpace(criminalSpace, destination.system_class);
const isShowCapital =
isPossibleSpace(criminalSpace, origin.system_class) && isPossibleSpace(criminalSpace, destination.system_class);
if (!isShowBOorJumpFreighter && !isShowCapital) {
return [];
}
return [
{
label: 'In Jump Planner',
icon: PrimeIcons.SEND,
items: [
...(isShowBOorJumpFreighter
? [
{
label: 'Black Ops',
icon: renderIcon(BRACKET_ICONS.battleship_32),
command: () => {
openJumpPlan(JUMP_SHIP_TYPE.BLACK_OPS, origin.solar_system_name, destination.solar_system_name);
},
},
{
label: 'Jump Freighter',
icon: renderIcon(BRACKET_ICONS.freighter_32),
command: () => {
openJumpPlan(
JUMP_SHIP_TYPE.JUMP_FREIGHTER,
origin.solar_system_name,
destination.solar_system_name,
);
},
},
{
label: 'Rorqual',
icon: renderIcon(BRACKET_ICONS.freighter_32),
command: () => {
openJumpPlan(JUMP_SHIP_TYPE.RORQUAL, origin.solar_system_name, destination.solar_system_name);
},
},
]
: []),
...(isShowCapital
? [
{
label: 'Capital',
icon: renderIcon(BRACKET_ICONS.carrier_32),
command: () => {
openJumpPlan(JUMP_SHIP_TYPE.CAPITAL, origin.solar_system_name, destination.solar_system_name);
},
},
{
label: 'Super Capital',
icon: renderIcon(BRACKET_ICONS.npcsuperCarrier_32),
command: () => {
openJumpPlan(
JUMP_SHIP_TYPE.SUPER_CAPITAL,
origin.solar_system_name,
destination.solar_system_name,
);
},
},
]
: []),
],
},
];
},
[systems, systemIdFrom],
);
};

View File

@@ -11,3 +11,7 @@ export const isKnownSpace = (wormholeClassID: number) => {
return false;
};
export const isPossibleSpace = (spaces: number[], wormholeClassID: number) => {
return spaces.includes(wormholeClassID);
};

View File

@@ -54,7 +54,7 @@ export const RoutesWidgetContent = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hubs, systems, systemStatics, lastUpdateKey]);
const preparedRoutes = useMemo(() => {
const preparedRoutes: Route[] = useMemo(() => {
return (
routes?.routes
.sort(sortByDist)
@@ -71,15 +71,17 @@ export const RoutesWidgetContent = () => {
);
}, [routes?.routes, routes?.systems_static_data, systemId]);
const refData = useRef({ open, loadSystems });
refData.current = { open, loadSystems };
const refData = useRef({ open, loadSystems, preparedRoutes });
refData.current = { open, loadSystems, preparedRoutes };
useEffect(() => {
(async () => await refData.current.loadSystems(hubs))();
}, [hubs]);
const handleClick = useCallback((e: MouseEvent, systemId: string) => {
refData.current.open(e, systemId);
const route = refData.current.preparedRoutes.find(x => x.destination.toString() === systemId);
refData.current.open(e, systemId, route?.mapped_systems ?? []);
}, []);
const handleContextMenu = useCallback(
@@ -146,7 +148,14 @@ export const RoutesWidgetContent = () => {
</div>
)}
<ContextMenuSystemInfo hubs={hubs} systems={systems} systemStatics={systemStatics} {...systemCtxProps} />
<ContextMenuSystemInfo
hubs={hubs}
routes={preparedRoutes}
systems={systems}
systemStatics={systemStatics}
systemIdFrom={systemId}
{...systemCtxProps}
/>
</>
);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

View File

@@ -43,7 +43,6 @@ defmodule WandererApp.Api.AccessList do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
change manage_relationship(:owner_id, :owner, on_lookup: :relate, on_no_match: nil)
end
@@ -51,8 +50,6 @@ defmodule WandererApp.Api.AccessList do
update :update do
accept [:name, :description, :owner_id]
primary?(true)
argument :owner_id_text_input, :string, allow_nil?: true
end
update :assign_owner do

View File

@@ -63,7 +63,6 @@ defmodule WandererApp.Api.Map do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
argument :create_default_acl, :boolean, allow_nil?: true
argument :acls, {:array, :uuid}, allow_nil?: true
argument :acls_text_input, :string, allow_nil?: true

View File

@@ -602,11 +602,11 @@ defmodule WandererAppWeb.CoreComponents do
<tr
:for={row <- @rows}
id={@row_id && @row_id.(row)}
phx-click={@row_click && @row_click.(row)}
class={"hover #{if @row_selected && @row_selected.(row), do: "!bg-slate-600", else: ""} #{if @row_click, do: "cursor-pointer", else: ""}"}
>
<td
:for={{col, _index} <- Enum.with_index(@col)}
phx-click={@row_click && @row_click.(row)}
>
<%= render_slot(col, @row_item.(row)) %>
</td>

View File

@@ -99,40 +99,34 @@ defmodule WandererAppWeb.AccessListsLive do
end
defp apply_action(socket, :add_members, %{"id" => acl_id} = _params) do
{:ok, %{owner: %{id: _character_id}} = access_list} =
socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner)
with {:ok, %{owner: %{id: _character_id}} = access_list} <- socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner),
user_character_ids <- socket.assigns.current_user.characters |> Enum.map(& &1.id) do
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
user_character_ids = socket.assigns.current_user.characters |> Enum.map(& &1.id)
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
end
@impl true
def handle_event("set-default", %{"id" => id}, socket) do
send_update(LiveSelect.Component, options: socket.assigns.characters, id: id)
{:noreply, socket}
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
else
_ ->
socket
end
end
@impl true

View File

@@ -127,23 +127,13 @@
<.form :let={f} for={@form} phx-change="validate" phx-submit={@live_action}>
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
dropdown_extra_class="max-h-64"
available_option_class="w-full"
value_mapper={&map_character/1}
update_min_len={0}
phx-focus="set-default"
options={@characters}
placeholder="Owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<div class="modal-action">
<.button class="mt-2" type="submit" phx-disable-with="Saving...">
<%= (@live_action == :create && "Create") || "Save" %>

View File

@@ -167,24 +167,6 @@ defmodule WandererAppWeb.MapsLive do
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",
%{"id" => "form_owner_id_live_select_component" = id, "text" => text} = _change_event,
socket
) do
options =
if text == "" do
socket.assigns.characters
else
socket.assigns.characters
end
send_update(LiveSelect.Component, options: options, id: id)
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",

View File

@@ -137,23 +137,17 @@
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="text" field={f[:slug]} prefix={@uri} placeholder="map-slug" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
value_mapper={&map_character/1}
options={@characters}
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<.input
type="select"
field={f[:scope]}
class="p-dropdown p-component p-inputwrapper"
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map scope"
options={Enum.map(@scopes, fn scope -> {scope, scope} end)}
/>

View File

@@ -2,7 +2,7 @@ defmodule WandererApp.MixProject do
use Mix.Project
@source_url "https://github.com/wanderer-industries/wanderer"
@version "1.1.0"
@version "1.2.1"
def project do
[