Skip to content
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

ACM-7784 [WIP] Change search query to use proper kind casing #3092

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function queryRemoteArgoApps(): IRequestResult<ISearchResult> {
input: [
{
filters: [
{ property: 'kind', values: ['application'] },
{ property: 'kind', values: ['Application'] },
{ property: 'apigroup', values: ['argoproj.io'] },
{ property: 'cluster', values: ['!local-cluster'] },
],
Expand All @@ -80,7 +80,7 @@ export function queryOCPAppResources(): IRequestResult<ISearchResult> {
filters: [
{
property: 'kind',
values: ['cronjob', 'daemonset', 'deployment', 'deploymentconfig', 'job', 'statefulset'],
values: ['CronJob', 'DaemonSet', 'Deployment', 'DeploymentConfig', 'Job', 'StatefulSet'],
},
],
limit: 6500, // search said not to use unlimited results so use this for now until pagination is available
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/Applications/Application.sharedmocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export const mockSearchQueryArgoApps = {
input: [
{
filters: [
{ property: 'kind', values: ['application'] },
{ property: 'kind', values: ['Application'] },
{ property: 'apigroup', values: ['argoproj.io'] },
{ property: 'cluster', values: ['!local-cluster'] },
],
Expand Down Expand Up @@ -533,7 +533,7 @@ export const mockSearchQueryOCPApplications = {
filters: [
{
property: 'kind',
values: ['cronjob', 'daemonset', 'deployment', 'deploymentconfig', 'job', 'statefulset'],
values: ['CronJob', 'DaemonSet', 'Deployment', 'DeploymentConfig', 'Job', 'StatefulSet'],
},
],
limit: 6500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const mockSearchQuery = {
{
keywords: [],
filters: [
{ property: 'kind', values: ['subscription'] },
{ property: 'kind', values: ['Subscription'] },
{ property: 'name', values: ['subscription-0'] },
{ property: 'namespace', values: ['namespace-0'] },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
export const convertStringToQuery = (searchText) => {
let relatedKinds = []

if (searchText.indexOf('kind:subscription') >= 0) {
relatedKinds = ['placementrule', 'deployable', 'application', 'subscription', 'channel']
} else if (searchText.indexOf('kind:channel') >= 0) {
relatedKinds = ['subscription']
} else if (searchText.indexOf('kind:placementrule') >= 0) {
relatedKinds = ['subscription']
if (searchText.indexOf('kind:Subscription') >= 0) {
relatedKinds = ['PlacementRule', 'Deployable', 'Application', 'Subscription', 'Channel']
} else if (searchText.indexOf('kind:Channel') >= 0) {
relatedKinds = ['Subscription']
} else if (searchText.indexOf('kind:PlacementRule') >= 0) {
relatedKinds = ['Subscription']
}

const searchTokens = searchText.split(' ')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@ import {
} from './search-helper'

describe('convertStringToQuery', () => {
const string1 = 'kind:subscription name:test'
const string2 = 'kind:channel name:test'
const string3 = 'kind:placementrule name:test'
const string1 = 'kind:Subscription name:test'
const string2 = 'kind:Channel name:test'
const string3 = 'kind:PlacementRule name:test'

const result1 = {
filters: [
{
property: 'kind',
values: ['subscription'],
values: ['Subscription'],
},
{
property: 'name',
values: ['test'],
},
],
keywords: [],
relatedKinds: ['placementrule', 'deployable', 'application', 'subscription', 'channel'],
relatedKinds: ['PlacementRule', 'Deployable', 'Application', 'Subscription', 'Channel'],
}

const result2 = {
filters: [
{ property: 'kind', values: ['channel'] },
{ property: 'kind', values: ['Channel'] },
{ property: 'name', values: ['test'] },
],
keywords: [],
relatedKinds: ['subscription'],
relatedKinds: ['Subscription'],
}
const result3 = {
filters: [
{ property: 'kind', values: ['placementrule'] },
{ property: 'kind', values: ['PlacementRule'] },
{ property: 'name', values: ['test'] },
],
keywords: [],
relatedKinds: ['subscription'],
relatedKinds: ['Subscription'],
}
it('convert string to query', () => {
expect(convertStringToQuery(string1)).toEqual(result1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function getRelatedResources(reports) {
const query = {
keywords: [],
filters: [
{ property: 'kind', values: [kind.toLowerCase()] },
{ property: 'kind', values: [kind] },
{ property: 'name', values: [name] },
{ property: 'namespace', values: [namespace] },
],
Expand All @@ -82,10 +82,10 @@ async function getRelatedResources(reports) {
}
switch (kind) {
case 'Deployment':
promises.push(getSearchPromise(cluster, kind, name, namespace, ['replicaset', 'pod']))
promises.push(getSearchPromise(cluster, kind, name, namespace, ['ReplicaSet', 'Pod']))
break
case 'DeploymentConfig':
promises.push(getSearchPromise(cluster, kind, name, namespace, ['replicationcontroller', 'pod']))
promises.push(getSearchPromise(cluster, kind, name, namespace, ['ReplicationController', 'Pod']))
break
case 'Route':
promises.push(fireManagedClusterView(cluster, 'route', 'route.openshift.io/v1', name, namespace))
Expand Down Expand Up @@ -126,7 +126,7 @@ const getSearchPromise = (cluster, kind, name, namespace, relatedKinds) => {
const query = {
keywords: [],
filters: [
{ property: 'kind', values: [kind.toLowerCase()] },
{ property: 'kind', values: [kind] },
{ property: 'name', values: [name] },
{ property: 'namespace', values: [namespace] },
],
Expand All @@ -151,10 +151,10 @@ const getQueryStringForResource = (resourcename, name, namespace) => {
if (resourcename) {
switch (resourcename) {
case 'Subscription':
resource = 'kind:subscription '
resource = 'kind:Subscription '
break
case 'Application':
resource = 'kind:application'
resource = 'kind:Application'
break
default:
resource = `kind:${resourcename} `
Expand Down