Skip to content

Commit

Permalink
[fix] inventory-string-values: fix remove unnecessary connection requ…
Browse files Browse the repository at this point in the history
…ests (#55)
  • Loading branch information
sijav authored Dec 7, 2023
1 parent 88daf23 commit 645d776
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 73 deletions.
38 changes: 19 additions & 19 deletions src/locales/de-DE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ msgstr "Alter"
msgid "Already have an account? Click here to Log in."
msgstr "Sie haben bereits ein Konto? Klicken Sie hier, um sich einzuloggen."

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:73
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:107
msgid "Alternatively if you would like to deploy the stack manually, you can use the following CloudFormation template"
msgstr "Wenn Sie den Stack alternativ manuell bereitstellen möchten, können Sie folgendes CloudFormation-Template verwenden"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:68
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:102
msgid "Alternatively: Manual Cloud Setup"
msgstr "Alternativ: Manuelles Cloud Setup"

Expand All @@ -97,7 +97,7 @@ msgstr "und"
msgid "Are you sure?"
msgstr "Bist du sicher?"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:35
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:45
msgid "Automatic Cloud Setup"
msgstr "Automatisches Cloud Setup"

Expand Down Expand Up @@ -180,11 +180,11 @@ msgstr "Kritisch"
msgid "Dashboard"
msgstr "Dashboard"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:116
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:151
msgid "Date Picker"
msgstr "Datumsauswahl"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:108
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:143
msgid "Date Time Picker"
msgstr "Datum-/Uhrzeitauswahl"

Expand All @@ -196,7 +196,7 @@ msgid "Delete"
msgstr "Löschen"

#: src/pages/panel/setup-cloud/SetupCloudButton.tsx:15
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:49
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:83
msgid "Deploy Stack"
msgstr "Deploy Stack"

Expand Down Expand Up @@ -230,15 +230,15 @@ msgstr "Ermöglicht"
msgid "Events"
msgstr "Veranstaltungen"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:92
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:126
msgid "External Id"
msgstr "External Id"

#: src/pages/panel/panel-home/OverallCard.tsx:89
#~ msgid "Failed Checks"
#~ msgstr "Fehlgeschlagene Prüfungen"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:100
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:135
msgid "False"
msgstr "FALSCH"

Expand Down Expand Up @@ -279,12 +279,12 @@ msgstr "ID"
msgid "Improved"
msgstr "Verbessert"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:38
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:48
msgid "In the next step we are going to set up the trust between FIX and your AWS cloud account."
msgstr "Im nächsten Schritt richten wir einen Trust zwischen FIX und Ihrem AWS Konto ein."

#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:282
#: src/pages/panel/inventory/InventoryFormFilterRowStringValue.tsx:159
#: src/pages/panel/inventory/InventoryFormFilterRowStringValue.tsx:193
msgid "Invalid Value"
msgstr "Ungültiger Wert"

Expand All @@ -300,7 +300,7 @@ msgstr "Inventar"
msgid "Kind"
msgstr "Art"

#: src/pages/panel/inventory/InventoryForm.tsx:213
#: src/pages/panel/inventory/InventoryForm.tsx:212
msgid "Kinds"
msgstr "Arten"

Expand All @@ -321,7 +321,7 @@ msgstr "Ausloggen"
msgid "Low"
msgstr "Niedrig"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:41
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:51
msgid "Make sure that you are already logged into the correct AWS account, before pressing the DEPLOY STACK button."
msgstr "Stellen Sie sicher, dass Sie bereits beim richtigen AWS Konto angemeldet sind, bevor Sie auf die Schaltfläche DEPLOY STACK klicken."

Expand Down Expand Up @@ -368,11 +368,11 @@ msgstr "Sie löschen gerade ein Management- oder delegiertes Admin-Konto. Beacht
msgid "Nothing to show yet"
msgstr "Noch nichts zu zeigen"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:94
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:129
msgid "Null"
msgstr "Null"

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:133
#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:109
msgid "Oops! It looks like your query didn't match our format. Please check and try again."
msgstr "Ups! Ihre Eingabe entspricht nicht unserem Format. Bitte überprüfen Sie sie und versuchen Sie es erneut."

Expand Down Expand Up @@ -491,19 +491,19 @@ msgstr "Stichworte"
#~ msgid "Task \"{0}\" with workflow \"{1}\" failed: {2}"
#~ msgstr "Aufgabe \"{0}\" mit Workflow \"{1}\" ist fehlgeschlagen: {2}"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:110
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:144
msgid "Tenant Id"
msgstr "Tenant Id"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:81
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:115
msgid "The Stack requires the following parameters"
msgstr "Der Stack erfordert die folgenden Parameter"

#: src/shared/layouts/panel-layout/AccountCheckGuard.tsx:38
msgid "There's no account configured for this workspace."
msgstr "Für diesen Arbeitsbereich ist kein Konto konfiguriert."

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:59
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:93
msgid "This will deploy a CloudFormation stack that creates a new IAM role in your AWS account. This role will be used by FIX to perform security scans in your AWS account."
msgstr "Hiermit wird ein CloudFormation-Stack bereitgestellt, der eine neue IAM Rolle in Ihrem AWS Konto erstellt. Diese Rolle wird von FIX verwendet, um in Ihrem AWS Konto Sicherheitsscans durchzuführen."

Expand All @@ -524,15 +524,15 @@ msgstr "Die fünf wichtigsten Sicherheitsverbesserungen"
msgid "Top Non-Compliant Resources"
msgstr "Top Ressourcen mit Compliance-Verstößen"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:97
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:132
msgid "True"
msgstr "WAHR"

#: src/shared/error-boundary-fallback/ErrorBoundaryFallback.tsx:73
msgid "Try again"
msgstr "Versuchen Sie es erneut"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:129
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:164
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:118
msgid "Value"
msgstr "Wert"
Expand Down
38 changes: 19 additions & 19 deletions src/locales/en-US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ msgstr "Age"
msgid "Already have an account? Click here to Log in."
msgstr "Already have an account? Click here to Log in."

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:73
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:107
msgid "Alternatively if you would like to deploy the stack manually, you can use the following CloudFormation template"
msgstr "Alternatively if you would like to deploy the stack manually, you can use the following CloudFormation template"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:68
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:102
msgid "Alternatively: Manual Cloud Setup"
msgstr "Alternatively: Manual Cloud Setup"

Expand All @@ -97,7 +97,7 @@ msgstr "and"
msgid "Are you sure?"
msgstr "Are you sure?"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:35
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:45
msgid "Automatic Cloud Setup"
msgstr "Automatic Cloud Setup"

Expand Down Expand Up @@ -180,11 +180,11 @@ msgstr "Critical"
msgid "Dashboard"
msgstr "Dashboard"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:116
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:151
msgid "Date Picker"
msgstr "Date Picker"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:108
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:143
msgid "Date Time Picker"
msgstr "Date Time Picker"

Expand All @@ -196,7 +196,7 @@ msgid "Delete"
msgstr "Delete"

#: src/pages/panel/setup-cloud/SetupCloudButton.tsx:15
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:49
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:83
msgid "Deploy Stack"
msgstr "Deploy Stack"

Expand Down Expand Up @@ -230,15 +230,15 @@ msgstr "Enabled"
msgid "Events"
msgstr "Events"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:92
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:126
msgid "External Id"
msgstr "External Id"

#: src/pages/panel/panel-home/OverallCard.tsx:89
#~ msgid "Failed Checks"
#~ msgstr "Failed Checks"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:100
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:135
msgid "False"
msgstr "False"

Expand Down Expand Up @@ -279,12 +279,12 @@ msgstr "ID"
msgid "Improved"
msgstr "Improved"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:38
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:48
msgid "In the next step we are going to set up the trust between FIX and your AWS cloud account."
msgstr "In the next step we are going to set up the trust between FIX and your AWS cloud account."

#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:282
#: src/pages/panel/inventory/InventoryFormFilterRowStringValue.tsx:159
#: src/pages/panel/inventory/InventoryFormFilterRowStringValue.tsx:193
msgid "Invalid Value"
msgstr "Invalid Value"

Expand All @@ -300,7 +300,7 @@ msgstr "Inventory"
msgid "Kind"
msgstr "Kind"

#: src/pages/panel/inventory/InventoryForm.tsx:213
#: src/pages/panel/inventory/InventoryForm.tsx:212
msgid "Kinds"
msgstr "Kinds"

Expand All @@ -321,7 +321,7 @@ msgstr "Logout"
msgid "Low"
msgstr "Low"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:41
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:51
msgid "Make sure that you are already logged into the correct AWS account, before pressing the DEPLOY STACK button."
msgstr "Make sure that you are already logged into the correct AWS account, before pressing the DEPLOY STACK button."

Expand Down Expand Up @@ -368,11 +368,11 @@ msgstr "Note: You are about to delete a management or delegated admin account. P
msgid "Nothing to show yet"
msgstr "Nothing to show yet"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:94
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:129
msgid "Null"
msgstr "Null"

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:133
#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:109
msgid "Oops! It looks like your query didn't match our format. Please check and try again."
msgstr "Oops! It looks like your query didn't match our format. Please check and try again."

Expand Down Expand Up @@ -491,19 +491,19 @@ msgstr "Tags"
#~ msgid "Task \"{0}\" with workflow \"{1}\" failed: {2}"
#~ msgstr "Task \"{0}\" with workflow \"{1}\" failed: {2}"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:110
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:144
msgid "Tenant Id"
msgstr "Tenant Id"

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:81
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:115
msgid "The Stack requires the following parameters"
msgstr "The Stack requires the following parameters"

#: src/shared/layouts/panel-layout/AccountCheckGuard.tsx:38
msgid "There's no account configured for this workspace."
msgstr "There's no account configured for this workspace."

#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:59
#: src/pages/panel/setup-cloud/SetupCloudPage.tsx:93
msgid "This will deploy a CloudFormation stack that creates a new IAM role in your AWS account. This role will be used by FIX to perform security scans in your AWS account."
msgstr "This will deploy a CloudFormation stack that creates a new IAM role in your AWS account. This role will be used by FIX to perform security scans in your AWS account."

Expand All @@ -524,15 +524,15 @@ msgstr "Top 5 Security Enhancements"
msgid "Top Non-Compliant Resources"
msgstr "Top Non-Compliant Resources"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:97
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:132
msgid "True"
msgstr "True"

#: src/shared/error-boundary-fallback/ErrorBoundaryFallback.tsx:73
msgid "Try again"
msgstr "Try again"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:129
#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:164
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:118
msgid "Value"
msgstr "Value"
Expand Down
28 changes: 2 additions & 26 deletions src/pages/panel/inventory/InventoryAdvanceSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ import SearchIcon from '@mui/icons-material/Search'
import { Box, Collapse, Divider, FormHelperText, IconButton, TextField, Typography, styled } from '@mui/material'
import { ChangeEvent, Suspense, useCallback, useEffect, useRef, useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import { OPType, stringSimpleTypes } from 'src/pages/panel/shared/constants'
import { panelUI } from 'src/shared/constants'
import { ErrorBoundaryFallback, NetworkErrorBoundary } from 'src/shared/error-boundary-fallback'
import { ResourceComplexKindSimpleTypeDefinitions } from 'src/shared/types/server'
import { shouldForwardProp } from 'src/shared/utils/shouldForwardProp'
import { InventoryForm } from './InventoryForm'
import { InventoryFormsSkeleton } from './InventoryForms.skeleton'
import { getArrayFromInOP } from './utils'

export interface InventoryAdvanceSearchConfig {
id: number
property: string | null
op: OPType | null
value: string | null
fqn: ResourceComplexKindSimpleTypeDefinitions | null
}
import { InventoryAdvanceSearchConfig, inventoryAdvanceSearchConfigToString } from './utils'

interface InventoryAdvanceSearchProps {
value: string
Expand Down Expand Up @@ -76,21 +66,7 @@ export const InventoryAdvanceSearch = ({ value: searchCrit, onChange, hasError }
useEffect(() => {
if (initializedRef.current) {
const configJoined = config
.map((item) => {
if (typeof item === 'string' || !item) {
return item
}
if (item.property && item.op && item.value && item.fqn) {
const value =
stringSimpleTypes.includes(item.fqn as (typeof stringSimpleTypes)[number]) && item.value !== 'null'
? item.op === 'in' || item.op === 'not in'
? JSON.stringify(getArrayFromInOP(item.value, true))
: `"${item.value}"`
: item.value
return `${item.property} ${item.op} ${value}`
}
return null
})
.map(inventoryAdvanceSearchConfigToString)
.filter((filter) => filter)
.join(' and ')
const result = (kind ? `is(${kind})${configJoined ? ' and ' : ''}` : '') + configJoined
Expand Down
3 changes: 1 addition & 2 deletions src/pages/panel/inventory/InventoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { DefaultPropertiesKeys } from 'src/pages/panel/shared/constants'
import { getWorkspaceInventorySearchStartQuery } from 'src/pages/panel/shared/queries'
import { isValidProp } from 'src/pages/panel/shared/utils'
import { ErrorBoundaryFallback, NetworkErrorBoundary } from 'src/shared/error-boundary-fallback'
import { InventoryAdvanceSearchConfig } from './InventoryAdvanceSearch'
import { InventoryFormFilterRow } from './InventoryFormFilterRow'
import { InventoryFormTemplateObject, InventoryFormTemplates } from './InventoryFormTemplates'
import { getArrayFromInOP } from './utils'
import { InventoryAdvanceSearchConfig, getArrayFromInOP } from './utils'

interface InventoryFormProps {
setConfig: Dispatch<SetStateAction<InventoryAdvanceSearchConfig[]>>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/panel/inventory/InventoryFormFilterRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import {
stringOPTypes,
} from 'src/pages/panel/shared/constants'
import { ResourceComplexKindSimpleTypeDefinitions } from 'src/shared/types/server'
import { InventoryAdvanceSearchConfig } from './InventoryAdvanceSearch'
import { InventoryFormFilterRowProperty } from './InventoryFormFilterRowProperty'
import { InventoryFormFilterRowValues } from './InventoryFormFilterRowValues'
import { AutoCompletePreDefinedItems, getArrayFromInOP } from './utils'
import { AutoCompletePreDefinedItems, InventoryAdvanceSearchConfig, getArrayFromInOP } from './utils'

interface InventoryFormFilterRowProps {
item: InventoryAdvanceSearchConfig
Expand Down
Loading

0 comments on commit 645d776

Please sign in to comment.