mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-09 15:56:11 -04:00
Refactor accepted extensions from string to array (#1937)
This commit is contained in:
committed by
Leendert de Borst
parent
c811cc7a0e
commit
7fd7e1172b
@@ -11,7 +11,7 @@
|
||||
ServiceName="1Password"
|
||||
Description="@Localizer["OnePasswordDescription"]"
|
||||
LogoUrl="img/importers/1password.svg"
|
||||
AcceptedFileTypes=".csv,.1pux"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["OnePasswordInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["OnePasswordInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".1pux", ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -13,16 +13,14 @@
|
||||
ServiceName="AliasVault"
|
||||
Description="@Localizer["AliasVaultDescription"]"
|
||||
LogoUrl="img/logo.svg"
|
||||
AcceptedFileTypes=".csv,.avux,.avex"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["AliasVaultInstructionsPart1"]</p>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
||||
@Localizer["AliasVaultSupportedFormatsInfo"]
|
||||
</p>
|
||||
</ImportServiceCard>
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".avex", ".avux", ".csv" };
|
||||
private ImportServiceCard? importServiceCard;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Bitwarden"
|
||||
Description="@Localizer["BitwardenDescription"]"
|
||||
LogoUrl="img/importers/bitwarden.svg"
|
||||
AcceptedFileTypes=".csv,.zip"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["BitwardenInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["BitwardenInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv", ".zip" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
@ChildContent
|
||||
<p class="text-gray-600 dark:text-gray-400 text-sm mb-4">
|
||||
<strong>@Localizer["supportedFormats"]:</strong>
|
||||
@AcceptedFileTypes
|
||||
@string.Join(", ", AcceptedFileExtensions)
|
||||
</p>
|
||||
<div class="mb-4 bg-amber-50 border border-amber-400 dark:bg-amber-800/30 dark:border-amber-500/50 rounded-lg p-4">
|
||||
<p class="mb-4 text-gray-700 dark:text-gray-200">@string.Format(Localizer["UploadExportFileText"], ServiceName)</p>
|
||||
@@ -305,17 +305,17 @@
|
||||
public Func<string, byte[], Task<List<ImportedCredential>>>? ProcessFileCallback { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the accepted file types (e.g., ".csv", ".avux").
|
||||
/// Gets or sets the accepted file extensions (e.g., [".csv", ".avux"]).
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string AcceptedFileTypes { get; set; } = string.Empty;
|
||||
public string[] AcceptedFileExtensions { get; set; } = Array.Empty<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The effective accept attribute for the file input. Includes application/octet-stream as a fallback
|
||||
/// so that iOS and other mobile platforms allow selecting files with custom extensions (e.g. .avex, .avux, .1pux)
|
||||
/// that don't have a registered MIME type.
|
||||
/// </summary>
|
||||
private string FileAcceptTypes => AcceptedFileTypes + ",application/octet-stream";
|
||||
private string FileAcceptTypes => string.Join(",", AcceptedFileExtensions) + ",application/octet-stream";
|
||||
|
||||
private bool IsModalOpen { get; set; } = false;
|
||||
private bool IsImporting { get; set; } = false;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Chrome"
|
||||
Description="@Localizer["ChromeDescription"]"
|
||||
LogoUrl="img/importers/chrome.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["ChromeInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["ChromeInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Dashlane"
|
||||
Description="@Localizer["DashlaneDescription"]"
|
||||
LogoUrl="img/importers/dashlane.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["DashlaneInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["DashlaneInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Dropbox Passwords"
|
||||
Description="@Localizer["DropboxDescription"]"
|
||||
LogoUrl="img/importers/dropbox.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["DropboxInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["UploadFileInstructionCommon"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Edge"
|
||||
Description="@Localizer["EdgeDescription"]"
|
||||
LogoUrl="img/importers/edge.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["EdgeInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["EdgeInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Enpass"
|
||||
Description="@Localizer["EnpassDescription"]"
|
||||
LogoUrl="img/importers/enpass.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["EnpassInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["EnpassInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Firefox"
|
||||
Description="@Localizer["FirefoxDescription"]"
|
||||
LogoUrl="img/importers/firefox.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["FirefoxInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["FirefoxInstructionsPart2"]</p>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ServiceName="Generic CSV"
|
||||
Description="@Localizer["GenericCsvDescription"]"
|
||||
LogoUrl="img/importers/generic-csv.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["GenericCsvInstructionsPart1"]</p>
|
||||
<ol class="text-sm text-gray-700 dark:text-gray-300 space-y-2 mb-4">
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="KeePass"
|
||||
Description="@Localizer["KeePassDescription"]"
|
||||
LogoUrl="img/importers/keepass.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["KeePassInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["KeePassInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="KeePassXC"
|
||||
Description="@Localizer["KeePassXCDescription"]"
|
||||
LogoUrl="img/importers/keepassxc.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["KeePassXCInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["KeePassXCInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="LastPass"
|
||||
Description="@Localizer["LastPassDescription"]"
|
||||
LogoUrl="img/importers/lastpass.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["LastPassInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["LastPassInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="NordPass"
|
||||
Description="@Localizer["NordPassDescription"]"
|
||||
LogoUrl="img/importers/nordpass.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["NordPassInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["NordPassInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="Proton Pass"
|
||||
Description="@Localizer["ProtonPassDescription"]"
|
||||
LogoUrl="img/importers/protonpass.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["ProtonPassInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["ProtonPassInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="RoboForm"
|
||||
Description="@Localizer["RoboformDescription"]"
|
||||
LogoUrl="img/importers/roboform.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["RoboformInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["RoboformInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ServiceName="Strongbox"
|
||||
Description="@Localizer["StrongboxDescription"]"
|
||||
LogoUrl="img/importers/strongbox.svg"
|
||||
AcceptedFileTypes=".csv"
|
||||
AcceptedFileExtensions="AcceptedExtensions"
|
||||
ProcessFileCallback="ProcessFile">
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["StrongboxInstructionsPart1"]</p>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4">@Localizer["StrongboxInstructionsPart2"]</p>
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@code {
|
||||
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.ImportExport.ImportServices", "AliasVault.Client");
|
||||
private static readonly string[] AcceptedExtensions = new[] { ".csv" };
|
||||
|
||||
private static async Task<List<ImportedCredential>> ProcessFile(string filename, byte[] fileBytes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user