-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathindex.tsx
More file actions
82 lines (73 loc) · 2.58 KB
/
index.tsx
File metadata and controls
82 lines (73 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { useMemo } from 'react';
import { Content, Spinner, Title } from '@patternfly/react-core';
import { CustomizationLabels } from '@/Components/sharedComponents/CustomizationLabels';
import { usePlatform } from '@/context/platform';
import { useSearchLanguagePacks } from '@/store/api/contentSources';
import { useAppSelector } from '@/store/hooks';
import {
selectArchitecture,
selectDistribution,
selectLocaleLangpackCandidates,
selectVerifiedLocaleLangpacks,
} from '@/store/slices/wizard';
import KeyboardDropDown from './components/KeyboardDropDown';
import LanguagesDropDown from './components/LanguagesDropDown';
const LocaleStep = () => {
const {
queries: { useGetArchitecturesQuery },
} = usePlatform();
const distribution = useAppSelector(selectDistribution);
const arch = useAppSelector(selectArchitecture);
const candidateLangpacks = useAppSelector(selectLocaleLangpackCandidates);
const { data: distroRepositories, isLoading: isArchitecturesLoading } =
useGetArchitecturesQuery({
distribution: distribution,
});
const distroUrls = useMemo(() => {
return (
distroRepositories
?.find((archItem) => archItem.arch === arch)
?.repositories.filter((repo) => !!repo.baseurl)
.map((repo) => repo.baseurl!) ?? []
);
}, [distroRepositories, arch]);
const { isLoading: isSearchLoading } = useSearchLanguagePacks(distroUrls);
const verifiedLangpacks = useAppSelector(selectVerifiedLocaleLangpacks);
const isLoading =
candidateLangpacks.length > 0 &&
(isArchitecturesLoading || isSearchLoading);
return (
<>
<CustomizationLabels customization='locale' />
<Content>
<Title headingLevel='h2' size='lg'>
Locale
</Title>
<Content component='small'>
Define the primary languages and keyboard settings for your image to
ensure proper system localization and user interface support.
</Content>
</Content>
<LanguagesDropDown />
{isLoading && (
<Content>
<Spinner size='md' /> Resolving packages for your preferred locale…
</Content>
)}
{!isLoading && verifiedLangpacks.length > 0 && (
<Content>
The following packages will be added based on your preferred locale:{' '}
{verifiedLangpacks.map((pkg, idx) => (
<strong key={pkg}>
{pkg}
{idx < verifiedLangpacks.length - 1 ? ', ' : ''}
</strong>
))}
.
</Content>
)}
<KeyboardDropDown />
</>
);
};
export default LocaleStep;