|
1 |
| -import { i18n } from '@lingui/core'; |
2 | 1 | import { t } from '@lingui/macro';
|
3 | 2 | import {
|
4 | 3 | Flex,
|
5 | 4 | FlexItem,
|
6 | 5 | InputGroup,
|
7 | 6 | InputGroupText,
|
8 |
| - Select, |
9 |
| - SelectOption, |
10 | 7 | } from '@patternfly/react-core';
|
11 |
| -import React, { useState } from 'react'; |
12 |
| -import { useNavigate } from 'react-router-dom'; |
13 |
| -import { Constants } from 'src/constants'; |
14 |
| -import { Paths, formatPath } from 'src/paths'; |
15 |
| -import './repo-selector.scss'; |
| 8 | +import React from 'react'; |
16 | 9 |
|
17 | 10 | interface IProps {
|
18 | 11 | selectedRepo: string;
|
19 |
| - // Path of the component that's using the component. This is required so that |
20 |
| - // the url for the repo can be updated correctly. |
21 |
| - path?: Paths; |
22 |
| - pathParams?: Record<string, string>; |
23 |
| - isDisabled?: boolean; |
24 | 12 | }
|
25 | 13 |
|
26 |
| -export const RepoSelector = ({ |
27 |
| - selectedRepo, |
28 |
| - path, |
29 |
| - pathParams, |
30 |
| - isDisabled, |
31 |
| -}: IProps) => { |
32 |
| - const [selectExpanded, setSelectExpanded] = useState<boolean>(false); |
33 |
| - const navigate = useNavigate(); |
34 |
| - |
35 |
| - const getRepoName = (repoName) => { |
36 |
| - const repo = Constants.REPOSITORYNAMES[repoName]; |
37 |
| - return repo ? i18n._(repo) : repoName; |
38 |
| - }; |
39 |
| - |
40 |
| - const repoNames = Constants.REPOSITORYNAMES; |
| 14 | +export const RepoSelector = ({ selectedRepo }: IProps) => { |
| 15 | + const repoName = |
| 16 | + { |
| 17 | + community: t`Community`, |
| 18 | + published: t`Published`, |
| 19 | + rejected: t`Rejected`, |
| 20 | + 'rh-certified': t`Red Hat Certified`, |
| 21 | + staging: t`Staging`, |
| 22 | + validated: t`Validated`, |
| 23 | + }[selectedRepo] || selectedRepo; |
41 | 24 |
|
42 | 25 | return (
|
43 | 26 | <Flex>
|
44 | 27 | <FlexItem>
|
45 | 28 | <InputGroup>
|
46 |
| - <InputGroupText |
47 |
| - style={{ paddingLeft: 0 }} |
48 |
| - variant='plain' |
49 |
| - className='hub-input-group-text-no-wrap' |
50 |
| - > |
| 29 | + <InputGroupText style={{ paddingLeft: 0 }} variant='plain'> |
51 | 30 | {t`Repository`}
|
52 | 31 | </InputGroupText>
|
53 |
| - <Select |
54 |
| - className='nav-select' |
55 |
| - isDisabled={!path || isDisabled} |
56 |
| - isOpen={selectExpanded} |
57 |
| - isPlain={false} |
58 |
| - onSelect={(event: React.ChangeEvent<HTMLInputElement>) => { |
59 |
| - const originalRepo = selectedRepo; |
60 |
| - const newRepo = getRepoName(event.target.name); |
61 |
| - |
62 |
| - setSelectExpanded(false); |
63 |
| - |
64 |
| - if (newRepo !== originalRepo) { |
65 |
| - const newPath = formatPath(path, { |
66 |
| - ...pathParams, |
67 |
| - repo: event.target.name, |
68 |
| - }); |
69 |
| - navigate(newPath); |
70 |
| - } |
| 32 | + <InputGroupText |
| 33 | + variant='plain' |
| 34 | + style={{ |
| 35 | + backgroundColor: 'var(--pf-global--disabled-color--300)', |
| 36 | + color: 'var(--pf-global--Color--100)', |
| 37 | + height: '36px', |
71 | 38 | }}
|
72 |
| - onToggle={(isExpanded) => setSelectExpanded(isExpanded)} |
73 |
| - selections={getRepoName(selectedRepo)} |
74 |
| - variant='single' |
75 | 39 | >
|
76 |
| - {Object.keys(repoNames).map((option) => ( |
77 |
| - <SelectOption |
78 |
| - name={option} |
79 |
| - key={option} |
80 |
| - value={i18n._(repoNames[option])} |
81 |
| - /> |
82 |
| - ))} |
83 |
| - </Select> |
| 40 | + {repoName} |
| 41 | + </InputGroupText> |
84 | 42 | </InputGroup>
|
85 | 43 | </FlexItem>
|
86 | 44 | </Flex>
|
|
0 commit comments