Skip to content

Commit

Permalink
[Fix] allow to see all resources (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Jul 12, 2024
1 parent 75ecf99 commit 826cc33
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 131 deletions.
28 changes: 14 additions & 14 deletions src/locales/de-DE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ msgid "Access to your account is broken"
msgstr "Der Zugriff auf Ihr Konto ist unterbrochen"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:195
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:60
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:65
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:239
msgid "Account"
msgstr "Konto"
Expand All @@ -259,7 +259,7 @@ msgstr "Konto"
msgid "Account: {0}"
msgstr "Konto: {0}"

#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:43
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:57
#: src/pages/panel/inventory/inventory-form/utils/getAutoCompleteFromKey.tsx:125
#: src/pages/panel/inventory/InventoryTable.error.tsx:73
#: src/pages/panel/workspace-settings/WorkspaceSettingsPage.tsx:57
Expand Down Expand Up @@ -348,7 +348,7 @@ msgstr "Admin"
msgid "Advanced"
msgstr ""

#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:85
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:83
msgid "Advanced search query"
msgstr "Erweiterte Suchabfrage"

Expand Down Expand Up @@ -566,7 +566,7 @@ msgstr "Stornieren"
msgid "Cannot enable this account"
msgstr ""

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:211
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:213
#: src/pages/panel/inventory/inventory-form/InventoryFormMoreValue.tsx:125
#: src/pages/panel/inventory/inventory-form/InventoryFormTagsValue.tsx:115
msgid "Change"
Expand Down Expand Up @@ -665,7 +665,7 @@ msgid "Close"
msgstr "Schließen"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:165
#: src/pages/panel/inventory/inventory-form/InventoryFormCloudValues.tsx:57
#: src/pages/panel/inventory/inventory-form/InventoryFormCloudValues.tsx:62
#: src/pages/panel/inventory/inventory-form/InventoryFormMore.tsx:96
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:235
#: src/pages/panel/security/AccountCard.tsx:37
Expand Down Expand Up @@ -1341,7 +1341,7 @@ msgstr "Externen Benutzer einladen"
msgid "Invites"
msgstr "Lädt ein"

#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:42
#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:45
msgid "kind"
msgstr ""

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

#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:34
#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:37
msgid "Kinds"
msgstr "Arten"

Expand Down Expand Up @@ -1530,7 +1530,7 @@ msgstr "Nächste Synchronisierung"
msgid "No"
msgstr ""

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:202
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:204
msgid "No {label} found for {typed}"
msgstr ""

Expand Down Expand Up @@ -1633,7 +1633,7 @@ msgid "Oops, the username or password doesn't seem to match our records. Please
msgstr "Hoppla, der Benutzername oder das Passwort scheinen nicht mit unseren Aufzeichnungen übereinzustimmen. Bitte versuche es erneut."

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:97
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:114
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:112
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 @@ -1853,7 +1853,7 @@ msgstr "Regenerieren"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:183
#: src/pages/panel/inventory/inventory-form/InventoryFormMore.tsx:97
#: src/pages/panel/inventory/inventory-form/InventoryFormRegionValues.tsx:54
#: src/pages/panel/inventory/inventory-form/InventoryFormRegionValues.tsx:60
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:240
msgid "Region"
msgstr "Region"
Expand Down Expand Up @@ -1931,7 +1931,7 @@ msgstr "Risiko"
msgid "Roles"
msgstr "Rollen"

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:167
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:169
msgid "Search {0}"
msgstr ""

Expand Down Expand Up @@ -2042,14 +2042,14 @@ msgstr "E-Mail-Benachrichtigungen einrichten"
msgid "Setup cloud"
msgstr ""

#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:40
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:56
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:46
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:60
msgid "Severities"
msgstr ""

#: src/pages/panel/benchmark-detail/BenchmarkCheckCollectionDetail.tsx:81
#: src/pages/panel/benchmark-detail/BenchmarkDetailView.tsx:102
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:50
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:54
#: src/pages/panel/inventory/inventory-form/utils/getAutoCompleteFromKey.tsx:156
#: src/pages/panel/workspace-settings/workspace-alerting-settings/WorkspaceAlertingSettings.tsx:163
#: src/pages/panel/workspace-settings/workspace-alerting-settings/WorkspaceAlertingSettings.tsx:217
Expand Down
28 changes: 14 additions & 14 deletions src/locales/en-US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ msgid "Access to your account is broken"
msgstr "Access to your account is broken"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:195
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:60
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:65
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:239
msgid "Account"
msgstr "Account"
Expand All @@ -259,7 +259,7 @@ msgstr "Account"
msgid "Account: {0}"
msgstr "Account: {0}"

#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:43
#: src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx:57
#: src/pages/panel/inventory/inventory-form/utils/getAutoCompleteFromKey.tsx:125
#: src/pages/panel/inventory/InventoryTable.error.tsx:73
#: src/pages/panel/workspace-settings/WorkspaceSettingsPage.tsx:57
Expand Down Expand Up @@ -348,7 +348,7 @@ msgstr "Admin"
msgid "Advanced"
msgstr "Advanced"

#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:85
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:83
msgid "Advanced search query"
msgstr "Advanced search query"

Expand Down Expand Up @@ -566,7 +566,7 @@ msgstr "Cancel"
msgid "Cannot enable this account"
msgstr "Cannot enable this account"

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:211
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:213
#: src/pages/panel/inventory/inventory-form/InventoryFormMoreValue.tsx:125
#: src/pages/panel/inventory/inventory-form/InventoryFormTagsValue.tsx:115
msgid "Change"
Expand Down Expand Up @@ -665,7 +665,7 @@ msgid "Close"
msgstr "Close"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:165
#: src/pages/panel/inventory/inventory-form/InventoryFormCloudValues.tsx:57
#: src/pages/panel/inventory/inventory-form/InventoryFormCloudValues.tsx:62
#: src/pages/panel/inventory/inventory-form/InventoryFormMore.tsx:96
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:235
#: src/pages/panel/security/AccountCard.tsx:37
Expand Down Expand Up @@ -1341,7 +1341,7 @@ msgstr "Invite External User"
msgid "Invites"
msgstr "Invites"

#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:42
#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:45
msgid "kind"
msgstr "kind"

Expand All @@ -1351,7 +1351,7 @@ msgstr "kind"
msgid "Kind"
msgstr "Kind"

#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:34
#: src/pages/panel/inventory/inventory-form/InventoryFormKind.tsx:37
msgid "Kinds"
msgstr "Kinds"

Expand Down Expand Up @@ -1530,7 +1530,7 @@ msgstr "Next Sync"
msgid "No"
msgstr "No"

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:202
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:204
msgid "No {label} found for {typed}"
msgstr "No {label} found for {typed}"

Expand Down Expand Up @@ -1633,7 +1633,7 @@ msgid "Oops, the username or password doesn't seem to match our records. Please
msgstr "Oops, the username or password doesn't seem to match our records. Please try again."

#: src/pages/panel/inventory/InventoryAdvanceSearch.tsx:97
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:114
#: src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx:112
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 @@ -1853,7 +1853,7 @@ msgstr "Regenerate"

#: src/pages/panel/benchmark-detail/BenchmarkDetailCheckDetail.tsx:183
#: src/pages/panel/inventory/inventory-form/InventoryFormMore.tsx:97
#: src/pages/panel/inventory/inventory-form/InventoryFormRegionValues.tsx:54
#: src/pages/panel/inventory/inventory-form/InventoryFormRegionValues.tsx:60
#: src/pages/panel/resource-detail/ResourceDetailView.tsx:240
msgid "Region"
msgstr "Region"
Expand Down Expand Up @@ -1931,7 +1931,7 @@ msgstr "Risk"
msgid "Roles"
msgstr "Roles"

#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:167
#: src/pages/panel/inventory/inventory-form/InventoryFormDefaultValue.tsx:169
msgid "Search {0}"
msgstr "Search {0}"

Expand Down Expand Up @@ -2042,14 +2042,14 @@ msgstr "Setting Up Email Notifications"
msgid "Setup cloud"
msgstr "Setup cloud"

#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:40
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:56
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:46
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:60
msgid "Severities"
msgstr "Severities"

#: src/pages/panel/benchmark-detail/BenchmarkCheckCollectionDetail.tsx:81
#: src/pages/panel/benchmark-detail/BenchmarkDetailView.tsx:102
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:50
#: src/pages/panel/inventory/inventory-form/InventoryFormSeverity.tsx:54
#: src/pages/panel/inventory/inventory-form/utils/getAutoCompleteFromKey.tsx:156
#: src/pages/panel/workspace-settings/workspace-alerting-settings/WorkspaceAlertingSettings.tsx:163
#: src/pages/panel/workspace-settings/workspace-alerting-settings/WorkspaceAlertingSettings.tsx:217
Expand Down
14 changes: 6 additions & 8 deletions src/pages/panel/inventory/InventoryAdvanceSearchTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const InventoryAdvanceSearchTextField = ({ hasError }: InventoryAdvanceSe
const [hasTextError, setHasTextError] = useState(false)
const { updateQuery, reset, error, q } = useFixQueryParser()

const [searchCritValue, setSearchCritValue] = useState(!q && q !== 'all' ? '' : q)
const [searchCritValue, setSearchCritValue] = useState(q ?? '')

const timeoutRef = useRef<number>()

Expand Down Expand Up @@ -69,17 +69,15 @@ export const InventoryAdvanceSearchTextField = ({ hasError }: InventoryAdvanceSe
setHasTextError(false)
}

const searchCritValueWithoutAll = searchCritValue === 'all' ? '' : searchCritValue

return (
<>
<TextField
variant="outlined"
margin="dense"
multiline
label={
<Stack direction="row" gap={1} mt={!focused && !searchCritValueWithoutAll ? 0.5 : undefined}>
<Collapse in={!focused && !searchCritValueWithoutAll} orientation="horizontal">
<Stack direction="row" gap={1} mt={!focused && !searchCritValue ? 0.5 : undefined}>
<Collapse in={!focused && !searchCritValue} orientation="horizontal">
<SearchIcon />
</Collapse>
<Trans>Advanced search query</Trans>
Expand All @@ -88,16 +86,16 @@ export const InventoryAdvanceSearchTextField = ({ hasError }: InventoryAdvanceSe
fullWidth
size="small"
inputProps={{ sx: { ml: 1 } }}
value={searchCritValueWithoutAll}
value={searchCritValue}
onChange={handleChange}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onReset={reset}
InputProps={{
startAdornment: focused || searchCritValueWithoutAll ? <SearchIcon /> : undefined,
startAdornment: focused || searchCritValue ? <SearchIcon /> : undefined,
endAdornment: (
<Stack direction="row" alignItems="center" mr={-1}>
{searchCritValueWithoutAll ? (
{searchCritValue ? (
<IconButton size="small" onClick={handleReset}>
<CloseIcon />
</IconButton>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/panel/inventory/InventoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function InventoryPage() {
const handleSetSearchCrit = useCallback(
(crit?: string) => {
const searchValues = getLocationSearchValues()
if (!crit || crit === 'all') {
if (!crit) {
setHasError(false)
delete searchValues['q']
} else {
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function InventoryPage() {
<NetworkErrorBoundary FallbackComponent={ErrorBoundaryFallback}>
<Outlet />
</NetworkErrorBoundary>
{searchCrit && (searchCrit !== 'all' || (hasChanges && history.changes.length) || hasError) ? (
{searchCrit || hasChanges || hasError ? (
<>
<NetworkErrorBoundary
fallbackRender={({ resetErrorBoundary }) => (
Expand Down
27 changes: 16 additions & 11 deletions src/pages/panel/inventory/inventory-form/InventoryFormAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { t } from '@lingui/macro'
// import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
// import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp'
import { useMemo, useState } from 'react'
import { useCallback, useMemo, useState } from 'react'
import { useFixQueryParser } from 'src/shared/fix-query-parser'
import { InventoryFormDefaultValue } from './InventoryFormDefaultValue'
import { InventoryFormField } from './InventoryFormField'
Expand Down Expand Up @@ -36,6 +36,20 @@ export const InventoryFormAccount = ({ preItems }: { preItems: AutoCompletePreDe
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(values), preItems.accounts])

const handleChange = useCallback(
(values: string[]) => {
if (isId) {
deleteCloudAccountRegion('account')
}
if (values) {
setCloudAccountRegion('account', 'in', values, true)
} else {
deleteCloudAccountRegion('account', true)
}
},
[deleteCloudAccountRegion, isId, setCloudAccountRegion],
)

return (
<>
<InventoryFormField
Expand All @@ -46,16 +60,7 @@ export const InventoryFormAccount = ({ preItems }: { preItems: AutoCompletePreDe
// endIcon={open ? <ArrowDropUpIcon fontSize="small" color="disabled" /> : <ArrowDropDownIcon fontSize="small" color="disabled" />}
/>
<InventoryFormDefaultValue
onChange={(values) => {
if (isId) {
deleteCloudAccountRegion('account')
}
if (values) {
setCloudAccountRegion('account', 'in', values, true)
} else {
deleteCloudAccountRegion('account', true)
}
}}
onChange={handleChange}
values={values}
label={t`Account`}
onClose={() => setOpen(null)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { t } from '@lingui/macro'
import { Stack, Typography } from '@mui/material'
import { useMemo } from 'react'
import { useCallback, useMemo } from 'react'
import { CloudAvatar } from 'src/shared/cloud-avatar'
import { useFixQueryParser } from 'src/shared/fix-query-parser'
import { InventoryFormDefaultValue } from './InventoryFormDefaultValue'
Expand Down Expand Up @@ -41,18 +41,23 @@ export const InventoryFormCloudValues = ({ preItems, onClose, open, values }: In
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(values), preItems.clouds])

const handleChange = useCallback(
(values: string[]) => {
if (isId) {
deleteCloudAccountRegion('cloud')
}
if (values) {
setCloudAccountRegion('cloud', 'in', values, true)
} else {
deleteCloudAccountRegion('cloud', true)
}
},
[deleteCloudAccountRegion, isId, setCloudAccountRegion],
)

return (
<InventoryFormDefaultValue
onChange={(values) => {
if (isId) {
deleteCloudAccountRegion('cloud')
}
if (values) {
setCloudAccountRegion('cloud', 'in', values, true)
} else {
deleteCloudAccountRegion('cloud', true)
}
}}
onChange={handleChange}
values={curValues}
label={t`Cloud`}
onClose={onClose}
Expand Down
Loading

0 comments on commit 826cc33

Please sign in to comment.