Skip to content

Feature: Disable warning when a new name is empty #12150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fa9e57d
Fix: Fixed NullReferenceException in `ModernShellPage` (#12135)
hishitetsu Apr 21, 2023
bdc1b68
Fix: Fixed cannot select Files in columns view (#12124)
ferrariofilippo Apr 21, 2023
47700ae
Fix: Fixed issue where the extract button on the toolbar was disabled…
hishitetsu Apr 21, 2023
9583bda
v2.4.67
yaira2 Apr 21, 2023
97e2156
Feature: Disable warning when a new name is empty
ferrariofilippo Apr 21, 2023
0003c35
Merge branch 'main' into Remove_Invalid_Warning_On_Empty
ferrariofilippo Apr 21, 2023
a8b37e2
Remove warning for empty shortcut
ferrariofilippo Apr 21, 2023
a2a227c
Remove tag warning
ferrariofilippo Apr 22, 2023
1dd1476
Merge branch 'service/2.4.67' into Remove_Invalid_Warning_On_Empty
ferrariofilippo Apr 22, 2023
22e3efc
Feature: Added Git Integration to the status bar (#12020)
ferrariofilippo Apr 19, 2023
a9af68d
Build(deps): Bump LibGit2Sharp from 0.26.2 to 0.27.2 (#12126)
dependabot[bot] Apr 20, 2023
7f4e4f5
Code Quality: Removed `async void` methods (#12128)
hishitetsu Apr 20, 2023
d621dff
Feature: Integrate Advanced Security page into properties window (#11…
0x5bfa Apr 20, 2023
3425fb9
Code Quality: Introduce Implicit Usings (#12121)
0x5bfa Apr 21, 2023
c15eb22
Build(deps): Bump Microsoft.DotNet.UpgradeAssistant.Extensions.Defaul…
dependabot[bot] Apr 21, 2023
5d119d8
Code Quality: Added license header to C# phase1 (#12143)
0x5bfa Apr 21, 2023
16ea03c
Feature: Disable warning when a new name is empty
ferrariofilippo Apr 21, 2023
c9afcd8
Remove warning for empty shortcut
ferrariofilippo Apr 21, 2023
70c04d1
Remove tag warning
ferrariofilippo Apr 22, 2023
0ab07d0
Merge branch 'Remove_Invalid_Warning_On_Empty' of https://github.com/…
ferrariofilippo Apr 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/Files.App/Dialogs/CreateArchiveDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
x:Class="Files.App.Dialogs.CreateArchiveDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:local="using:Files.App.Dialogs"
Expand All @@ -21,10 +20,6 @@
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

<ContentDialog.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
</ContentDialog.Resources>

<StackPanel Width="440" Spacing="4">

<!-- Archive Name -->
Expand Down Expand Up @@ -53,7 +48,7 @@
<TeachingTip
x:Name="InvalidNameWarning"
Title="{helpers:ResourceString Name=InvalidFilename/Text}"
IsOpen="{x:Bind ViewModel.IsNameValid, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
IsOpen="{x:Bind ViewModel.ShowNameWarning, Mode=OneWay}"
PreferredPlacement="Bottom"
Target="{x:Bind FileNameBox}" />
</TextBox.Resources>
Expand Down
11 changes: 10 additions & 1 deletion src/Files.App/Dialogs/CreateArchiveDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,20 @@ private class DialogViewModel : ObservableObject
{
public bool IsNameValid => FilesystemHelpers.IsValidForFilename(fileName);

public bool ShowNameWarning => !string.IsNullOrEmpty(fileName) && !IsNameValid;

private string fileName = string.Empty;
public string FileName
{
get => fileName;
set => SetProperty(ref fileName, value, nameof(IsNameValid));
set
{
if (SetProperty(ref fileName, value))
{
OnPropertyChanged(nameof(IsNameValid));
OnPropertyChanged(nameof(ShowNameWarning));
}
}
}

private FileFormatItem fileFormat;
Expand Down
7 changes: 1 addition & 6 deletions src/Files.App/Dialogs/CreateShortcutDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
x:Class="Files.App.Dialogs.CreateShortcutDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -16,10 +15,6 @@
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

<ContentDialog.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
</ContentDialog.Resources>

<Border Width="400">
<Grid
x:Name="DestinationPathGrid"
Expand Down Expand Up @@ -59,7 +54,7 @@
<TeachingTip
x:Name="InvalidPathWarning"
Title="{helpers:ResourceString Name=InvalidLocation}"
IsOpen="{x:Bind ViewModel.IsLocationValid, Mode=OneWay, Converter={StaticResource BoolNegationConverter}, FallbackValue=False}"
IsOpen="{x:Bind ViewModel.ShowWarningTip, Mode=OneWay}"
PreferredPlacement="Bottom" />
</TextBox.Resources>
</TextBox>
Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Helpers/DynamicDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static DynamicDialog GetFor_RenameDialog()
inputText.TextChanged += (textBox, args) =>
{
var isInputValid = FilesystemHelpers.IsValidForFilename(inputText.Text);
((RenameDialogViewModel)warning.DataContext).IsNameInvalid = !isInputValid;
((RenameDialogViewModel)warning.DataContext).IsNameInvalid = !string.IsNullOrEmpty(inputText.Text) && !isInputValid;
dialog!.ViewModel.DynamicButtonsEnabled = isInputValid
? DynamicDialogButtons.Primary | DynamicDialogButtons.Cancel
: DynamicDialogButtons.Cancel;
Expand All @@ -99,7 +99,6 @@ public static DynamicDialog GetFor_RenameDialog()
{
// dispatching to the ui thread fixes an issue where the primary dialog button would steal focus
_ = inputText.DispatcherQueue.EnqueueAsync(() => inputText.Focus(FocusState.Programmatic));
((RenameDialogViewModel)warning.DataContext).IsNameInvalid = true;
};

dialog = new DynamicDialog(new DynamicDialogViewModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public string DestinationItemPath
if (!SetProperty(ref _destinationItemPath, value))
return;

OnPropertyChanged(nameof(ShowWarningTip));
if (string.IsNullOrWhiteSpace(DestinationItemPath))
{
IsLocationValid = false;
Expand Down Expand Up @@ -60,9 +61,11 @@ public string DestinationItemPath
public bool IsLocationValid
{
get => _isLocationValid;
set => SetProperty(ref _isLocationValid, value);
set => SetProperty(ref _isLocationValid, value, nameof(ShowWarningTip));
}

public bool ShowWarningTip => !string.IsNullOrEmpty(DestinationItemPath) && !_isLocationValid;

// Command invoked when the user clicks the 'Browse' button
public ICommand SelectDestinationCommand { get; private set; }

Expand Down Expand Up @@ -105,10 +108,10 @@ private async Task CreateShortcut()
if (string.IsNullOrEmpty(destinationName))
{
var destinationPath = DestinationItemPath.Replace('/', '\\');

if (destinationPath.EndsWith('\\'))
destinationPath = destinationPath.Substring(0, destinationPath.Length - 1);

destinationName = destinationPath.Substring(destinationPath.LastIndexOf('\\') + 1);
}
}
Expand Down
19 changes: 14 additions & 5 deletions src/Files.App/ViewModels/Settings/TagsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Files.App.ViewModels.Settings
{
public class TagsViewModel : ObservableObject
{
{
private readonly IFileTagsSettingsService fileTagsSettingsService = Ioc.Default.GetRequiredService<IFileTagsSettingsService>();

private bool isBulkOperation = true;
Expand Down Expand Up @@ -108,8 +108,11 @@ public string Name
get => name;
set
{
if (SetProperty(ref name, value))
SetProperty(ref name, value);
{
OnPropertyChanged(nameof(CanCommit));
OnPropertyChanged(nameof(IsNameValid));
}
}
}

Expand All @@ -120,17 +123,23 @@ public string Color
set => SetProperty(ref color, value);
}

private bool isNameValid;
private bool isNameValid = true;
public bool IsNameValid
{
get => isNameValid;
set => SetProperty(ref isNameValid, value);
set
{
if (SetProperty(ref isNameValid, value))
OnPropertyChanged(nameof(CanCommit));
}
}

public bool CanCommit => !string.IsNullOrEmpty(name) && IsNameValid;

public void Reset()
{
Name = string.Empty;
IsNameValid = false;
IsNameValid = true;
Color = ColorHelpers.RandomColor();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Settings/TagsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<Button
Command="{x:Bind ViewModel.SaveNewTagCommand, Mode=OneWay}"
Content="{helpers:ResourceString Name=Create}"
IsEnabled="{x:Bind ViewModel.NewTag.IsNameValid, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.NewTag.CanCommit, Mode=OneWay}"
Style="{StaticResource AccentButtonStyle}" />
</StackPanel>
</Grid>
Expand Down
7 changes: 4 additions & 3 deletions src/Files.App/Views/Settings/TagsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ private void RemoveTag_Click(object sender, RoutedEventArgs e)
private void RenameTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
var text = ((TextBox)sender).Text;
editingTag!.IsNameValid = IsNameValid(text) && !ViewModel.Tags.Any(tag => tag.Tag.Name == text && editingTag!.Tag.Name != text);
editingTag!.CanCommit = editingTag!.IsNameValid && (
var isNullOrEmpty = string.IsNullOrEmpty(text);
editingTag!.IsNameValid = isNullOrEmpty || (IsNameValid(text) && !ViewModel.Tags.Any(tag => tag.Tag.Name == text && editingTag!.Tag.Name != text));
editingTag!.CanCommit = !isNullOrEmpty && editingTag!.IsNameValid && (
text != editingTag!.Tag.Name ||
editingTag!.NewColor != editingTag!.Tag.Color
);
Expand All @@ -113,7 +114,7 @@ private void NewTagTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
var text = ((TextBox)sender).Text;
ViewModel.NewTag.Name = text;
ViewModel.NewTag.IsNameValid = IsNameValid(text) && !ViewModel.Tags.Any(tag => text == tag.Tag.Name);
ViewModel.NewTag.IsNameValid = string.IsNullOrEmpty(text) || (IsNameValid(text) && !ViewModel.Tags.Any(tag => text == tag.Tag.Name));
}

private void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
Expand Down