Skip to content

Commit

Permalink
[fix] fix inventory row string values for numbers type (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Dec 2, 2023
1 parent ff25e7c commit fdab07b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 58 deletions.
36 changes: 18 additions & 18 deletions src/locales/de-DE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ msgstr "© 2023 Some Engineering Services GMBH. Alle Rechte vorbehalten."
#: src/pages/panel/accounts/AccountsTable.tsx:31
#: src/pages/panel/inventory/InventoryTable.error.tsx:74
#: src/pages/panel/inventory/InventoryTable.tsx:79
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:77
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:79
#: src/shared/layouts/panel-layout/UserProfileButton.tsx:103
msgid "Accounts"
msgstr "Konten"
Expand All @@ -73,7 +73,7 @@ msgstr "Aktionen"
msgid "Add an account"
msgstr "Füge ein Konto hinzu"

#: src/pages/panel/inventory/ResourceDetail.tsx:185
#: src/pages/panel/inventory/ResourceDetail.tsx:186
msgid "Age"
msgstr "Alter"

Expand Down Expand Up @@ -105,7 +105,7 @@ msgstr "Automatisches Cloud Setup"
msgid "AWS Marketplace has been successfully subscribed"
msgstr "AWS Marketplace wurde erfolgreich abonniert"

#: src/pages/panel/inventory/ResourceDetail.tsx:171
#: src/pages/panel/inventory/ResourceDetail.tsx:172
msgid "Basic Information"
msgstr "Grundinformation"

Expand Down Expand Up @@ -138,7 +138,7 @@ msgstr "Cloud"
msgid "Cloud account added, id: {0}"
msgstr "Cloud-Konto hinzugefügt, ID: {0}"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:73
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:75
msgid "Clouds"
msgstr "Wolken"

Expand All @@ -160,7 +160,7 @@ msgstr "In die Zwischenablage kopiert!"
msgid "Copy"
msgstr "Kopieren"

#: src/pages/panel/inventory/ResourceDetail.tsx:181
#: src/pages/panel/inventory/ResourceDetail.tsx:182
msgid "Created Time"
msgstr "Erstellte Zeit"

Expand Down Expand Up @@ -192,7 +192,7 @@ msgstr "Löschen"
msgid "Deploy Stack"
msgstr "Deploy Stack"

#: src/pages/panel/inventory/ResourceDetail.tsx:213
#: src/pages/panel/inventory/ResourceDetail.tsx:214
msgid "Details"
msgstr "Einzelheiten"

Expand Down Expand Up @@ -263,7 +263,7 @@ msgstr "Wie repariert man"
#: src/pages/panel/accounts/AccountRow.tsx:278
#: src/pages/panel/accounts/AccountsTable.tsx:38
#: src/pages/panel/home/AccountCard.tsx:30
#: src/pages/panel/inventory/ResourceDetail.tsx:178
#: src/pages/panel/inventory/ResourceDetail.tsx:179
msgid "ID"
msgstr "ID"

Expand All @@ -283,11 +283,11 @@ msgstr "Inventar"
#~ msgid "Issues"
#~ msgstr "Probleme"

#: src/pages/panel/inventory/ResourceDetail.tsx:177
#: src/pages/panel/inventory/ResourceDetail.tsx:178
msgid "Kind"
msgstr "Art"

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

Expand Down Expand Up @@ -326,7 +326,7 @@ msgstr "Am meisten verbesserte Ressourcen"

#: src/pages/panel/accounts/AccountRow.tsx:284
#: src/pages/panel/accounts/AccountsTable.tsx:41
#: src/pages/panel/inventory/ResourceDetail.tsx:179
#: src/pages/panel/inventory/ResourceDetail.tsx:180
msgid "Name"
msgstr "Name"

Expand Down Expand Up @@ -359,7 +359,7 @@ msgstr "Noch nichts zu zeigen"
msgid "Null"
msgstr "Null"

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:138
#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:129
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 @@ -405,11 +405,11 @@ msgstr "Privilegiert"
msgid "Profile"
msgstr "Profil"

#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:197
#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:213
msgid "Property"
msgstr "Eigentum"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:81
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:83
msgid "Regions"
msgstr "Regionen"

Expand All @@ -425,7 +425,7 @@ msgstr "Ressourcen"
msgid "Risk"
msgstr "Risiko"

#: src/pages/panel/inventory/ResourceDetail.tsx:233
#: src/pages/panel/inventory/ResourceDetail.tsx:234
msgid "Security Issues"
msgstr "Sicherheitsprobleme"

Expand All @@ -442,7 +442,7 @@ msgstr "Sicherheitsbewertung"
msgid "Select Language"
msgstr "Sprache auswählen"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:99
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:101
msgid "Severity"
msgstr "Schwere"

Expand All @@ -469,8 +469,8 @@ msgstr "Einfacher und erschwinglicher Einblick in die Sicherheitslage Ihrer Clou
msgid "Submit"
msgstr "Einreichen"

#: src/pages/panel/inventory/InventoryTagAutoComplete.tsx:69
#: src/pages/panel/inventory/ResourceDetail.tsx:199
#: src/pages/panel/inventory/InventoryTagAutoComplete.tsx:72
#: src/pages/panel/inventory/ResourceDetail.tsx:200
msgid "Tags"
msgstr "Stichworte"

Expand Down Expand Up @@ -520,7 +520,7 @@ msgid "Try again"
msgstr "Versuchen Sie es erneut"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:126
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:103
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:105
msgid "Value"
msgstr "Wert"

Expand Down
36 changes: 18 additions & 18 deletions src/locales/en-US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ msgstr "© 2023 Some Engineering Inc. All rights reserved."
#: src/pages/panel/accounts/AccountsTable.tsx:31
#: src/pages/panel/inventory/InventoryTable.error.tsx:74
#: src/pages/panel/inventory/InventoryTable.tsx:79
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:77
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:79
#: src/shared/layouts/panel-layout/UserProfileButton.tsx:103
msgid "Accounts"
msgstr "Accounts"
Expand All @@ -73,7 +73,7 @@ msgstr "Actions"
msgid "Add an account"
msgstr "Add an account"

#: src/pages/panel/inventory/ResourceDetail.tsx:185
#: src/pages/panel/inventory/ResourceDetail.tsx:186
msgid "Age"
msgstr "Age"

Expand Down Expand Up @@ -105,7 +105,7 @@ msgstr "Automatic Cloud Setup"
msgid "AWS Marketplace has been successfully subscribed"
msgstr "AWS Marketplace has been successfully subscribed"

#: src/pages/panel/inventory/ResourceDetail.tsx:171
#: src/pages/panel/inventory/ResourceDetail.tsx:172
msgid "Basic Information"
msgstr "Basic Information"

Expand Down Expand Up @@ -138,7 +138,7 @@ msgstr "Cloud"
msgid "Cloud account added, id: {0}"
msgstr "Cloud account added, id: {0}"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:73
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:75
msgid "Clouds"
msgstr "Clouds"

Expand All @@ -160,7 +160,7 @@ msgstr "Copied to Clipboard!"
msgid "Copy"
msgstr "Copy"

#: src/pages/panel/inventory/ResourceDetail.tsx:181
#: src/pages/panel/inventory/ResourceDetail.tsx:182
msgid "Created Time"
msgstr "Created Time"

Expand Down Expand Up @@ -192,7 +192,7 @@ msgstr "Delete"
msgid "Deploy Stack"
msgstr "Deploy Stack"

#: src/pages/panel/inventory/ResourceDetail.tsx:213
#: src/pages/panel/inventory/ResourceDetail.tsx:214
msgid "Details"
msgstr "Details"

Expand Down Expand Up @@ -263,7 +263,7 @@ msgstr "How to fix"
#: src/pages/panel/accounts/AccountRow.tsx:278
#: src/pages/panel/accounts/AccountsTable.tsx:38
#: src/pages/panel/home/AccountCard.tsx:30
#: src/pages/panel/inventory/ResourceDetail.tsx:178
#: src/pages/panel/inventory/ResourceDetail.tsx:179
msgid "ID"
msgstr "ID"

Expand All @@ -283,11 +283,11 @@ msgstr "Inventory"
#~ msgid "Issues"
#~ msgstr "Issues"

#: src/pages/panel/inventory/ResourceDetail.tsx:177
#: src/pages/panel/inventory/ResourceDetail.tsx:178
msgid "Kind"
msgstr "Kind"

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

Expand Down Expand Up @@ -326,7 +326,7 @@ msgstr "Most Improved Resources"

#: src/pages/panel/accounts/AccountRow.tsx:284
#: src/pages/panel/accounts/AccountsTable.tsx:41
#: src/pages/panel/inventory/ResourceDetail.tsx:179
#: src/pages/panel/inventory/ResourceDetail.tsx:180
msgid "Name"
msgstr "Name"

Expand Down Expand Up @@ -359,7 +359,7 @@ msgstr "Nothing to show yet"
msgid "Null"
msgstr "Null"

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:138
#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:129
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 @@ -405,11 +405,11 @@ msgstr "Privileged"
msgid "Profile"
msgstr "Profile"

#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:197
#: src/pages/panel/inventory/InventoryFormFilterRowProperty.tsx:213
msgid "Property"
msgstr "Property"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:81
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:83
msgid "Regions"
msgstr "Regions"

Expand All @@ -425,7 +425,7 @@ msgstr "Resources"
msgid "Risk"
msgstr "Risk"

#: src/pages/panel/inventory/ResourceDetail.tsx:233
#: src/pages/panel/inventory/ResourceDetail.tsx:234
msgid "Security Issues"
msgstr "Security Issues"

Expand All @@ -442,7 +442,7 @@ msgstr "Security Score"
msgid "Select Language"
msgstr "Select Language"

#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:99
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:101
msgid "Severity"
msgstr "Severity"

Expand All @@ -469,8 +469,8 @@ msgstr "Simple and affordable visibility into your cloud security posture."
msgid "Submit"
msgstr "Submit"

#: src/pages/panel/inventory/InventoryTagAutoComplete.tsx:69
#: src/pages/panel/inventory/ResourceDetail.tsx:199
#: src/pages/panel/inventory/InventoryTagAutoComplete.tsx:72
#: src/pages/panel/inventory/ResourceDetail.tsx:200
msgid "Tags"
msgstr "Tags"

Expand Down Expand Up @@ -520,7 +520,7 @@ msgid "Try again"
msgstr "Try again"

#: src/pages/panel/inventory/InventoryFormFilterRowValues.tsx:126
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:103
#: src/pages/panel/inventory/utils/getAutoCompleteFromKey.tsx:105
msgid "Value"
msgstr "Value"

Expand Down
44 changes: 23 additions & 21 deletions src/pages/panel/inventory/InventoryFormFilterRowStringValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ export function InventoryFormFilterRowStringValue<Multiple extends boolean, Netw
value && (!Array.isArray(value) || value.length)
? optionsWithTyped.concat(
Array.isArray(value)
? value
.map((i) => (optionsWithTyped.find((j) => (typeof i === 'string' ? j.label === i : j === i)) ? undefined : i))
.filter((i) => i && i.value !== 'null')
.map((i) => (typeof i === 'string' ? { label: i, value: i } : (i as AutoCompleteValue)))
: optionsWithTyped.indexOf(value) > -1
? (value
.map((i) => (optionsWithTyped.find((j) => j === i || i.value === j.value) ? undefined : i))
.filter((i) => i && i.value !== 'null') as AutoCompleteValue[])
: optionsWithTyped.find((j) => value.value === j.value)
? []
: [value],
)
Expand Down Expand Up @@ -145,25 +144,10 @@ export function InventoryFormFilterRowStringValue<Multiple extends boolean, Netw
renderInput={(params) => (
<TextField
{...params}
type={isNumber ? 'number' : 'text'}
type={isNumber && typed !== 'null' && typed !== 'Null' ? 'number' : 'text'}
inputProps={{
...params.inputProps,
value: typed,
onChange: (e) => {
if (isNumber) {
const num = Number(e.currentTarget.value)
if (!Number.isNaN(num)) {
if (isDouble) {
setTyped(num.toString())
} else {
setTyped(Math.round(num).toString())
}
}
} else {
setTyped(e.currentTarget.value)
}
params.inputProps.onChange?.(e as ChangeEvent<HTMLInputElement>)
},
}}
InputProps={{
...params.InputProps,
Expand All @@ -174,6 +158,24 @@ export function InventoryFormFilterRowStringValue<Multiple extends boolean, Netw
</>
),
}}
onChange={(e) => {
if (isNumber) {
const curValue = e.currentTarget.value
const num = Number(curValue)
if (curValue === '' || curValue === 'null' || curValue === 'Null' || !Number.isNaN(num)) {
if (curValue === '' || curValue === 'null' || curValue === 'Null') {
setTyped(curValue)
} else if (isDouble) {
setTyped(num.toString())
} else {
setTyped(Math.round(num).toString())
}
}
} else {
setTyped(e.currentTarget.value)
}
params.inputProps.onChange?.(e as ChangeEvent<HTMLInputElement>)
}}
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export const getWorkspaceInventoryPropertyValuesQuery = ({
},
},
)
.then((res) => res.data)
.then((res) => res.data.map((i) => i.toString()))
: null
}

0 comments on commit fdab07b

Please sign in to comment.