mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
fix(Map): Update wormhole lifetime UI and removed unnecessary code
This commit is contained in:
@@ -15,3 +15,14 @@
|
|||||||
.SelectedItem {
|
.SelectedItem {
|
||||||
background-color: var(--selected-item-bg);
|
background-color: var(--selected-item-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.FastActions {
|
||||||
|
:global {
|
||||||
|
.p-menuitem-content {
|
||||||
|
background-color: initial !important;
|
||||||
|
}
|
||||||
|
.p-menuitem-content:hover {
|
||||||
|
background-color: initial !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import {
|
|||||||
SHIP_SIZES_SIZE,
|
SHIP_SIZES_SIZE,
|
||||||
} from '@/hooks/Mapper/components/map/constants.ts';
|
} from '@/hooks/Mapper/components/map/constants.ts';
|
||||||
import { Edge } from 'reactflow';
|
import { Edge } from 'reactflow';
|
||||||
|
import { LifetimeActions } from '@/hooks/Mapper/components/map/components/ContextMenuConnection/LifetimeActions.tsx';
|
||||||
|
|
||||||
export interface ContextMenuConnectionProps {
|
export interface ContextMenuConnectionProps {
|
||||||
contextMenuRef: RefObject<ContextMenu>;
|
contextMenuRef: RefObject<ContextMenu>;
|
||||||
onDeleteConnection(): void;
|
onDeleteConnection(): void;
|
||||||
onChangeTimeState(): void;
|
onChangeTimeState(lifetime: TimeStatus): void;
|
||||||
onChangeMassState(state: MassState): void;
|
onChangeMassState(state: MassState): void;
|
||||||
onChangeShipSizeStatus(state: ShipSizeStatus): void;
|
onChangeShipSizeStatus(state: ShipSizeStatus): void;
|
||||||
onToggleMassSave(isLocked: boolean): void;
|
onToggleMassSave(isLocked: boolean): void;
|
||||||
@@ -48,12 +49,10 @@ export const ContextMenuConnection: React.FC<ContextMenuConnectionProps> = ({
|
|||||||
...(isWormhole
|
...(isWormhole
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: `EOL`,
|
className: clsx(classes.FastActions, '!h-[54px]'),
|
||||||
className: clsx({
|
template: () => {
|
||||||
[classes.ConnectionTimeEOL]: edge.data?.time_status === TimeStatus.eol,
|
return <LifetimeActions lifetime={edge.data?.time_status} onChangeLifetime={onChangeTimeState} />;
|
||||||
}),
|
},
|
||||||
icon: PrimeIcons.CLOCK,
|
|
||||||
command: onChangeTimeState,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: `Frigate`,
|
label: `Frigate`,
|
||||||
@@ -122,7 +121,7 @@ export const ContextMenuConnection: React.FC<ContextMenuConnectionProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ContextMenu model={items} ref={contextMenuRef} onHide={onHide} breakpoint="767px" />
|
<ContextMenu model={items} ref={contextMenuRef} onHide={onHide} breakpoint="767px" className="!w-[250px]" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { LayoutEventBlocker } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import { TimeStatus } from '@/hooks/Mapper/types';
|
||||||
|
|
||||||
|
const LIFE_TIME = [
|
||||||
|
{
|
||||||
|
id: TimeStatus._1h,
|
||||||
|
label: '1H',
|
||||||
|
className: 'bg-purple-400 hover:!bg-purple-400',
|
||||||
|
inactiveClassName: 'bg-purple-400/30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: TimeStatus._4h,
|
||||||
|
label: '4H',
|
||||||
|
className: 'bg-purple-300 hover:!bg-purple-300',
|
||||||
|
inactiveClassName: 'bg-purple-300/30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: TimeStatus._4h30m,
|
||||||
|
label: '4.5H',
|
||||||
|
className: 'bg-indigo-300 hover:!bg-indigo-300',
|
||||||
|
inactiveClassName: 'bg-indigo-300/30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: TimeStatus._8h,
|
||||||
|
label: '16H',
|
||||||
|
className: 'bg-orange-300 hover:!bg-orange-300',
|
||||||
|
inactiveClassName: 'bg-orange-400/30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: TimeStatus._16h,
|
||||||
|
label: '24H',
|
||||||
|
className: 'bg-orange-300 hover:!bg-orange-300',
|
||||||
|
inactiveClassName: 'bg-orange-400/30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: TimeStatus._24h,
|
||||||
|
label: '48H',
|
||||||
|
className: 'bg-orange-300 hover:!bg-orange-300',
|
||||||
|
inactiveClassName: 'bg-orange-400/30',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// const active = 1;
|
||||||
|
|
||||||
|
interface LifetimeActionsProps {
|
||||||
|
lifetime?: TimeStatus;
|
||||||
|
onChangeLifetime(lifetime: TimeStatus): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LifetimeActions = ({ lifetime = TimeStatus._24h, onChangeLifetime }: LifetimeActionsProps) => {
|
||||||
|
return (
|
||||||
|
<LayoutEventBlocker className="flex flex-col gap-1 w-[100%] h-full px-2 pt-[4px]">
|
||||||
|
<div className="text-[12px] text-stone-500 font-semibold">Life time:</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-[1fr_1fr_1fr_1fr_1fr_1fr] gap-1">
|
||||||
|
{LIFE_TIME.map(x => (
|
||||||
|
<Button
|
||||||
|
outlined={false}
|
||||||
|
// severity="help"
|
||||||
|
key={x.id}
|
||||||
|
value={x.label}
|
||||||
|
size="small"
|
||||||
|
className={clsx(
|
||||||
|
`py-[1px] justify-center min-w-auto w-auto border-0 text-[12px] font-bold leading-[20px]`,
|
||||||
|
{ [x.inactiveClassName]: lifetime !== x.id },
|
||||||
|
x.className,
|
||||||
|
)}
|
||||||
|
onClick={() => onChangeLifetime(x.id)}
|
||||||
|
// onClick={() => system?.tag !== x && onSystemTag(x)}
|
||||||
|
>
|
||||||
|
{x.label}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</LayoutEventBlocker>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -30,7 +30,7 @@ export const useContextMenuConnectionHandlers = () => {
|
|||||||
setEdge(undefined);
|
setEdge(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeTimeState = () => {
|
const onChangeTimeState = (lifetime: TimeStatus) => {
|
||||||
if (!edge || !edge.data) {
|
if (!edge || !edge.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ export const useContextMenuConnectionHandlers = () => {
|
|||||||
data: {
|
data: {
|
||||||
source: edge.source,
|
source: edge.source,
|
||||||
target: edge.target,
|
target: edge.target,
|
||||||
value: edge.data.time_status === TimeStatus.default ? TimeStatus.eol : TimeStatus.default,
|
value: lifetime,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setEdge(undefined);
|
setEdge(undefined);
|
||||||
|
|||||||
@@ -5,6 +5,16 @@
|
|||||||
stroke: #80a5c5;
|
stroke: #80a5c5;
|
||||||
stroke-width: 3px;
|
stroke-width: 3px;
|
||||||
|
|
||||||
|
&.time1 {
|
||||||
|
stroke: #f11ab2;
|
||||||
|
stroke-width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.time4 {
|
||||||
|
stroke: #a654e3;
|
||||||
|
stroke-width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
&.TimeCrit {
|
&.TimeCrit {
|
||||||
stroke: #f11ab2;
|
stroke: #f11ab2;
|
||||||
stroke-width: 4px;
|
stroke-width: 4px;
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }:
|
|||||||
id={`back_${id}`}
|
id={`back_${id}`}
|
||||||
className={clsx(classes.EdgePathBack, {
|
className={clsx(classes.EdgePathBack, {
|
||||||
[classes.Tick]: isThickConnections,
|
[classes.Tick]: isThickConnections,
|
||||||
[classes.TimeCrit]: isWormhole && data.time_status === TimeStatus.eol,
|
[classes.time1]: isWormhole && data.time_status === TimeStatus._1h,
|
||||||
|
[classes.time4]: isWormhole && data.time_status === TimeStatus._4h,
|
||||||
[classes.Hovered]: hovered,
|
[classes.Hovered]: hovered,
|
||||||
[classes.Gate]: !isWormhole,
|
[classes.Gate]: !isWormhole,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ import {
|
|||||||
} from '@/hooks/Mapper/components/map/constants.ts';
|
} from '@/hooks/Mapper/components/map/constants.ts';
|
||||||
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
|
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
|
||||||
import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts';
|
import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts';
|
||||||
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
|
|
||||||
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
|
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
|
import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
|
||||||
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
||||||
import { SETTINGS_KEYS, SignatureSettingsType } from '@/hooks/Mapper/constants/signatures';
|
import { SETTINGS_KEYS, SignatureSettingsType } from '@/hooks/Mapper/constants/signatures';
|
||||||
|
|
||||||
@@ -116,14 +115,14 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSelect = useCallback(
|
const handleSelect = useCallback(
|
||||||
async (signature: SystemSignature) => {
|
(signature: SystemSignature) => {
|
||||||
if (!signature) {
|
if (!signature) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { outCommand } = ref.current;
|
const { outCommand } = ref.current;
|
||||||
|
|
||||||
await outCommand({
|
outCommand({
|
||||||
type: OutCommand.linkSignatureToSystem,
|
type: OutCommand.linkSignatureToSystem,
|
||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
@@ -131,32 +130,9 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (parseSignatureCustomInfo(signature.custom_info).isEOL === true) {
|
|
||||||
await outCommand({
|
|
||||||
type: OutCommand.updateConnectionTimeStatus,
|
|
||||||
data: {
|
|
||||||
source: data.solar_system_source,
|
|
||||||
target: data.solar_system_target,
|
|
||||||
value: TimeStatus.eol,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const whShipSize = getWhSize(wormholes, signature.type);
|
|
||||||
if (whShipSize !== undefined && whShipSize !== null) {
|
|
||||||
await outCommand({
|
|
||||||
type: OutCommand.updateConnectionShipSizeType,
|
|
||||||
data: {
|
|
||||||
source: data.solar_system_source,
|
|
||||||
target: data.solar_system_target,
|
|
||||||
value: whShipSize,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
},
|
},
|
||||||
[data, setVisible, wormholes],
|
[data, setVisible],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
import { OutCommand, SignatureGroup, SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
|
import { OutCommand, SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
|
||||||
import { Controller, FormProvider, useForm } from 'react-hook-form';
|
import { Controller, FormProvider, useForm } from 'react-hook-form';
|
||||||
import {
|
import {
|
||||||
SignatureGroupContent,
|
SignatureGroupContent,
|
||||||
@@ -10,7 +10,6 @@ import { InputText } from 'primereact/inputtext';
|
|||||||
import { SystemsSettingsProvider } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/Provider.tsx';
|
import { SystemsSettingsProvider } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/Provider.tsx';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
|
|
||||||
|
|
||||||
type SystemSignaturePrepared = Omit<SystemSignature, 'linked_system'> & { linked_system: string };
|
type SystemSignaturePrepared = Omit<SystemSignature, 'linked_system'> & { linked_system: string };
|
||||||
|
|
||||||
@@ -22,10 +21,7 @@ export interface MapSettingsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SignatureSettings = ({ systemId, show, onHide, signatureData }: MapSettingsProps) => {
|
export const SignatureSettings = ({ systemId, show, onHide, signatureData }: MapSettingsProps) => {
|
||||||
const {
|
const { outCommand } = useMapRootState();
|
||||||
outCommand,
|
|
||||||
data: { wormholes },
|
|
||||||
} = useMapRootState();
|
|
||||||
|
|
||||||
const handleShow = async () => {};
|
const handleShow = async () => {};
|
||||||
const signatureForm = useForm<Partial<SystemSignaturePrepared>>({});
|
const signatureForm = useForm<Partial<SystemSignaturePrepared>>({});
|
||||||
@@ -52,32 +48,6 @@ export const SignatureSettings = ({ systemId, show, onHide, signatureData }: Map
|
|||||||
solar_system_target: values.linked_system,
|
solar_system_target: values.linked_system,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: need fix
|
|
||||||
if (values.isEOL) {
|
|
||||||
await outCommand({
|
|
||||||
type: OutCommand.updateConnectionTimeStatus,
|
|
||||||
data: {
|
|
||||||
source: systemId,
|
|
||||||
target: values.linked_system,
|
|
||||||
value: TimeStatus.eol,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values.type) {
|
|
||||||
const whShipSize = getWhSize(wormholes, values.type);
|
|
||||||
if (whShipSize !== undefined && whShipSize !== null) {
|
|
||||||
await outCommand({
|
|
||||||
type: OutCommand.updateConnectionShipSizeType,
|
|
||||||
data: {
|
|
||||||
source: systemId,
|
|
||||||
target: values.linked_system,
|
|
||||||
value: whShipSize,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out = {
|
out = {
|
||||||
@@ -153,7 +123,7 @@ export const SignatureSettings = ({ systemId, show, onHide, signatureData }: Map
|
|||||||
signatureForm.reset();
|
signatureForm.reset();
|
||||||
onHide();
|
onHide();
|
||||||
},
|
},
|
||||||
[signatureData, signatureForm, outCommand, systemId, onHide, wormholes],
|
[signatureData, signatureForm, outCommand, systemId, onHide],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -10,8 +10,14 @@ export enum MassState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum TimeStatus {
|
export enum TimeStatus {
|
||||||
default,
|
reserved, // TODO: this reserved for not broke prev solution
|
||||||
eol,
|
_1h,
|
||||||
|
_4h,
|
||||||
|
_4h30m,
|
||||||
|
_8h,
|
||||||
|
_16h,
|
||||||
|
_24h,
|
||||||
|
_48h,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ShipSizeStatus {
|
export enum ShipSizeStatus {
|
||||||
|
|||||||
Reference in New Issue
Block a user