Search in accessible deploy keys
Hello, In the latest gitlab releases, pagination was added to deploy keys. However, there is no search feature, creating issues if you want to add an existing deploy key when you have a lot of them. Before pagination, browser's search feature was good enought to find the key :smile: Suggestion: add a search field on the deploy key list. ![image](/uploads/83fe0eef8d3c61f788bfaf664df2cb9a/image.png) Thanks! ## Proposed Solution: Add a filtered search to the top of the deploy keys section: | Proposal | | ------ | | ![Screenshot_2024-04-26_at_12.35.28_PM](/uploads/a2beb3715f19345d604afa205ffaba34/Screenshot_2024-04-26_at_12.35.28_PM.png) | This filtered search would first work by searching for deploy key name OR SHA only. ![Screenshot_2024-04-26_at_10.56.25_AM](/uploads/d2a882e97b940b5bb674d29c859687aa/Screenshot_2024-04-26_at_10.56.25_AM.png) ## Technical proposal Adding proposed filtering logic requires both ~backend and ~frontend work. ### Backend The filtering of deployment keys is implemented in [DeployKeysFinder](https://gitlab.com/gitlab-org/gitlab/blob/4ea1635b98003b21011649617990738110bbb8df/app/finders/deploy_keys/deploy_keys_finder.rb) We need to add filtering for `key` and `title` fields of a [DeployKey](https://gitlab.com/gitlab-org/gitlab/blob/7e80f65a35a18bff5b74b57dd4bec3d7f4375398/app/models/deploy_key.rb) entity. The `fingerprint_sha256` field already has an index in place. The `title` doesn't have an index. Following [our index guidelines](https://docs.gitlab.com/ee/development/database/adding_database_indexes.html) I'd say we should not worry about that, as initial filtering by project/group should already decrease the data size enough. The proposed API follows the [Issues API](https://docs.gitlab.com/ee/api/issues.html) shape and is the following: | Attribute | Type | Required | Description| | ------ | ------ |------ |------ | | `search` | string| No|Searches deployment keys based on their `title` and `key` parameters, unless changed by `in` attribute| | `in` | string | No|Modify the scope of the search attribute. Values are `title`, `key`, or a string joining them with comma. Default is `title,key`.| We need to update [DeployKeysController](https://gitlab.com/gitlab-org/gitlab/blob/200f3fe6905bb48dfd4517d98461ad935ec702c2/app/controllers/projects/deploy_keys_controller.rb) to accept new filtering parameters for the following endpoints: ``` -/deploy_keys/available_project_keys -/deploy_keys/available_public_keys -/deploy_keys/enabled_keys ``` ### Frontend We should add a [FilteredSearch](https://gitlab-org.gitlab.io/gitlab-ui/?path=%2Fstory%2Fbase-filtered-search--default) component from `@gitlab/ui` package and has to be added to the [DeploymentKeysApp](https://gitlab.com/gitlab-org/gitlab/blob/5965d1b71386079b74d98bb3d4dbf0b0ce1cf842/app/assets/javascripts/deploy_keys/components/app.vue) component. We need to add two tokens to the FilteredSearch component for title and sha We should also update the data fetching logic in [GraphQl Resolvers](https://gitlab.com/gitlab-org/gitlab/blob/5965d1b71386079b74d98bb3d4dbf0b0ce1cf842/app/assets/javascripts/deploy_keys/graphql/resolvers.js) that wraps the underlying REST calls, and the respective client-side graphql queries.
issue