Skip to content
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

Feature: Added tooltips to Git columns in the details layout #12676

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions src/Files.App/Data/Models/GitItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ internal class GitItemModel
/// Gets or initializes file change kind
/// </summary>
/// <remarks>
/// This is often showed as A(Add), D(Delete), M(Modified), U(Untracked) in VS Code.
/// This is often showed as A(Added), D(Deleted), M(Modified), U(Untracked) in VS Code.
/// </remarks>
public ChangeKind Status { get; init; }

/// <summary>
/// Gets or initializes file change kind humanized string
/// Gets or initializes file change kind symbol
/// </summary>
/// <remarks>
/// This is often showed as A(Add), D(Delete), M(Modified), U(Untracked) in VS Code.
/// This is often showed as A(Added), D(Deleted), M(Modified), U(Untracked) in VS Code.
/// </remarks>
public string? StatusSymbol { get; init; }

/// <summary>
/// Gets or initializes file change kind humanized string
/// </summary>
public string? StatusHumanized { get; init; }

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,13 @@ await SafetyExtensions.IgnoreExceptions(() =>
return dispatcherQueue.EnqueueOrInvokeAsync(() =>
{
var gitItem = item.AsGitItem;
gitItem.UnmergedGitStatusLabel = gitItemModel.StatusHumanized;
gitItem.UnmergedGitStatusLabel = gitItemModel.StatusSymbol;
gitItem.UnmergedGitStatusName = gitItemModel.StatusHumanized;
gitItem.GitLastCommitDate = gitItemModel.LastCommit?.Author.When;
gitItem.GitLastCommitMessage = gitItemModel.LastCommit?.MessageShort;
gitItem.GitLastCommitAuthor = gitItemModel.LastCommit?.Author.Name;
gitItem.GitLastCommitSha = gitItemModel.LastCommit?.Sha.Substring(0, 7);
gitItem.GitLastCommitFullSha = gitItemModel.LastCommit?.Sha;

repo.Dispose();
},
Expand Down
14 changes: 14 additions & 0 deletions src/Files.App/Filesystem/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ public string? UnmergedGitStatusLabel
set => SetProperty(ref _UnmergedGitStatusLabel, value);
}

private string? _UnmergedGitStatusName;
public string? UnmergedGitStatusName
{
get => _UnmergedGitStatusName;
set => SetProperty(ref _UnmergedGitStatusName, value);
}

public SolidColorBrush UnmergedGitStatusLabelForeground { get; init; }

private DateTimeOffset? _GitLastCommitDate;
Expand Down Expand Up @@ -678,5 +685,12 @@ public string? GitLastCommitSha
get => _GitLastCommitSha;
set => SetProperty(ref _GitLastCommitSha, value);
}

private string? _GitLastCommitFullSha;
public string? GitLastCommitFullSha
{
get => _GitLastCommitFullSha;
set => SetProperty(ref _GitLastCommitFullSha, value);
}
}
}
20 changes: 17 additions & 3 deletions src/Files.App/Helpers/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,22 +308,36 @@ public static GitItemModel GetGitInformationForItem(Repository repository, strin
}
}

string? changeKindHumanized = "";
string? changeKindSymbol = null;
if (changeKind is not ChangeKind.Ignored)
{
changeKindHumanized = changeKind switch
changeKindSymbol = changeKind switch
{
ChangeKind.Added => "A",
ChangeKind.Deleted => "D",
ChangeKind.Modified => "M",
ChangeKind.Untracked => "U",
_ => "",
_ => null,
};
}

string? changeKindHumanized = null;
if (changeKind is not ChangeKind.Ignored)
{
changeKindHumanized = changeKind switch
{
ChangeKind.Added => "Added".GetLocalizedResource(),
ChangeKind.Deleted => "Deleted".GetLocalizedResource(),
ChangeKind.Modified => "Modified".GetLocalizedResource(),
ChangeKind.Untracked => "Untracked".GetLocalizedResource(),
_ => null,
};
}

var gitItemModel = new GitItemModel()
{
Status = changeKind,
StatusSymbol = changeKindSymbol,
StatusHumanized = changeKindHumanized,
LastCommit = commit,
Path = relativePath,
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3326,4 +3326,16 @@
<data name="OpenInVSCodeDescription" xml:space="preserve">
<value>Open the current directory in Visual Studio Code</value>
</data>
<data name="Added" xml:space="preserve">
<value>Added</value>
</data>
<data name="Deleted" xml:space="preserve">
<value>Deleted</value>
</data>
<data name="Modified" xml:space="preserve">
<value>Modified</value>
</data>
<data name="Untracked" xml:space="preserve">
<value>Untracked</value>
</data>
</root>
8 changes: 8 additions & 0 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsGitItem.UnmergedGitStatusLabel, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
ToolTipService.ToolTip="{x:Bind AsGitItem.UnmergedGitStatusName, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.GitStatusColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<!-- Item Git Last Commit Date -->
Expand All @@ -996,6 +997,8 @@
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsGitItem.GitLastCommitDateHumanized, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.GitLastCommitDateColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
Expand All @@ -1007,6 +1010,8 @@
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsGitItem.GitLastCommitMessage, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.GitLastCommitMessageColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
Expand All @@ -1018,6 +1023,8 @@
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsGitItem.GitLastCommitAuthor, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.GitCommitAuthorColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
Expand All @@ -1031,6 +1038,7 @@
VerticalAlignment="Center"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsGitItem.GitLastCommitSha, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind AsGitItem.GitLastCommitFullSha, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.GitLastCommitShaColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<!-- Tags That Item Is Labeled -->
Expand Down