Copilot commented on code in PR #14225:
URL: https://github.com/apache/cloudstack/pull/14225#discussion_r4075012079
##########
ui/src/components/header/ProjectMenu.vue:
##########
@@ -43,19 +45,29 @@ export default {
data () {
return {
selectedProjectId: null,
- loading: false,
+ availableProjects: [],
timestamp: new Date().getTime()
}
},
created () {
- this.selectedProjectId = this.$store.getters?.project?.id ||
this.defaultOption.id
+ this.listUserAvailableProjects()
+ this.selectedProjectId = this.$store.getters?.project?.id ||
this.defaultOption?.id
Review Comment:
When `defaultOption` is `null`, `this.defaultOption?.id` evaluates to
`undefined`, so `selectedProjectId` can become `undefined` even though the rest
of the component appears to use `null` to represent 'no selection'. It would be
more consistent to normalize to `null` (e.g., via `?? null`) to avoid subtle
watcher/comparison issues.
##########
ui/src/components/header/ProjectMenu.vue:
##########
@@ -91,6 +104,18 @@ export default {
if (this.$route.name !== 'dashboard') {
this.$router.push({ name: 'dashboard' })
}
+ },
+ listUserAvailableProjects () {
+ getAPI('listProjects', { details: 'min', listall: true })
+ .then((response) => {
+ this.availableProjects = response.listprojectsresponse?.project || []
+ if (this.shouldHideDefaultView && !this.$store.getters.project?.id) {
+ this.selectedProjectId = null
+ }
+ })
Review Comment:
This introduces an additional `listProjects` call on component creation and
every `projects-updated` event, while `InfiniteScrollSelect` will also fetch
projects to populate the dropdown. This can double API traffic and slow down
navigation. A more efficient approach would be to derive `availableProjects`
(or at least whether any projects exist) from the same fetch used by the select
(e.g., via an emitted 'loaded options' event), or to reuse the select’s
response instead of issuing a second request.
##########
server/src/main/java/com/cloud/user/AccountManager.java:
##########
@@ -192,6 +192,8 @@ void buildACLViewSearchCriteria(SearchCriteria<? extends
ControlledViewEntity> s
ConfigKey<Boolean> UseSecretKeyInResponse = new
ConfigKey<Boolean>("Advanced", Boolean.class, "use.secret.key.in.response",
"false",
"This parameter allows the users to enable or disable of showing
secret key as a part of response for various APIs. By default it is set to
false.", true);
+ ConfigKey<Boolean> DisableDefaultView = new ConfigKey<>("Advanced",
Boolean.class, "disable.default.view", "false", "This defines if the account
will have access to the default view, or only to the projects it is associated
to. In the GUI, if the account does not have access to any project, the Default
View will be rendered.", true, ConfigKey.Scope.Account);
Review Comment:
The PR description/table lists the setting name as `disable.account.view`,
but the implementation (and earlier description text) uses
`disable.default.view`. Please align the PR description to the implemented
config key to avoid confusion for operators/users.
##########
ui/src/components/widgets/InfiniteScrollSelect.vue:
##########
@@ -332,8 +350,7 @@ export default {
if (firstOption) {
const firstValue = firstOption[this.optionValueKey]
this.hasAutoSelectedFirst = true
- this.$emit('change-option-value', firstValue)
- this.$emit('change-option', firstOption)
+ this.onChange(firstValue)
}
Review Comment:
`autoSelectFirstOptionIfNeeded()` previously emitted selection events
directly, but now routes through `onChange()`, which also calls
`resetPreselectedOptionValue()` and emits `update:value`. This is a behavior
change that can break preselection flows (auto-select now clears preselection
state and triggers v-model updates). Consider splitting event emission from
preselection-reset logic (e.g., a dedicated internal emit helper), or add a
parameter to `onChange` to skip preselected reset during auto-selection.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]