-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3140 from microsoft/main
Staging - 6/5/24
- Loading branch information
Showing
34 changed files
with
1,029 additions
and
467 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,38 @@ | ||
trigger: | ||
- release | ||
|
||
steps: | ||
- script: echo Triggering ADO Build | ||
displayName: 'Triggering ADO Build' | ||
resources: | ||
repositories: | ||
- repository: templates_onebranch | ||
type: git | ||
name: OneBranch.Pipelines/GovernedTemplates | ||
ref: refs/heads/main | ||
- repository: m365Pipelines | ||
type: git | ||
name: 1ESPipelineTemplates/M365GPT | ||
ref: refs/tags/release | ||
|
||
extends: | ||
template: v1/M365.Official.PipelineTemplate.yml@m365Pipelines | ||
parameters: | ||
sdl: | ||
roslyn: | ||
enabled: true | ||
arrow: | ||
serviceConnection: DevHome Build VM Generation | ||
baseline: | ||
baselineFile: $(Build.SourcesDirectory)\guardian\SDL\.gdnbaselines | ||
pool: | ||
name: Azure-Pipelines-1ESPT-ExDShared | ||
image: windows-2022 | ||
os: windows | ||
customBuildTags: | ||
- ES365AIMigrationTooling | ||
stages: | ||
- stage: Trigger_Build | ||
dependsOn: [] | ||
jobs: | ||
- job: Trigger_Build | ||
steps: | ||
- script: echo Triggering ADO Build | ||
displayName: 'Triggering ADO Build' |
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 |
---|---|---|
@@ -1,6 +1,38 @@ | ||
trigger: | ||
- staging | ||
|
||
steps: | ||
- script: echo Triggering ADO Build | ||
displayName: 'Triggering ADO Build' | ||
resources: | ||
repositories: | ||
- repository: templates_onebranch | ||
type: git | ||
name: OneBranch.Pipelines/GovernedTemplates | ||
ref: refs/heads/main | ||
- repository: m365Pipelines | ||
type: git | ||
name: 1ESPipelineTemplates/M365GPT | ||
ref: refs/tags/release | ||
|
||
extends: | ||
template: v1/M365.Official.PipelineTemplate.yml@m365Pipelines | ||
parameters: | ||
sdl: | ||
roslyn: | ||
enabled: true | ||
arrow: | ||
serviceConnection: DevHome Build VM Generation | ||
baseline: | ||
baselineFile: $(Build.SourcesDirectory)\guardian\SDL\.gdnbaselines | ||
pool: | ||
name: Azure-Pipelines-1ESPT-ExDShared | ||
image: windows-2022 | ||
os: windows | ||
customBuildTags: | ||
- ES365AIMigrationTooling | ||
stages: | ||
- stage: Trigger_Build | ||
dependsOn: [] | ||
jobs: | ||
- job: Trigger_Build | ||
steps: | ||
- script: echo Triggering ADO Build | ||
displayName: 'Triggering ADO Build' |
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,170 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using AdaptiveCards.ObjectModel.WinUI3; | ||
using AdaptiveCards.Rendering.WinUI3; | ||
using DevHome.Common.Extensions; | ||
using DevHome.Common.Services; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Windows.Data.Json; | ||
using Windows.Storage.Pickers; | ||
using WinRT.Interop; | ||
using WinUIEx; | ||
|
||
namespace DevHome.Common.Renderers; | ||
|
||
public class ChooseFileAction : IAdaptiveActionElement | ||
{ | ||
// ChooseFile properties | ||
public string FilePath { get; set; } = string.Empty; | ||
|
||
public string Verb { get; set; } = string.Empty; | ||
|
||
public bool UseIcon { get; set; } | ||
|
||
public static readonly string CustomTypeString = "Action.ChooseFile"; | ||
|
||
// Inherited properties | ||
public ActionType ActionType => ActionType.Custom; | ||
|
||
public string ActionTypeString => CustomTypeString; | ||
|
||
public JsonObject? AdditionalProperties { get; set; } | ||
|
||
public IAdaptiveActionElement? FallbackContent { get; set; } | ||
|
||
public FallbackType FallbackType { get; set; } = FallbackType.Drop; | ||
|
||
public string IconUrl { get; set; } = string.Empty; | ||
|
||
public string? Id { get; set; } = CustomTypeString + "Id"; | ||
|
||
public bool IsEnabled { get; set; } = true; | ||
|
||
public AdaptiveCards.ObjectModel.WinUI3.ActionMode Mode { get; set; } | ||
|
||
public ActionRole Role { get; set; } | ||
|
||
public string Style { get; set; } = string.Empty; | ||
|
||
public string Title { get; set; } = string.Empty; | ||
|
||
public string Tooltip { get; set; } = string.Empty; | ||
|
||
public JsonObject ToJson() | ||
{ | ||
var json = new JsonObject | ||
{ | ||
["type"] = JsonValue.CreateStringValue(ActionTypeString), | ||
["filePath"] = JsonValue.CreateStringValue(FilePath), | ||
["verb"] = JsonValue.CreateStringValue(Verb), | ||
}; | ||
|
||
if (AdditionalProperties != null) | ||
{ | ||
foreach (var prop in AdditionalProperties) | ||
{ | ||
json.Add(prop.Key, prop.Value); | ||
} | ||
} | ||
|
||
return json; | ||
} | ||
|
||
/// <summary>Launches the file picker dialog to select a file.</summary> | ||
/// <returns>true if a file was selected, false otherwise.</returns> | ||
public bool LaunchFilePicker() | ||
{ | ||
var filePicker = new FileOpenPicker(); | ||
filePicker.FileTypeFilter.Add("*"); | ||
|
||
var mainWindow = Application.Current.GetService<Window>(); | ||
if (mainWindow != null) | ||
{ | ||
var hwnd = WindowNative.GetWindowHandle(mainWindow); | ||
InitializeWithWindow.Initialize(filePicker, hwnd); | ||
} | ||
|
||
var file = filePicker.PickSingleFileAsync().AsTask().Result; | ||
if (file != null) | ||
{ | ||
FilePath = file.Path; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
public class ChooseFileParser : IAdaptiveActionParser | ||
{ | ||
public IAdaptiveActionElement FromJson( | ||
JsonObject inputJson, | ||
AdaptiveElementParserRegistration elementParsers, | ||
AdaptiveActionParserRegistration actionParsers, | ||
IList<AdaptiveWarning> warnings) | ||
{ | ||
var stringResource = new StringResource("DevHome.Common.pri", "DevHome.Common/Resources"); | ||
|
||
var chooseFileAction = new ChooseFileAction | ||
{ | ||
Title = stringResource.GetLocalized("ChooseFileActionTitle"), | ||
Tooltip = stringResource.GetLocalized("ChooseFileActionToolTip"), | ||
|
||
// Parse the JSON properties of the action. | ||
// The Verb ChooseFile is not meant to be localized. | ||
Verb = inputJson.GetNamedString("verb", "ChooseFile"), | ||
UseIcon = inputJson.GetNamedBoolean("useIcon", false), | ||
}; | ||
|
||
return chooseFileAction; | ||
} | ||
} | ||
|
||
public class ChooseFileActionRenderer : IAdaptiveActionRenderer | ||
{ | ||
public UIElement Render(IAdaptiveActionElement element, AdaptiveRenderContext context, AdaptiveRenderArgs renderArgs) | ||
{ | ||
var renderer = new AdaptiveExecuteActionRenderer(); | ||
|
||
if (element as ChooseFileAction is ChooseFileAction chooseFileElement) | ||
{ | ||
// Card author is not allowed to specify a custom icon for the file picker action. | ||
chooseFileElement.IconUrl = string.Empty; | ||
|
||
var button = renderer.Render(element, context, renderArgs) as Button; | ||
if (button != null) | ||
{ | ||
var content = new StackPanel | ||
{ | ||
Orientation = Orientation.Horizontal, | ||
Spacing = 8, | ||
}; | ||
if (chooseFileElement.UseIcon) | ||
{ | ||
content.Children.Add(new FontIcon | ||
{ | ||
Glyph = "\xED25", | ||
}); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(chooseFileElement.Title)) | ||
{ | ||
content.Children.Add(new TextBlock | ||
{ | ||
Text = chooseFileElement.Title, | ||
}); | ||
} | ||
|
||
button.Content = content; | ||
|
||
return button; | ||
} | ||
} | ||
|
||
return renderer.Render(element, context, renderArgs); | ||
} | ||
} |
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,51 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Linq; | ||
using AdaptiveCards.ObjectModel.WinUI3; | ||
using AdaptiveCards.Rendering.WinUI3; | ||
using CommunityToolkit.WinUI; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Automation; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace DevHome.Common.Renderers; | ||
|
||
public class TextInputRenderer : IAdaptiveElementRenderer | ||
{ | ||
public UIElement Render(IAdaptiveCardElement element, AdaptiveRenderContext context, AdaptiveRenderArgs renderArgs) | ||
{ | ||
var renderer = new AdaptiveTextInputRenderer(); | ||
var elementToReturn = renderer.Render(element, context, renderArgs); | ||
|
||
if (element as AdaptiveTextInput is AdaptiveTextInput textInputElement) | ||
{ | ||
if (textInputElement.InlineAction == null) | ||
{ | ||
return elementToReturn; | ||
} | ||
|
||
if (textInputElement.InlineAction is not ChooseFileAction) | ||
{ | ||
return elementToReturn; | ||
} | ||
|
||
// If the Input has an inline action, the element will have a button as a descendant. | ||
// Since guidance suggests inline actions use an icon rather than text, we can safely | ||
// set the content of the button to an icon. | ||
foreach (var descendant in elementToReturn.FindDescendants()) | ||
{ | ||
if (descendant is Button inlineActionButton) | ||
{ | ||
inlineActionButton.Padding = new Thickness(5); | ||
inlineActionButton.Content = new FontIcon | ||
{ | ||
Glyph = "\xED25", | ||
}; | ||
} | ||
} | ||
} | ||
|
||
return elementToReturn; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -48,4 +48,6 @@ public enum WidgetAction | |
Save, | ||
|
||
Cancel, | ||
|
||
ChooseFile, | ||
} |
Oops, something went wrong.