Skip to content

Commit a001f81

Browse files
committed
RepoSelector - remove Select logic, just show current repo
1 parent 6d869ee commit a001f81

File tree

4 files changed

+21
-76
lines changed

4 files changed

+21
-76
lines changed

src/components/headers/collection-header.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,7 @@ export class CollectionHeader extends React.Component<IProps, IState> {
415415
)
416416
}
417417
contextSelector={
418-
<RepoSelector
419-
selectedRepo={collection.repository.name}
420-
isDisabled
421-
/>
418+
<RepoSelector selectedRepo={collection.repository.name} />
422419
}
423420
breadcrumbs={<Breadcrumbs links={breadcrumbs} />}
424421
versionControl={

src/components/repo-selector/repo-selector.scss

-3
This file was deleted.

src/components/repo-selector/repo-selector.tsx

+20-62
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,44 @@
1-
import { i18n } from '@lingui/core';
21
import { t } from '@lingui/macro';
32
import {
43
Flex,
54
FlexItem,
65
InputGroup,
76
InputGroupText,
8-
Select,
9-
SelectOption,
107
} 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';
169

1710
interface IProps {
1811
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;
2412
}
2513

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;
4124

4225
return (
4326
<Flex>
4427
<FlexItem>
4528
<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'>
5130
{t`Repository`}
5231
</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',
7138
}}
72-
onToggle={(isExpanded) => setSelectExpanded(isExpanded)}
73-
selections={getRepoName(selectedRepo)}
74-
variant='single'
7539
>
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>
8442
</InputGroup>
8543
</FlexItem>
8644
</Flex>

src/constants.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ export class Constants {
2828
'galaxy.add_group',
2929
];
3030

31-
static REPOSITORYNAMES = {
32-
published: defineMessage({ message: `Published` }),
33-
'rh-certified': defineMessage({ message: `Red Hat Certified` }),
34-
community: defineMessage({ message: `Community` }),
35-
validated: defineMessage({ message: `Validated` }),
36-
};
37-
3831
static PROTECTED_REPOSITORIES = [
3932
'rh-certified',
4033
'validated',

0 commit comments

Comments
 (0)