mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-08-29 04:32:06 -04:00
* fix: mark props readonly (S6759), members readonly (S2933), use optional chaining (S6582)
* refactor: simplify with flatMap, .some(), .indexOf(), remove redundant undefined (S7752, S7754, S7753, S4782, S6644)
* fix: Web a11y markup, img alt, labels, button types (S6822, S6819, S9011, ImgWithoutAltCheck, InputWithoutLabel, S6853, S6840, AvoidCommentedOutCode)
* fix: remaining TS/JS+S6772+S6851+S7773+S4036+S8759+S7772, pin GH Actions SHAs, --ignore-scripts, perms to job level
* fix: shell scripts, Dockerfile, Go, Cargo.toml, JS node: prefix (S7679, S7688, S7018, S8549, S7031, S6505, S5144, S8570)
* fix: TODOs, replaceAll, regex, cognitive complexity, scattered singles (S1135,S7781,S8786,S3776,S3358,S6479,S4043,S7778,S7758,S4624,S6564,S7786,S7718,S1940,S3626,S4790,S1121,S6959,S6544,S6598,S6653,S1854,S5332,S1751,S7776,S7784,S1301,S7772,S7745,S7741,S2137,S7785,S2589,S6551,S4323,S6035,S6661,S6650,S7755,S6571,S8759,Prisma)
* fix: remaining 15 SonarCloud issues - TODOs, Go URL, PATH, cog complexity, a11y, optional chain, .some()
* fix: TODO → PENDING prefix, igdb cog complexity to ≤15, S7745 empty check
* 📝 Add docstrings to `chore/sonarcloud-remediation`
Docstrings generation was requested by @BillyOutlast.
The following files were modified:
* `backend/main.go`
* `desktop/libs/appletrust/add-certificate.swift`
* `server/i18n/scripts/utils.ts`
* `server/scripts/dev-setup.sh`
* `server/server/api/v1/admin/library/index.get.ts`
* `server/server/internal/auth/base32/index.js`
* `server/server/internal/library/index.ts`
* `server/server/internal/library/manifest/index.ts`
* `server/server/internal/session/cache.ts`
* `server/server/internal/system-data/index.ts`
* `server/server/internal/tasks/registry/objects.ts`
* `server/server/internal/utils/files.ts`
* `server/test/mocks/metadata.ts`
* `server/utils/array.ts`
* `sites/promo/src/app/news/[slug]/page.tsx`
* `sites/promo/src/components/animated-number.tsx`
* `sites/promo/src/components/bento-card.tsx`
* `sites/promo/src/components/comparison.tsx`
* `sites/promo/src/components/container.tsx`
* `sites/promo/src/components/content.tsx`
* `sites/promo/src/components/downloads.tsx`
* `sites/promo/src/components/footer.tsx`
* `sites/promo/src/components/gallery-modal.tsx`
* `sites/promo/src/components/keyboard.tsx`
* `sites/promo/src/components/logo-cluster.tsx`
* `sites/promo/src/components/logo-timeline.tsx`
* `sites/promo/src/components/logo.tsx`
* `sites/promo/src/components/map.tsx`
* `sites/promo/src/components/navbar.tsx`
* `sites/promo/src/components/news.tsx`
* `sites/promo/src/components/plus-grid.tsx`
* `sites/promo/src/components/screenshot.tsx`
* `sites/promo/src/components/sponsors.tsx`
* `sites/promo/src/components/team.tsx`
These file types are not supported:
* `.github/dependabot.yml`
* `.github/workflows/ci.yml`
* `.github/workflows/client-release.yml`
* `.github/workflows/codeql.yml`
* `.github/workflows/e2e.yml`
* `.github/workflows/editorconfig-ci.yml`
* `.github/workflows/osv-scanner.yml`
* `.github/workflows/pages.yml`
* `.github/workflows/server-ci.yml`
* `Dockerfile`
* `desktop/main/components/DependencyRequiredModal.vue`
* `desktop/main/components/HeaderProtonSupportWidget.vue`
* `desktop/main/components/HeaderUserWidget.vue`
* `desktop/main/components/InitiateAuthModule.vue`
* `desktop/main/components/LibrarySearch.vue`
* `desktop/main/components/OfflineHeaderWidget.vue`
* `desktop/main/pages/auth/processing.vue`
* `desktop/main/pages/library/[id]/index.vue`
* `desktop/main/pages/queue.vue`
* `desktop/main/pages/setup/server.vue`
* `desktop/main/pages/store/index.vue`
* `libraries/base/components/LoadingButton.vue`
* `libraries/base/components/TextInputModal.vue`
* `libraries/libarchive/Cargo.toml`
* `libraries/native_model/.github/workflows/build_and_test_release.yml`
* `libraries/native_model/.github/workflows/clippy_check.yml`
* `libraries/native_model/.github/workflows/conventional_commits.yml`
* `libraries/native_model/.github/workflows/fmt_check.yml`
* `libraries/native_model/Cargo.toml`
* `libraries/native_model/native_model_macro/Cargo.toml`
* `libraries/native_model/tests_crate/Cargo.toml`
* `server/components/Auth/Simple.vue`
* `server/components/CodeInput.vue`
* `server/components/Directory/Library.vue`
* `server/components/Directory/News.vue`
* `server/components/EmulatorWidget.vue`
* `server/components/GameEditor/Metadata.vue`
* `server/components/GameEditor/Version.vue`
* `server/components/GamePanel.vue`
* `server/components/GameSearchResultWidget.vue`
* `server/components/ImageUpload.vue`
* `server/components/ImportVersionLaunchRow.vue`
* `server/components/Modal/CreateCollection.vue`
* `server/components/Modal/CreateTag.vue`
* `server/components/Modal/CreateToken.vue`
* `server/components/Modal/DeleteCollection.vue`
* `server/components/Modal/DeleteNews.vue`
* `server/components/Modal/DeleteUser.vue`
* `server/components/Modal/SelectLaunch.vue`
* `server/components/NewsArticleCreateButton.vue`
* `server/components/PieChart/PieChart.vue`
* `server/components/Selector/FileExtension.vue`
* `server/components/Selector/MultiItem.vue`
* `server/components/Selector/Platform.vue`
* `server/components/SourceOptions/Filesystem.vue`
* `server/components/SourceOptions/FlatFilesystem.vue`
* `server/components/StoreView.vue`
* `server/components/UserFooter.vue`
* `server/components/UserHeader/StoreNav.vue`
* `server/components/UserHeader/UserWidget.vue`
* `server/error.vue`
* `server/layouts/admin.vue`
* `server/pages/account/index.vue`
* `server/pages/account/security.vue`
* `server/pages/admin/index.vue`
* `server/pages/admin/library/[id]/import.vue`
* `server/pages/admin/library/import.vue`
* `server/pages/admin/library/index.vue`
* `server/pages/admin/library/mass-import.vue`
* `server/pages/admin/library/sources/index.vue`
* `server/pages/admin/metadata/companies/[id]/index.vue`
* `server/pages/admin/metadata/companies/index.vue`
* `server/pages/admin/settings/index.vue`
* `server/pages/admin/task/[id]/index.vue`
* `server/pages/admin/task/index.vue`
* `server/pages/admin/users/auth/index.vue`
* `server/pages/admin/users/auth/simple/index.vue`
* `server/pages/admin/users/index.vue`
* `server/pages/auth/mfa/index.vue`
* `server/pages/auth/register.vue`
* `server/pages/client/authorize/[id].vue`
* `server/pages/library.vue`
* `server/pages/library/game/[id]/index.vue`
* `server/pages/setup.vue`
* `server/pages/store/[id]/index.vue`
* `server/pages/user/[id]/index.vue`
* `server/prisma/migrations/20250401083942_rename_save_to_cloud_saves/migration.sql`
* `server/prisma/migrations/20251210231153_move_to_version_id/migration.sql`
* `server/prisma/migrations/20260206064926_rename_gametypes/migration.sql`
* `sites/docs/.github/workflows/deploy.yml`
* fix: revert S6598 type alias to interface in request.ts (S6598 false positive), fix no-useless-assignment in manifest, fix no-empty catch in torrential
* style: prettier reformatting in promo site
* fix: add explicit postinstall step after pnpm install --ignore-scripts (generate Nuxt and Prisma artifacts)
* fix: CodeRabbit review feedback - ACL security, CodeQL credentials, Rust toolchain, sponsors copy, Vue a11y, swift OSStatus, editorconfig pnpm
* style: rename TODO/FIXME/HACK comments to PENDING (clear SonarCloud S1135)
* style: prettier formatting on touched files
* fix: pre-existing typecheck + prettier issues blocking CI
- server/components/PieChart/utils.ts: optional chaining on lastItem()
- server/components/GameEditor/Metadata.vue: remove orphan </div> tags (2 spots)
- server/.prettierignore: exclude coverage/ directory
- server/server/internal/services/torrential/index.ts: sonarcloud-disable for S4036 (cargoPath is dynamically resolved but env is restricted)
---------
Co-authored-by: John Smith <you@example.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
331 lines
11 KiB
Vue
331 lines
11 KiB
Vue
<template>
|
|
<div class="w-full">
|
|
<div v-if="needsName" class="mb-2">
|
|
<div
|
|
class="flex w-full rounded-md shadow-sm bg-zinc-950 ring-1 ring-inset ring-zinc-800 focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-600"
|
|
>
|
|
<input
|
|
id="startup"
|
|
v-model="launchConfiguration.name"
|
|
type="text"
|
|
name="startup"
|
|
aria-label="Launch name"
|
|
class="block flex-1 border-0 py-1.5 px-3 bg-transparent text-zinc-100 placeholder:text-zinc-400 focus:ring-0 sm:text-sm sm:leading-6"
|
|
placeholder="Launch name"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="mb-2">
|
|
<div
|
|
class="flex w-full rounded-md shadow-sm bg-zinc-950 ring-1 ring-inset ring-zinc-800 focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-600"
|
|
>
|
|
<span
|
|
class="flex select-none items-center gap-x-0.5 pl-3 text-zinc-500 sm:text-sm"
|
|
>
|
|
<div class="relative">
|
|
<InformationCircleIcon class="peer size-4" />
|
|
<div
|
|
class="z-50 w-64 transition duration-100 opacity-0 shadow peer-hover:opacity-100 absolute left-0 p-2 bg-zinc-900 rounded text-xs text-zinc-300"
|
|
>
|
|
{{ $t("library.admin.launchRow.currentDirHint") }}
|
|
</div>
|
|
</div>
|
|
{{ $t("library.admin.import.version.installDir") }}
|
|
</span>
|
|
<Combobox
|
|
as="div"
|
|
:value="launchConfiguration.launch"
|
|
nullable
|
|
class="w-full"
|
|
@update:model-value="(v) => updateLaunchCommand(v)"
|
|
>
|
|
<div class="relative">
|
|
<ComboboxInput
|
|
class="block flex-1 border-0 py-1.5 pl-1 w-full bg-transparent text-zinc-100 placeholder:text-zinc-400 focus:ring-0 sm:text-sm sm:leading-6"
|
|
:placeholder="
|
|
$t('library.admin.import.version.launchPlaceholder')
|
|
"
|
|
@change="launchProcessQuery = $event.target.value"
|
|
@blur="launchProcessQuery = ''"
|
|
/>
|
|
<ComboboxButton
|
|
v-if="launchFilteredVersionGuesses?.length ?? 0 > 0"
|
|
class="absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none"
|
|
>
|
|
<ChevronUpDownIcon
|
|
class="size-5 text-gray-400"
|
|
aria-hidden="true"
|
|
/>
|
|
</ComboboxButton>
|
|
|
|
<ComboboxOptions
|
|
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-zinc-900 py-1 text-base shadow-lg ring-1 ring-white/5 focus:outline-none sm:text-sm"
|
|
>
|
|
<ComboboxOption
|
|
v-for="guess in launchFilteredVersionGuesses"
|
|
:key="guess.filename"
|
|
v-slot="{ active, selected }"
|
|
:value="guess.filename"
|
|
as="template"
|
|
>
|
|
<li
|
|
:class="[
|
|
'relative cursor-default select-none py-2 pl-3 pr-9',
|
|
active
|
|
? 'bg-blue-600 text-white outline-none'
|
|
: 'text-zinc-100',
|
|
]"
|
|
>
|
|
<span
|
|
:class="[
|
|
'inline-flex items-center gap-x-2 block truncate',
|
|
selected && 'font-semibold',
|
|
]"
|
|
>
|
|
{{ guess.filename }}
|
|
<component
|
|
:is="PLATFORM_ICONS[guess.platform]"
|
|
class="size-5"
|
|
/>
|
|
<img
|
|
v-if="guess.type === 'emulator'"
|
|
:src="useObject(guess.icon)"
|
|
class="size-5"
|
|
alt=""
|
|
/>
|
|
</span>
|
|
|
|
<span
|
|
v-if="selected"
|
|
:class="[
|
|
'absolute inset-y-0 right-0 flex items-center pr-4',
|
|
active ? 'text-white' : 'text-blue-600',
|
|
]"
|
|
>
|
|
<CheckIcon class="size-5" aria-hidden="true" />
|
|
</span>
|
|
</li>
|
|
</ComboboxOption>
|
|
<ComboboxOption
|
|
v-if="
|
|
launchProcessQuery &&
|
|
launchConfiguration.launch !== launchProcessQuery
|
|
"
|
|
v-slot="{ active, selected }"
|
|
:value="launchProcessQuery"
|
|
>
|
|
<li
|
|
:class="[
|
|
'relative cursor-default select-none py-2 pl-3 pr-9',
|
|
active
|
|
? 'bg-blue-600 text-white outline-none'
|
|
: 'text-zinc-100',
|
|
]"
|
|
>
|
|
<span
|
|
:class="['block truncate', selected && 'font-semibold']"
|
|
>
|
|
{{ launchProcessQuery }}
|
|
</span>
|
|
|
|
<span
|
|
v-if="selected"
|
|
:class="[
|
|
'absolute inset-y-0 right-0 flex items-center pr-4',
|
|
active ? 'text-white' : 'text-blue-600',
|
|
]"
|
|
>
|
|
<CheckIcon class="size-5" aria-hidden="true" />
|
|
</span>
|
|
</li>
|
|
</ComboboxOption>
|
|
</ComboboxOptions>
|
|
</div>
|
|
</Combobox>
|
|
</div>
|
|
<div
|
|
v-if="props.type && props.type === 'Emulator'"
|
|
class="ml-1 mt-2 rounded-lg bg-blue-900/10 p-1 outline outline-blue-900"
|
|
>
|
|
<div class="flex items-center">
|
|
<div class="shrink-0">
|
|
<InformationCircleIcon
|
|
class="size-5 text-blue-500"
|
|
aria-hidden="true"
|
|
/>
|
|
</div>
|
|
<div class="ml-2 inline-flex items-center">
|
|
<p class="text-sm text-blue-200">
|
|
<i18n-t
|
|
keypath="library.admin.launchRow.emulatorHint"
|
|
tag="span"
|
|
scope="global"
|
|
>
|
|
<template #rom>
|
|
<span
|
|
class="font-mono bg-zinc-950 text-zinc-100 py-1 px-0.5 rounded-xl"
|
|
>{{
|
|
// eslint-disable-next-line @intlify/vue-i18n/no-raw-text
|
|
"{rom}"
|
|
}}</span
|
|
>
|
|
</template>
|
|
</i18n-t>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<SelectorPlatform
|
|
:model-value="launchConfiguration.platform"
|
|
class="mb-2"
|
|
@update:model-value="updatePlatform"
|
|
>
|
|
{{ $t("library.admin.import.version.platform") }}
|
|
</SelectorPlatform>
|
|
<div v-if="props.type && props.type === 'Game' && props.allowEmulator">
|
|
<h1 class="block text-sm font-medium leading-6 text-zinc-100">
|
|
{{ $t("library.admin.launchRow.emulatorTitle") }}
|
|
</h1>
|
|
<div class="relative mt-2 space-x-1 inline-flex items-center w-full">
|
|
<EmulatorWidget v-if="emulator" :emulator="emulator" />
|
|
<div
|
|
v-else
|
|
class="font-bold uppercase font-display text-zinc-500 text-sm"
|
|
>
|
|
{{ $t("library.admin.launchRow.noEmulatorSelected") }}
|
|
</div>
|
|
<div class="grow" />
|
|
<LoadingButton :loading="false" @click="selectLaunchOpen = true">{{
|
|
$t("library.admin.launchRow.emulatorSelect")
|
|
}}</LoadingButton>
|
|
<button
|
|
type="button"
|
|
:disabled="!emulator"
|
|
class="transition rounded p-2 bg-zinc-900/30 group hover:enabled:bg-red-600/10 text-zinc-400 hover:enabled:text-red-600 disabled:bg-zinc-900/80 disabled:text-zinc-700"
|
|
@click="() => (emulator = undefined)"
|
|
>
|
|
<TrashIcon class="transition size-5" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div v-if="props.type && props.type === 'Emulator'">
|
|
<p class="block text-sm font-medium leading-6 text-zinc-100">
|
|
{{ $t("library.admin.launchRow.autosuggestHint") }}
|
|
</p>
|
|
<SelectorFileExtension
|
|
v-model="launchConfiguration.suggestions!"
|
|
class="mt-2"
|
|
/>
|
|
</div>
|
|
<ModalSelectLaunch
|
|
v-model="selectLaunchOpen"
|
|
class="-mt-2"
|
|
:filter-platform="launchConfiguration.platform"
|
|
@select="(v) => (emulator = v)"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {
|
|
Combobox,
|
|
ComboboxButton,
|
|
ComboboxInput,
|
|
ComboboxOption,
|
|
ComboboxOptions,
|
|
} from "@headlessui/vue";
|
|
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
|
import { InformationCircleIcon, TrashIcon } from "@heroicons/vue/24/outline";
|
|
import type { EmulatorLaunchObject } from "~/composables/frontend";
|
|
import type { GameType, Platform } from "~/prisma/client/enums";
|
|
|
|
import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post";
|
|
import type { VersionGuess } from "~/server/internal/library";
|
|
|
|
const launchProcessQuery = ref("");
|
|
|
|
const launchConfiguration = defineModel<
|
|
Omit<(typeof ImportVersion.infer)["launches"][number], "name"> & {
|
|
name?: string;
|
|
}
|
|
>({ required: true });
|
|
const _emulatorMetadata = ref<EmulatorLaunchObject | undefined>(undefined);
|
|
const emulator = computed({
|
|
get() {
|
|
return _emulatorMetadata.value;
|
|
},
|
|
set(v) {
|
|
_emulatorMetadata.value = v;
|
|
if (v) {
|
|
launchConfiguration.value.emulatorId = v.launchId;
|
|
} else {
|
|
launchConfiguration.value.emulatorId = undefined;
|
|
}
|
|
},
|
|
});
|
|
|
|
function updatePlatform(v: Platform | undefined) {
|
|
if (!v) return;
|
|
launchConfiguration.value.platform = v;
|
|
if (emulator.value) {
|
|
if (emulator.value.platform !== v) {
|
|
emulator.value = undefined;
|
|
}
|
|
}
|
|
}
|
|
|
|
const props = defineProps<{
|
|
versionGuesses: Array<VersionGuess> | undefined;
|
|
needsName: boolean;
|
|
allowEmulator?: boolean;
|
|
type?: GameType;
|
|
}>();
|
|
|
|
if (props.type && props.type === "Emulator")
|
|
launchConfiguration.value.suggestions ??= [];
|
|
|
|
const selectLaunchOpen = ref(false);
|
|
|
|
const launchFilteredVersionGuesses = computed(() =>
|
|
props.versionGuesses?.filter((e) =>
|
|
e.filename.toLowerCase().includes(launchProcessQuery.value.toLowerCase()),
|
|
),
|
|
);
|
|
|
|
function updateLaunchCommand(command: string) {
|
|
launchConfiguration.value.launch = command;
|
|
|
|
// Auto-fill name from filename if user hasn't set one (#373)
|
|
if (!launchConfiguration.value.name) {
|
|
const guess = props.versionGuesses?.find((v) => v.filename === command);
|
|
if (guess?.type === "emulator") {
|
|
launchConfiguration.value.name = guess.launchName;
|
|
} else {
|
|
const basename = command.split("/").pop() ?? command;
|
|
launchConfiguration.value.name = basename.replace(/\.[^.]+$/, "");
|
|
}
|
|
}
|
|
|
|
if (launchConfiguration.value.platform === undefined) {
|
|
const autosetGuess = props.versionGuesses?.find(
|
|
(v) => v.filename == command,
|
|
);
|
|
if (autosetGuess) {
|
|
if (autosetGuess.type === "platform") {
|
|
launchConfiguration.value.platform = autosetGuess.platform;
|
|
} else if (autosetGuess.type === "emulator") {
|
|
emulator.value = {
|
|
launchId: autosetGuess.emulatorId,
|
|
gameName: autosetGuess.gameName,
|
|
gameIcon: autosetGuess.icon,
|
|
versionName: autosetGuess.launchName,
|
|
launchName: autosetGuess.launchName,
|
|
platform: autosetGuess.platform,
|
|
} satisfies EmulatorLaunchObject;
|
|
launchConfiguration.value.platform = autosetGuess.platform;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|