Skip to content

Remove default selection on console logs page#1119

Merged
tlmii merged 3 commits intomicrosoft:mainfrom
tlmii:dev/no-initial-selection-on-console-logs
Nov 30, 2023
Merged

Remove default selection on console logs page#1119
tlmii merged 3 commits intomicrosoft:mainfrom
tlmii:dev/no-initial-selection-on-console-logs

Conversation

@tlmii
Copy link
Copy Markdown
Member

@tlmii tlmii commented Nov 29, 2023

Resolves #1055

  • Change the binding for the FluentSelect to be a list of Option<string> instead of directly using ResourceViewModel
  • Insert a default (Select a resource) entry in the list (see first screenshot)
  • If you hit the page directly (either by typing in the /ConsoleLogs url or using the menu, logs won't start automatically and you'll get the view in the second screenshot below
  • If there is no selection and a new resource shows up, we do not automatically select it
  • Switching between log sources is the same as before this change
  • Changed all statuses to sentence casing per UX board suggestion

Screenshots:
image
image

<h1>Console Logs</h1>
<FluentToolbar Orientation="Orientation.Horizontal">
<FluentSelect @ref="_resourceSelectComponent" TOption="ResourceViewModel"
<FluentSelect @ref="_resourceSelectComponent" TOption="Option<string>"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll allow us to add icons easily too if we decide to do so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long has Option<T> been in FluentUI? I added our own version - SelectViewModel<T> - because I never noticed it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why does Option<T> have Text and Value properties both of T? Surely Text should always be a string...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long has Option<T> been in FluentUI? I added our own version - SelectViewModel<T> - because I never noticed it.

It's been there since August I guess. I only really noticed it when I looked into how to add icons and it looks like using Option<T> is the only way to do so:

https://github.com/microsoft/fluentui-blazor/blob/41bc71d065f0cd7f0006345cc5a6be101e1dff17/src/Core/Components/List/ListComponentBase.cs#L418C25-L437C26

Hmm, why does Option<T> have Text and Value properties both of T? Surely Text should always be a string...

Yeah I don't know, it seems off. Seems like Value should be T and Text should be string. But there's no special handling for Option<T> (other than Icon) so you still have to use the OptionText and OptionValue parameters to set the display text and value.

private CancellationTokenSource? _watchLogsTokenSource;
private string _status = LogStatus.Initializing;

private readonly TaskCompletionSource _renderCompleted = new();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just append TaskCompletionSource or something. The name looks like a bool otherwise.

Comment thread src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs Outdated
private CancellationTokenSource? _watchLogsTokenSource;
private string _status = LogStatus.Initializing;

private readonly TaskCompletionSource _renderCompletedTaskCompletionSource = new();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The usual suffix (at least in aspnetcore code) is tcs

Suggested change
private readonly TaskCompletionSource _renderCompletedTaskCompletionSource = new();
private readonly TaskCompletionSource _renderCompletedTcs = new();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are really inconsistent at this. e.g. _watchContainersTokenSource (now why it uses containers lol). 🙃

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskCompletionSource = tcs
CancelationTokenSource = cts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and renamed _watchContainersTokenSource too.

now why it uses containers lol

Naming things is hard to do. Renaming things is hard to remember to do.

@tlmii tlmii enabled auto-merge (squash) November 30, 2023 05:35
@tlmii tlmii merged commit 375577a into microsoft:main Nov 30, 2023
andrevlins pushed a commit to andrevlins/aspire that referenced this pull request Dec 3, 2023
* Remove default selection on console logs page

* PR Feedback

* More PR Feedback
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't start watching console logs if an existing resource isn't selected

3 participants