-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Summary screen by adding more details about applied resources #912
Changes from all commits
af531d4
635beac
5cc4d38
29d9c81
120d285
49bbf9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ public ConfigurationUnitResultViewModel(ISetupFlowStringResource stringResource, | |
_unitResult = unitResult; | ||
} | ||
|
||
public string Title => _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummary, _unitResult.Intent, _unitResult.UnitName); | ||
public string Title => BuildTitle(); | ||
|
||
public string ApplyResult => GetApplyResult(); | ||
|
||
|
@@ -54,4 +54,24 @@ private string GetApplyResult() | |
|
||
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSuccess); | ||
} | ||
|
||
private string BuildTitle() | ||
{ | ||
if (string.IsNullOrEmpty(_unitResult.Id) && string.IsNullOrEmpty(_unitResult.Description)) | ||
{ | ||
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryMinimal, _unitResult.Intent, _unitResult.UnitName); | ||
} | ||
|
||
if (string.IsNullOrEmpty(_unitResult.Id)) | ||
{ | ||
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoId, _unitResult.Intent, _unitResult.UnitName, _unitResult.Description); | ||
} | ||
|
||
if (string.IsNullOrEmpty(_unitResult.Description)) | ||
{ | ||
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoDescription, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id); | ||
} | ||
|
||
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryFull, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.Description); | ||
Comment on lines
+60
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: It bothers me a bit to have all the repetition of var resourceKey = StringResourceKey.ConfigurationUnitSummaryFull;
if (condition1) resourceKey = [another string]
else if (condition2) resourceKey = [another string]
return _stringResource.GetLocalized(resourceKey, _unitResult.Intent, _unitResult.UnitName, ...); Though this may be abusing the GetLocalized function since it may not be intended to get more replacements than placeholders there are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a corner case that break the simplicity of this solution: if the unit ID is missing the description should be the thrid param. Because of this the resulting code looks worse (even assuming the repetition of private string BuildTitle()
{
var missingId = string.IsNullOrEmpty(_unitResult.Id);
var missingDescription = string.IsNullOrEmpty(_unitResult.Description);
var summaryResourceKey = StringResourceKey.ConfigurationUnitSummaryFull;
object[] localizedParams = { _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.Description };
if (missingId && missingDescription)
{
summaryResourceKey = StringResourceKey.ConfigurationUnitSummaryMinimal;
}
else if (missingId)
{
summaryResourceKey = StringResourceKey.ConfigurationUnitSummaryNoId;
// for this variant of the string template the description is the thrid param
localizedParams[2] = _unitResult.Description;
}
else if (missingDescription)
{
summaryResourceKey = StringResourceKey.ConfigurationUnitSummaryNoDescription;
}
return _stringResource.GetLocalized(summaryResourceKey, localizedParams);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This may be a Bad Idea® but... This could probably be avoided by having that string skip the replacement Anyways, what I'm suggesting would be adding complexity in the strings to get some simplicity here, so it may not be worth it. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all of these variants to be localized? I'm a bit concerned that we may have more combinations we want to be able to handle and that's going to grow too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed the current style because I have no much context on why we are using a localized string for this, but folks, if you want I'm good with removing this strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember getting guidance specifically about this. When I've added strings like these to localization it is because I'm not sure if other locales would use the same characters.
For example, I know for quotes some languages use 「these」 and some others use „these“. Not sure if that applies in this case, particularly considering the audience here is developers.
If we're keeping your current formatting, I think it's okay to localize these. IIRC my comment was thinking of adding the components to the string one by one always in the same order, instead of the current formatting where things change places depending on which ones are available.