Skip to content

Commit

Permalink
move delete codes button
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jan 21, 2024
1 parent d825315 commit c111750
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 40 deletions.
5 changes: 1 addition & 4 deletions interface/utils/language/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,7 @@ export const localeEN = {
codesLayout: "Codes layout",
codesLayoutText: "You can choose your preferred layout. Grid displays more items and adapts to the screen size",
sortCodes: "Sort codes",
sortCodesText: "You can choose how to sort the codes. By default codes are sorted by importing order",
deleteCodes: "Delete codes",
deleteCodesText: "Delete all imported 2FA codes. Be careful, this can not be undone",
deleteCodesButton: "Delete codes",
sortCodesText: "You can choose how to sort the codes. By default codes are sorted by importing order.",
shortcuts: "Shortcuts",
shortcutsEditButton: "Edit",
shortcutsResetButton: "Reset",
Expand Down
20 changes: 0 additions & 20 deletions interface/windows/edit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,6 @@ export const saveChanges = async () => {
setSettings(settings)
}

/**
* Delete all imported codes
*/
export const deleteCodes = async () => {
const confirm0 = await dialog.ask("Are you sure you want to delete all codes? \n\nYou can not revert this!", { type: "warning" })

if (confirm0 === false) {
return
}

const confirm1 = await dialog.ask("Are you absolutely sure? \n\nThere is no way back!", { type: "warning" })

if (confirm1 === true) {
settings.vault.codes = null
setSettings(settings)

navigate("codes")
}
}

/**
* Edit a specific code
*/
Expand Down
12 changes: 11 additions & 1 deletion interface/windows/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { path, invoke, os, dialog, app, process, clipboard, window } from "@taur
import { UAParser } from "ua-parser-js"
import { navigate, open } from "../../utils/navigate"
import { deleteEncryptionKey } from "interface/utils/encryption"
import { getSettings } from "interface/stores/settings"
import { getSettings, setSettings } from "interface/stores/settings"

const settings = getSettings()

Expand Down Expand Up @@ -69,6 +69,16 @@ export const clearData = async () => {
}
}

/**
* Delete all imported codes
*/
export const deleteCodes = async () => {
settings.vault.codes = null
setSettings(settings)

navigate("codes")
}

export const showLogs = async () => {
const folderPath = await path.join(await path.cacheDir(), "com.levminer.authme", "logs")
open(folderPath)
Expand Down
31 changes: 16 additions & 15 deletions interface/windows/settings/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,6 @@
<Select options={["Default", "A-Z", "Z-A"]} setting={"sortCodes"} />
</div>
</div>

<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>{language.settings.deleteCodes}</h2>
<h3>{language.settings.deleteCodesText}</h3>
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={deleteCodes}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18" /><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" /><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" /></svg>
{language.settings.deleteCodesButton}
</button>
</div>
</div>
</div>
</div>

Expand Down Expand Up @@ -151,6 +138,20 @@
<h1 class="px-10">{language.settings.about}</h1>

<div class="mx-auto flex flex-col items-center justify-center rounded-2xl p-10">
{#if build.dev}
<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Delete codes</h2>
<h3>Delete all imported 2FA codes. Be careful, this can not be undone</h3>
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={deleteCodes}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18" /><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" /><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" /></svg>
Delete codes
</button>
</div>
</div>
{/if}
<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>{language.settings.feedback}</h2>
Expand Down Expand Up @@ -199,12 +200,12 @@
<script>
import Select from "../../components/select.svelte"
import Toggle from "../../components/toggle.svelte"
import { about, clearData, showLogs, launchOnStartup, toggleWindowCapture } from "./index"
import { about, clearData, showLogs, launchOnStartup, toggleWindowCapture, deleteCodes } from "./index"
import { settings } from "../../stores/settings"
import { open } from "../../utils/navigate"
import { deleteShortcut, editShortcut, resetShortcut, shortcuts } from "../../utils/shortcuts"
import { deleteCodes } from "../edit/index"
import { getLanguage } from "@utils/language"
import build from "../../../build.json"
const language = getLanguage()
Expand Down

0 comments on commit c111750

Please sign in to comment.