mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
[MIRROR] quick import follow up (#11589)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9ee7d17071
commit
b5dda088a5
@@ -73,6 +73,7 @@ export const downloadPrefs = (extension: string) => {
|
||||
const exportPayload = {
|
||||
[mob_name]: {
|
||||
version: db_version,
|
||||
repo: db_repo,
|
||||
bellies: validBellies,
|
||||
soulcatcher: soulcatcher,
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'tgui-core/components';
|
||||
import { createSearch } from 'tgui-core/string';
|
||||
import { getCurrentTimestamp } from '../../VorePanelExport/VorePanelExportTimestamp';
|
||||
import { CURRENT_VERSION } from '../constants';
|
||||
import { CURRENT_VERSION, UNKNOWN_ORIGIN } from '../constants';
|
||||
import { importLengthToColor } from '../function';
|
||||
import type { DesiredData } from '../types';
|
||||
|
||||
@@ -22,6 +22,7 @@ export const CharacterSelector = (props: {
|
||||
onSelectedCharacters: React.Dispatch<React.SetStateAction<Set<string>>>;
|
||||
importLength: number;
|
||||
selectedVersions: string[];
|
||||
selectedOrigins: string[];
|
||||
}) => {
|
||||
const {
|
||||
characterData,
|
||||
@@ -30,6 +31,7 @@ export const CharacterSelector = (props: {
|
||||
onSelectedCharacters,
|
||||
importLength,
|
||||
selectedVersions,
|
||||
selectedOrigins,
|
||||
} = props;
|
||||
|
||||
const [searchText, setSearchText] = useState('');
|
||||
@@ -104,7 +106,11 @@ export const CharacterSelector = (props: {
|
||||
scrollable
|
||||
title="Characters"
|
||||
buttons={
|
||||
<Button disabled={!selectedCharacters.size} onClick={handleMerge}>
|
||||
<Button
|
||||
disabled={!selectedCharacters.size}
|
||||
onClick={handleMerge}
|
||||
tooltip="Migrate saves or merge multiple characters."
|
||||
>
|
||||
Merge/Migrate
|
||||
</Button>
|
||||
}
|
||||
@@ -184,6 +190,19 @@ export const CharacterSelector = (props: {
|
||||
</Fragment>
|
||||
))}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Origins">
|
||||
{selectedOrigins.map((origin, index) => (
|
||||
<Fragment key={origin}>
|
||||
<Box
|
||||
inline
|
||||
color={origin === UNKNOWN_ORIGIN ? 'red' : undefined}
|
||||
>
|
||||
{origin}
|
||||
</Box>
|
||||
{index < selectedVersions.length - 1 && ', '}
|
||||
</Fragment>
|
||||
))}
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export const CURRENT_VERSION = 0.3;
|
||||
|
||||
export const UNKNOWN_ORIGIN = 'unknown';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UNKNOWN_ORIGIN } from './constants';
|
||||
import type { DesiredData, ImportData } from './types';
|
||||
|
||||
export function importLengthToColor(importLength: number): string {
|
||||
@@ -21,6 +22,7 @@ export function handleImportData(importString: string | string[]): DesiredData {
|
||||
bellies: Array.isArray(parsedData) ? parsedData : [],
|
||||
soulcatcher: undefined,
|
||||
version: '0.1',
|
||||
repo: UNKNOWN_ORIGIN,
|
||||
},
|
||||
};
|
||||
return ourBellies;
|
||||
@@ -34,6 +36,7 @@ export function handleImportData(importString: string | string[]): DesiredData {
|
||||
? parsedData.soulcatcher
|
||||
: {},
|
||||
version: '0.2',
|
||||
repo: UNKNOWN_ORIGIN,
|
||||
},
|
||||
};
|
||||
return ourBellies;
|
||||
@@ -50,6 +53,7 @@ export function handleImportData(importString: string | string[]): DesiredData {
|
||||
? ourData.soulcatcher
|
||||
: {},
|
||||
version: ourData.version,
|
||||
repo: ourData.repo,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
@@ -59,6 +63,7 @@ export function handleImportData(importString: string | string[]): DesiredData {
|
||||
bellies: {},
|
||||
soulcatcher: {},
|
||||
version: '0.3',
|
||||
repo: UNKNOWN_ORIGIN,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export const VorePanelImport = () => {
|
||||
const [activeTab, setActiveTab] = useState('');
|
||||
const [currentLength, setCurrentLength] = useState(0);
|
||||
const [selectedVersions, setSelectedVersions] = useState<string[]>([]);
|
||||
const [selectedOrigins, setSelectedOrigins] = useState<string[]>([]);
|
||||
|
||||
const filteredData = Object.fromEntries(
|
||||
Array.from(selectedCharacters).map((name) => [name, characterData[name]]),
|
||||
@@ -52,7 +53,15 @@ export const VorePanelImport = () => {
|
||||
),
|
||||
);
|
||||
|
||||
const allOrigins = Array.from(
|
||||
new Set(
|
||||
Object.values(filteredData)
|
||||
.map((dataEntry) => dataEntry.repo)
|
||||
.filter((v): v is string => typeof v === 'string'),
|
||||
),
|
||||
);
|
||||
setSelectedVersions(allVersions);
|
||||
setSelectedOrigins(allOrigins);
|
||||
}, [filteredData]);
|
||||
|
||||
function handleTabChange(newTab: string) {
|
||||
@@ -82,6 +91,7 @@ export const VorePanelImport = () => {
|
||||
onSelectedCharacters={setSelectedCharacters}
|
||||
importLength={currentLength}
|
||||
selectedVersions={selectedVersions}
|
||||
selectedOrigins={selectedOrigins}
|
||||
/>
|
||||
</Stack.Item>
|
||||
<Stack.Item>
|
||||
|
||||
@@ -6,5 +6,6 @@ export type DesiredData = Record<
|
||||
bellies: Record<string, string | number | null>[];
|
||||
soulcatcher?: Record<string, string | number | null>;
|
||||
version?: string;
|
||||
repo?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user