diff --git a/backend/common/profile/manager.go b/backend/common/profile/manager.go index a0dad0a..d987e25 100644 --- a/backend/common/profile/manager.go +++ b/backend/common/profile/manager.go @@ -51,6 +51,10 @@ func (pm *ProfileManager) SaveProfile(gameTitle, profileName string, prof Profil return SaveManifest(gameTitle, profileName, prof) } +func (pm *ProfileManager) DeleteProfile(gameTitle, profileName string) error { + return DeleteManifest(gameTitle, profileName) +} + func PathToProfilesDir(gameTitle string) string { cacheDir, _ := os.UserConfigDir() path := filepath.Join(cacheDir, "modm8", "Games", gameTitle, "Profiles") @@ -94,6 +98,10 @@ func SaveManifest(gameTitle, profileName string, prof ProfileManifest) error { return backend.SaveFile(PathToProfile(gameTitle, profileName), data) } +func DeleteManifest(gameTitle, profileName string) error { + return os.Remove(PathToProfile(gameTitle, profileName)) +} + func GetManifest(gameTitle, profileName string) (*ProfileManifest, error) { contents, err := backend.ReadFile(PathToProfile(gameTitle, profileName)) if err != nil { diff --git a/frontend/src/components/selected-game/ProfileManager.vue b/frontend/src/components/selected-game/ProfileManager.vue index ae32330..29ee15c 100644 --- a/frontend/src/components/selected-game/ProfileManager.vue +++ b/frontend/src/components/selected-game/ProfileManager.vue @@ -4,7 +4,7 @@ import Listbox, { ListboxChangeEvent } from 'primevue/listbox' import InputGroup from 'primevue/inputgroup' import Popover from 'primevue/popover' -import { NewProfile } from '@backend/profile/ProfileManager' +import { NewProfile, DeleteProfile } from '@backend/profile/ProfileManager' import { tooltipOpts } from '@frontend/src/util' import { t } from '@i18n' @@ -37,11 +37,11 @@ const onChange = (e: ListboxChangeEvent) => { emit('profileSelected', e) } -const toggleProfilePopover = (e: MouseEvent) => { +const togglePopover = (e: MouseEvent) => { pp?.value.show(e) } -const createProfile = async (e: MouseEvent) => { +const createNewProf = async (e: MouseEvent) => { await NewProfile(selectedGame.value.title, newProfNameInput.value!) await initProfiles() @@ -50,6 +50,17 @@ const createProfile = async (e: MouseEvent) => { emit('profileCreated', e) } +const renameProf = (_: MouseEvent, name: string) => { + +} + +const deleteProf = async (e: MouseEvent, name: string) => { + e.stopPropagation() + + await DeleteProfile(selectedGame.value.title, name) + await initProfiles() +} + const shouldDisableCreation = () => { if (newProfNameInput.value.length < 1) return true // No input yet @@ -86,7 +97,7 @@ onMounted(async () => { @@ -97,7 +108,7 @@ onMounted(async () => { @@ -141,12 +152,12 @@ onMounted(async () => { renameProf(e, profile.name)" /> e.stopPropagation()" + @click="e => deleteProf(e, profile.name)" />