Skip to content

Commit

Permalink
Merge pull request #46659 from nextcloud/feat/migrate-backupcodes-to-…
Browse files Browse the repository at this point in the history
…ncvue

feat: migrate backupcodes personal settings buttons
  • Loading branch information
ChristophWurst authored Jul 22, 2024
2 parents 1768bd6 + 6761d78 commit 8cc9961
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
69 changes: 45 additions & 24 deletions apps/twofactor_backupcodes/src/views/PersonalSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,47 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div>
<button v-if="!enabled"
<div class="backupcodes-settings">
<NcButton v-if="!enabled"
id="generate-backup-codes"
:disabled="generatingCodes"
@click="generateBackupCodes">
<template #icon>
<NcLoadingIcon v-if="generatingCodes" />
</template>
{{ t('twofactor_backupcodes', 'Generate backup codes') }}
<span :class="{'icon-loading-small': generatingCodes}" />
</button>
</NcButton>
<template v-else>
<p>
<p class="backupcodes-settings__codes">
<template v-if="!haveCodes">
{{ t('twofactor_backupcodes', 'Backup codes have been generated. {used} of {total} codes have been used.', {used, total}) }}
</template>
<template v-else>
{{ t('twofactor_backupcodes', 'These are your backup codes. Please save and/or print them as you will not be able to read the codes again later') }}
{{ t('twofactor_backupcodes', 'These are your backup codes. Please save and/or print them as you will not be able to read the codes again later.') }}
<ul>
<li v-for="code in codes" :key="code" class="backup-code">
<li v-for="code in codes"
:key="code"
class="backupcodes-settings__codes__code">
{{ code }}
</li>
</ul>
<a :href="downloadUrl"
class="button primary"
:download="downloadFilename">{{ t('twofactor_backupcodes', 'Save backup codes') }}</a>
<button class="button"
@click="printCodes">
{{ t('twofactor_backupcodes', 'Print backup codes') }}
</button>
</template>
</p>
<p>
<button id="generate-backup-codes"
<p class="backupcodes-settings__actions">
<template v-if="haveCodes">
<NcButton :href="downloadUrl"
:download="downloadFilename"
type="primary">
{{ t('twofactor_backupcodes', 'Save backup codes') }}
</NcButton>
<NcButton @click="printCodes">
{{ t('twofactor_backupcodes', 'Print backup codes') }}
</NcButton>
</template>
<NcButton id="generate-backup-codes"
@click="generateBackupCodes">
{{ t('twofactor_backupcodes', 'Regenerate backup codes') }}
</button>
</NcButton>
</p>
<p>
<em>
Expand All @@ -50,11 +57,17 @@
<script>
import { confirmPassword } from '@nextcloud/password-confirmation'
import { print } from '../service/PrintService.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'

import '@nextcloud/password-confirmation/dist/style.css'

export default {
name: 'PersonalSettings',
components: {
NcButton,
NcLoadingIcon,
},
data() {
return {
generatingCodes: false,
Expand Down Expand Up @@ -124,13 +137,21 @@ export default {
}
</script>

<style scoped>
.backup-code {
font-family: monospace;
letter-spacing: 0.02em;
font-size: 1.2em;
<style lang="scss" scoped>
.backupcodes-settings {
&__codes {
&__code {
font-family: monospace;
letter-spacing: 0.02em;
font-size: 1.2em;
}
}
.button {
display: inline-block;

&__actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--default-grid-baseline);
}
}
</style>
4 changes: 2 additions & 2 deletions dist/twofactor_backupcodes-settings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8cc9961

Please sign in to comment.