mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[cmdpal] Fix empty file name issue when create new ext in "Create New Extension" command. (#38864)
Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
@@ -28,69 +29,69 @@ internal sealed partial class NewExtensionForm : NewExtensionFormBase
|
|||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_page_title}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_page_title)}},
|
||||||
"size": "large"
|
"size": "large"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_page_text}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_page_text)}},
|
||||||
"wrap": true
|
"wrap": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_name_header}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_name_header)}},
|
||||||
"weight": "bolder",
|
"weight": "bolder",
|
||||||
"size": "default"
|
"size": "default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_name_description}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_name_description)}},
|
||||||
"wrap": true
|
"wrap": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Input.Text",
|
"type": "Input.Text",
|
||||||
"label": "{{Properties.Resources.builtin_create_extension_name_label}}",
|
"label": {{FormatJsonString(Properties.Resources.builtin_create_extension_name_label)}},
|
||||||
"isRequired": true,
|
"isRequired": true,
|
||||||
"errorMessage": "{{Properties.Resources.builtin_create_extension_name_required}}",
|
"errorMessage": {{FormatJsonString(Properties.Resources.builtin_create_extension_name_required)}},
|
||||||
"id": "ExtensionName",
|
"id": "ExtensionName",
|
||||||
"placeholder": "ExtensionName",
|
"placeholder": "ExtensionName",
|
||||||
"regex": "^[^\\s]+$"
|
"regex": "^[^\\s]+$"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_display_name_header}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_display_name_header)}},
|
||||||
"weight": "bolder",
|
"weight": "bolder",
|
||||||
"size": "default"
|
"size": "default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_display_name_description}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_display_name_description)}},
|
||||||
"wrap": true
|
"wrap": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Input.Text",
|
"type": "Input.Text",
|
||||||
"label": "{{Properties.Resources.builtin_create_extension_display_name_label}}",
|
"label": {{FormatJsonString(Properties.Resources.builtin_create_extension_display_name_label)}},
|
||||||
"isRequired": true,
|
"isRequired": true,
|
||||||
"errorMessage": "{{Properties.Resources.builtin_create_extension_display_name_required}}",
|
"errorMessage": {{FormatJsonString(Properties.Resources.builtin_create_extension_display_name_required)}},
|
||||||
"id": "DisplayName",
|
"id": "DisplayName",
|
||||||
"placeholder": "My new extension"
|
"placeholder": "My new extension"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_directory_header}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_directory_header)}},
|
||||||
"weight": "bolder",
|
"weight": "bolder",
|
||||||
"size": "default"
|
"size": "default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextBlock",
|
"type": "TextBlock",
|
||||||
"text": "{{Properties.Resources.builtin_create_extension_directory_description}}",
|
"text": {{FormatJsonString(Properties.Resources.builtin_create_extension_directory_description)}},
|
||||||
"wrap": true
|
"wrap": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Input.Text",
|
"type": "Input.Text",
|
||||||
"label": "{{Properties.Resources.builtin_create_extension_directory_label}}",
|
"label": {{FormatJsonString(Properties.Resources.builtin_create_extension_directory_label)}},
|
||||||
"isRequired": true,
|
"isRequired": true,
|
||||||
"errorMessage": "{{Properties.Resources.builtin_create_extension_directory_required}}",
|
"errorMessage": {{FormatJsonString(Properties.Resources.builtin_create_extension_directory_required)}},
|
||||||
"id": "OutputPath",
|
"id": "OutputPath",
|
||||||
"placeholder": "C:\\users\\me\\dev"
|
"placeholder": "C:\\users\\me\\dev"
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,7 @@ internal sealed partial class NewExtensionForm : NewExtensionFormBase
|
|||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"type": "Action.Submit",
|
"type": "Action.Submit",
|
||||||
"title": "{{Properties.Resources.builtin_create_extension_submit}}",
|
"title": {{FormatJsonString(Properties.Resources.builtin_create_extension_submit)}},
|
||||||
"associatedInputs": "auto"
|
"associatedInputs": "auto"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -192,4 +193,10 @@ internal sealed partial class NewExtensionForm : NewExtensionFormBase
|
|||||||
// Delete the temp dir
|
// Delete the temp dir
|
||||||
Directory.Delete(tempDir, true);
|
Directory.Delete(tempDir, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FormatJsonString(string str)
|
||||||
|
{
|
||||||
|
// Escape the string for JSON
|
||||||
|
return JsonSerializer.Serialize(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user