mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:39:48 +00:00
Implemented move feature inside the workspace component
This commit is contained in:
parent
bf83c1830b
commit
ce8f50ee66
@ -16,11 +16,16 @@
|
|||||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||||
<MudText Style="justify-self: start;">@treeItem.Text</MudText>
|
<MudText Style="justify-self: start;">@treeItem.Text</MudText>
|
||||||
<div style="justify-self: end;">
|
<div style="justify-self: end;">
|
||||||
<MudTooltip Text="Rename" Placement="Placement.Right">
|
|
||||||
|
<MudTooltip Text="Move to workspace" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.MoveToInbox" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.MoveChat(treeItem.Path)"/>
|
||||||
|
</MudTooltip>
|
||||||
|
|
||||||
|
<MudTooltip Text="Rename" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameChat(treeItem.Path)"/>
|
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameChat(treeItem.Path)"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
|
|
||||||
<MudTooltip Text="Delete" Placement="Placement.Right">
|
<MudTooltip Text="Delete" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteChat(treeItem.Path)"/>
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteChat(treeItem.Path)"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
</div>
|
</div>
|
||||||
@ -35,11 +40,11 @@
|
|||||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||||
<MudText Style="justify-self: start;">@treeItem.Text</MudText>
|
<MudText Style="justify-self: start;">@treeItem.Text</MudText>
|
||||||
<div style="justify-self: end;">
|
<div style="justify-self: end;">
|
||||||
<MudTooltip Text="Rename" Placement="Placement.Right">
|
<MudTooltip Text="Rename" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameWorkspace(treeItem.Path)"/>
|
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.RenameWorkspace(treeItem.Path)"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
|
|
||||||
<MudTooltip Text="Delete" Placement="Placement.Right">
|
<MudTooltip Text="Delete" Placement="@WORKSPACE_ITEM_TOOLTIP_PLACEMENT">
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteWorkspace(treeItem.Path)"/>
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" Color="Color.Inherit" OnClick="() => this.DeleteWorkspace(treeItem.Path)"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,6 +26,8 @@ public partial class Workspaces : ComponentBase
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<ChatThread> CurrentChatThreadChanged { get; set; }
|
public EventCallback<ChatThread> CurrentChatThreadChanged { get; set; }
|
||||||
|
|
||||||
|
private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
@ -165,7 +167,7 @@ public partial class Workspaces : ComponentBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaces.Add(new TreeButton(WorkspaceBranch.WORKSPACES, 1, "Add workspace",Icons.Material.Filled.Add, this.AddWorkspace));
|
workspaces.Add(new TreeButton(WorkspaceBranch.WORKSPACES, 1, "Add workspace",Icons.Material.Filled.LibraryAdd, this.AddWorkspace));
|
||||||
return workspaces;
|
return workspaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +194,7 @@ public partial class Workspaces : ComponentBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceChats.Add(new TreeButton(WorkspaceBranch.WORKSPACES, 2, "Add chat",Icons.Material.Filled.Add, () => this.AddChat(workspacePath)));
|
workspaceChats.Add(new TreeButton(WorkspaceBranch.WORKSPACES, 2, "Add chat",Icons.Material.Filled.AddComment, () => this.AddChat(workspacePath)));
|
||||||
return workspaceChats;
|
return workspaceChats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +303,7 @@ public partial class Workspaces : ComponentBase
|
|||||||
{ "Message", $"Please enter a new or edit the name for your chat '{chat.Name}':" },
|
{ "Message", $"Please enter a new or edit the name for your chat '{chat.Name}':" },
|
||||||
{ "UserInput", chat.Name },
|
{ "UserInput", chat.Name },
|
||||||
{ "ConfirmText", "Rename" },
|
{ "ConfirmText", "Rename" },
|
||||||
|
{ "ConfirmColor", Color.Info },
|
||||||
};
|
};
|
||||||
|
|
||||||
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Rename Chat", dialogParameters, DialogOptions.FULLSCREEN);
|
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Rename Chat", dialogParameters, DialogOptions.FULLSCREEN);
|
||||||
@ -325,6 +328,7 @@ public partial class Workspaces : ComponentBase
|
|||||||
{ "Message", $"Please enter a new or edit the name for your workspace '{workspaceName}':" },
|
{ "Message", $"Please enter a new or edit the name for your workspace '{workspaceName}':" },
|
||||||
{ "UserInput", workspaceName },
|
{ "UserInput", workspaceName },
|
||||||
{ "ConfirmText", "Rename" },
|
{ "ConfirmText", "Rename" },
|
||||||
|
{ "ConfirmColor", Color.Info },
|
||||||
};
|
};
|
||||||
|
|
||||||
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Rename Workspace", dialogParameters, DialogOptions.FULLSCREEN);
|
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Rename Workspace", dialogParameters, DialogOptions.FULLSCREEN);
|
||||||
@ -345,6 +349,7 @@ public partial class Workspaces : ComponentBase
|
|||||||
{ "Message", "Please name your workspace:" },
|
{ "Message", "Please name your workspace:" },
|
||||||
{ "UserInput", string.Empty },
|
{ "UserInput", string.Empty },
|
||||||
{ "ConfirmText", "Add workspace" },
|
{ "ConfirmText", "Add workspace" },
|
||||||
|
{ "ConfirmColor", Color.Info },
|
||||||
};
|
};
|
||||||
|
|
||||||
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Add Workspace", dialogParameters, DialogOptions.FULLSCREEN);
|
var dialogReference = await this.DialogService.ShowAsync<SingleInputDialog>("Add Workspace", dialogParameters, DialogOptions.FULLSCREEN);
|
||||||
@ -387,6 +392,53 @@ public partial class Workspaces : ComponentBase
|
|||||||
await this.LoadTreeItems();
|
await this.LoadTreeItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task MoveChat(string? chatPath)
|
||||||
|
{
|
||||||
|
var chat = await this.LoadChat(chatPath, false);
|
||||||
|
if (chat is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var dialogParameters = new DialogParameters
|
||||||
|
{
|
||||||
|
{ "Message", "Please select the workspace where you want to move the chat to." },
|
||||||
|
{ "SelectedWorkspace", chat.WorkspaceId },
|
||||||
|
{ "ConfirmText", "Move chat" },
|
||||||
|
};
|
||||||
|
|
||||||
|
var dialogReference = await this.DialogService.ShowAsync<WorkspaceSelectionDialog>("Move Chat to Workspace", dialogParameters, DialogOptions.FULLSCREEN);
|
||||||
|
var dialogResult = await dialogReference.Result;
|
||||||
|
if (dialogResult.Canceled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var workspaceId = dialogResult.Data is Guid id ? id : default;
|
||||||
|
if (workspaceId == Guid.Empty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Delete the chat from the current workspace or the temporary storage:
|
||||||
|
if (chat.WorkspaceId == Guid.Empty)
|
||||||
|
{
|
||||||
|
// Case: The chat is stored in the temporary storage:
|
||||||
|
await this.DeleteChat(Path.Join(SettingsManager.DataDirectory, "tempChats", chat.ChatId.ToString()), askForConfirmation: false, unloadChat: false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Case: The chat is stored in a workspace.
|
||||||
|
await this.DeleteChat(Path.Join(SettingsManager.DataDirectory, "workspaces", chat.WorkspaceId.ToString(), chat.ChatId.ToString()), askForConfirmation: false, unloadChat: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the chat's workspace:
|
||||||
|
chat.WorkspaceId = workspaceId;
|
||||||
|
|
||||||
|
// Handle the case, where the chat is the active chat:
|
||||||
|
if (this.CurrentChatThread?.ChatId == chat.ChatId)
|
||||||
|
{
|
||||||
|
this.CurrentChatThread = chat;
|
||||||
|
await this.CurrentChatThreadChanged.InvokeAsync(this.CurrentChatThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.StoreChat(chat);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task AddChat(string workspacePath)
|
private async Task AddChat(string workspacePath)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user