Skip to content

Commit

Permalink
Move password show/hide button to password input
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed Jun 10, 2024
1 parent 111c901 commit 28311aa
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions frontend/src/lib/components/modals/ServerManager.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { mdiAlert, mdiLoading, mdiServerNetwork, mdiTrashCan } from '@mdi/js';
import { mdiAlert, mdiEyeOffOutline, mdiEyeOutline, mdiLoading, mdiServerNetwork, mdiTrashCan } from '@mdi/js';
import { getTranslate } from '@tolgee/svelte';
import _ from 'lodash';
Expand Down Expand Up @@ -163,10 +163,6 @@
placement: 'bottom',
} as PopupSettings]).reduce((acc, [k, v]) => ({ ...acc, [k as string]: v as PopupSettings }), {} as Record<string, PopupSettings>);
function toggleMaskPassword() {
maskPassword = !maskPassword;
}
function redactRemoteURL(path: string) {
return path.replace(/(?<=.+:\/\/)(?:(.+?)(?::.*?)?)?(?=@)/, '$1:********');
}
Expand Down Expand Up @@ -274,20 +270,25 @@
placeholder={$t('server-manager.username-placeholder', 'username')}
type="text"
bind:value={newServerUsername}/>
<!-- This is a conditional because the type var cant be dynamic with bind:value -->
{#if maskPassword}
<input
class="input px-4 h-full"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="password"
bind:value={newServerPassword}/>
{:else}
<input
class="input px-4 h-full"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="text"
bind:value={newServerPassword}/>
{/if}
<div class="input-group h-full grid-cols-[1fr_auto]">
<!-- This is a conditional because svelte doesn't allow dynamic type with bind:value -->
{#if maskPassword}
<input
class="px-4 h-full !outline-none"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="password"
bind:value={newServerPassword}/>
{:else}
<input
class="px-4 h-full !outline-none"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="text"
bind:value={newServerPassword}/>
{/if}
<button class="!outline-none" on:click={() => maskPassword = !maskPassword}>
<SvgIcon class="!w-4 !h-4" icon={maskPassword ? mdiEyeOutline : mdiEyeOffOutline} />
</button>
</div>
<input
class="input px-4 h-full sm:col-start-2"
placeholder={$t('server-manager.host-placeholder', 'host')}
Expand Down Expand Up @@ -354,17 +355,6 @@
class="h-5 w-5"
icon={mdiServerNetwork} />
</button>
<button
class="btn h-full text-sm bg-primary-600 text-secondary-900 col-start-2 sm:col-start-4 row-start-3"
on:click={() => toggleMaskPassword()}>
<span>
{#if maskPassword}
<T defaultValue="Show Password" keyName="server-manager.show-password" />
{:else}
<T defaultValue="Hide Password" keyName="server-manager.hide-password" />
{/if}
</span>
</button>
</div>
<p>{err}</p>
</section>
Expand Down

0 comments on commit 28311aa

Please sign in to comment.