-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Added support for logging in/out of GitHub (#14085)
- Loading branch information
Showing
9 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using System.Windows.Input; | ||
|
||
namespace Files.App.ViewModels.Settings | ||
{ | ||
public class GitViewModel : ObservableObject | ||
{ | ||
protected readonly IFileTagsSettingsService FileTagsSettingsService = Ioc.Default.GetRequiredService<IFileTagsSettingsService>(); | ||
|
||
public ICommand RemoveCredentialsCommand { get; } | ||
public ICommand ConnectToGitHubCommand { get; } | ||
|
||
// Enabled when there are saved credentials | ||
private bool _IsLogoutEnabled; | ||
public bool IsLogoutEnabled | ||
{ | ||
get => _IsLogoutEnabled; | ||
set => SetProperty(ref _IsLogoutEnabled, value); | ||
} | ||
|
||
public GitViewModel() | ||
{ | ||
RemoveCredentialsCommand = new RelayCommand(DoRemoveCredentials); | ||
ConnectToGitHubCommand = new RelayCommand(DoConnectToGitHubAsync); | ||
|
||
IsLogoutEnabled = GitHelpers.GetSavedCredentials() != string.Empty; | ||
} | ||
|
||
public void DoRemoveCredentials() | ||
{ | ||
GitHelpers.RemoveSavedCredentials(); | ||
IsLogoutEnabled = false; | ||
} | ||
|
||
public async void DoConnectToGitHubAsync() | ||
{ | ||
UIHelpers.CloseAllDialogs(); | ||
await GitHelpers.RequireGitAuthenticationAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. --> | ||
<Page | ||
x:Class="Files.App.Views.Settings.GitPage" | ||
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:i="using:Microsoft.Xaml.Interactivity" | ||
xmlns:icore="using:Microsoft.Xaml.Interactions.Core" | ||
xmlns:local="using:Files.App.UserControls.Settings" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:vm="using:Files.App.ViewModels.Settings" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="/ResourceDictionaries/RightAlignedToggleSwitchStyle.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
|
||
<converters:BoolNegationConverter x:Key="BoolNegationConverter" /> | ||
</ResourceDictionary> | ||
</Page.Resources> | ||
|
||
<Page.DataContext> | ||
<vm:GitViewModel x:Name="ViewModel" /> | ||
</Page.DataContext> | ||
|
||
<Grid> | ||
<StackPanel | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Spacing="4"> | ||
<StackPanel.ChildrenTransitions> | ||
<TransitionCollection> | ||
<EntranceThemeTransition /> | ||
</TransitionCollection> | ||
</StackPanel.ChildrenTransitions> | ||
|
||
<!-- Title --> | ||
<TextBlock | ||
Padding="0,0,0,12" | ||
FontSize="24" | ||
FontWeight="Medium" | ||
Text="{helpers:ResourceString Name=Git}" /> | ||
|
||
<!-- Connect to GitHub --> | ||
<local:SettingsBlockControl | ||
x:Name="ConnectToGitHubSection" | ||
Title="{helpers:ResourceString Name=ConnectToGitHub}" | ||
HorizontalAlignment="Stretch" | ||
x:Load="{x:Bind ViewModel.IsLogoutEnabled, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"> | ||
<local:SettingsBlockControl.Icon> | ||
<FontIcon Glyph="" /> | ||
</local:SettingsBlockControl.Icon> | ||
<Button Command="{x:Bind ViewModel.ConnectToGitHubCommand}" Content="{helpers:ResourceString Name=Login}" /> | ||
</local:SettingsBlockControl> | ||
|
||
<!-- Remove credentials --> | ||
<local:SettingsBlockControl | ||
x:Name="RemoveCredentialsSection" | ||
Title="{helpers:ResourceString Name=ConnectedToGitHub}" | ||
HorizontalAlignment="Stretch" | ||
x:Load="{x:Bind ViewModel.IsLogoutEnabled, Mode=OneWay}"> | ||
<local:SettingsBlockControl.Icon> | ||
<FontIcon Glyph="" /> | ||
</local:SettingsBlockControl.Icon> | ||
<Button Command="{x:Bind ViewModel.RemoveCredentialsCommand}" Content="{helpers:ResourceString Name=Logout}" /> | ||
</local:SettingsBlockControl> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Files.App.Views.Settings | ||
{ | ||
public sealed partial class GitPage : Page | ||
{ | ||
public GitPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters