malliaridis commented on code in PR #5257: URL: https://github.com/apache/solr/pull/5257#discussion_r4623390322
########## ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/indexquery/IndexQueryHeader.kt: ########## @@ -0,0 +1,222 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.solr.ui.views.indexquery + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExposedDropdownMenuAnchorType +import androidx.compose.material3.ExposedDropdownMenuBox +import androidx.compose.material3.ExposedDropdownMenuDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import org.apache.solr.ui.domain.RequestHandlerOption +import org.apache.solr.ui.shared.generated.resources.Res +import org.apache.solr.ui.shared.generated.resources.label_collection_core +import org.apache.solr.ui.shared.generated.resources.label_request_handler +import org.apache.solr.ui.shared.generated.resources.no_collections_available +import org.apache.solr.ui.shared.generated.resources.no_request_handlers +import org.apache.solr.ui.shared.generated.resources.placeholder_select_request_handler +import org.jetbrains.compose.resources.stringResource + +/** + * Header of the Index & Query section with a collection dropdown and a request handler dropdown. + * + * The header only renders what it is given. Loading and selection happen in the caller. + * + * @param collections The available collection names. + * @param collectionsLoading Whether the collections are being loaded. Disables both dropdowns. + * @param selectedCollection The selected collection, or null. + * @param onSelectCollection Called with the collection the user picked. + * @param handlers The request handlers of the selected collection. + * @param handlersLoading Whether the handlers are being loaded. Disables the handler dropdown. + * @param selectedHandler The name of the selected request handler, or null. + * @param onSelectHandler Called with the name of the request handler the user picked. + * @param modifier Modifier to apply to the root column. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun IndexQueryHeader( + collections: List<String>, + collectionsLoading: Boolean, + selectedCollection: String?, + onSelectCollection: (String) -> Unit, Review Comment: I am not sure if going with a data class here is the right call, especially because we will have to map entities to a less-information-holding format, loosing eventually additional metadata about the entity that may be important at some point. Sure, the entities so far are just strings. An enum would make more sense in my opinion. But lets go with this and we can still change it later if we see it is not enough. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
