Skip to content

Commit 67e6e97

Browse files
authored
Use display_repositories feature flag (ansible#3558)
* FeatureFlagsType: add ai_deny_index, display_repositories * Use display_repositories feature flag without it: hide repo link in collections view, hide repo selector, hide menu item with it: show menu item in anonymous mode too No-Issue * view-only tests - run with more community feature flags
1 parent 9610edb commit 67e6e97

File tree

11 files changed

+89
-68
lines changed

11 files changed

+89
-68
lines changed
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
export class FeatureFlagsType {
2-
// execution environments menu section
2+
// execution environments
3+
container_signing: boolean;
34
execution_environments: boolean;
45

56
// keycloak login screen
67
external_authentication: boolean;
78

8-
// community version
9+
// community mode
10+
ai_deny_index: boolean;
11+
display_repositories: boolean;
912
legacy_roles: boolean;
1013

1114
// collection signing
@@ -17,9 +20,6 @@ export class FeatureFlagsType {
1720
require_upload_signatures: boolean;
1821
signatures_enabled: boolean;
1922

20-
// container signing (EE)
21-
container_signing: boolean;
22-
2323
// errors
2424
_messages: string[];
2525
}

src/components/cards/collection-card.tsx

+19-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Link } from 'react-router-dom';
1616
import { CollectionVersionSearch } from 'src/api';
1717
import { CollectionNumericLabel, Logo, SignatureBadge } from 'src/components';
1818
import { Constants } from 'src/constants';
19+
import { useContext } from 'src/loaders/app-context';
1920
import { Paths, formatPath } from 'src/paths';
2021
import { convertContentSummaryCounts } from 'src/utilities';
2122

@@ -36,6 +37,7 @@ export const CollectionCard = ({
3637
menu,
3738
footer,
3839
}: IProps) => {
40+
const { featureFlags } = useContext();
3941
const MAX_DESCRIPTION_LENGTH = 60;
4042

4143
const company = namespace?.company || collection_version.namespace;
@@ -53,21 +55,23 @@ export const CollectionCard = ({
5355
flexGrow
5456
/>
5557
<div className='card-badge-area'>
56-
<TextContent>
57-
<Text component={TextVariants.small}>
58-
<Badge isRead>
59-
<Link
60-
to={formatPath(Paths.ansibleRepositoryDetail, {
61-
name: repository.name,
62-
})}
63-
>
64-
{repository.name === Constants.CERTIFIED_REPO
65-
? t`Certified`
66-
: repository.name}
67-
</Link>
68-
</Badge>
69-
</Text>
70-
</TextContent>
58+
{featureFlags.display_repositories ? (
59+
<TextContent>
60+
<Text component={TextVariants.small}>
61+
<Badge isRead>
62+
<Link
63+
to={formatPath(Paths.ansibleRepositoryDetail, {
64+
name: repository.name,
65+
})}
66+
>
67+
{repository.name === Constants.CERTIFIED_REPO
68+
? t`Certified`
69+
: repository.name}
70+
</Link>
71+
</Badge>
72+
</Text>
73+
</TextContent>
74+
) : null}
7175
{displaySignatures ? (
7276
<SignatureBadge
7377
isCompact

src/components/collection-list/collection-list-item.tsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
Logo,
2323
Tag,
2424
} from 'src/components';
25+
import { useContext } from 'src/loaders/app-context';
2526
import { Paths, formatPath } from 'src/paths';
2627
import { chipGroupProps, convertContentSummaryCounts } from 'src/utilities';
2728
import { SignatureBadge } from '../signing';
@@ -50,6 +51,7 @@ export const CollectionListItem = ({
5051
synclistSwitch,
5152
uploadButton,
5253
}: IProps) => {
54+
const { featureFlags } = useContext();
5355
const cells = [];
5456

5557
const company = namespace?.company || collection_version.namespace;
@@ -152,17 +154,19 @@ export const CollectionListItem = ({
152154
direction={{ default: 'row' }}
153155
alignSelf={{ default: 'alignSelfFlexStart' }}
154156
>
155-
<FlexItem>
156-
<Label variant='outline'>
157-
<Link
158-
to={formatPath(Paths.ansibleRepositoryDetail, {
159-
name: repository.name,
160-
})}
161-
>
162-
{repository.name}
163-
</Link>
164-
</Label>
165-
</FlexItem>
157+
{featureFlags.display_repositories ? (
158+
<FlexItem>
159+
<Label variant='outline'>
160+
<Link
161+
to={formatPath(Paths.ansibleRepositoryDetail, {
162+
name: repository.name,
163+
})}
164+
>
165+
{repository.name}
166+
</Link>
167+
</Label>
168+
</FlexItem>
169+
) : null}
166170
{displaySignatures ? (
167171
<FlexItem>
168172
<SignatureBadge

src/components/headers/base-header.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Title } from '@patternfly/react-core';
22
import cx from 'classnames';
33
import * as React from 'react';
4-
import { Constants } from 'src/constants';
54
import './header.scss';
65

76
interface IProps {
@@ -30,18 +29,13 @@ export class BaseHeader extends React.Component<IProps> {
3029
status,
3130
} = this.props;
3231

33-
const showRepoSelector =
34-
contextSelector && DEPLOYMENT_MODE !== Constants.INSIGHTS_DEPLOYMENT_MODE;
35-
3632
return (
3733
<div className={cx('background', className)}>
38-
{showRepoSelector && (
39-
<div className='breadcrumb-container'>{contextSelector}</div>
40-
)}
34+
{contextSelector || null}
4135
{breadcrumbs && (
4236
<div className='breadcrumb-container'>{breadcrumbs}</div>
4337
)}
44-
{!breadcrumbs && !showRepoSelector && <div className='placeholder' />}
38+
{!breadcrumbs && !contextSelector && <div className='placeholder' />}
4539

4640
<div className='column-section'>
4741
<div className='title-box'>

src/components/headers/partner-header.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ interface IProps {
2020
updateParams: (p) => void;
2121

2222
pageControls?: React.ReactNode;
23-
contextSelector?: React.ReactNode;
2423
filters?: React.ReactNode;
2524
}
2625

2726
export class PartnerHeader extends React.Component<IProps> {
2827
render() {
2928
const {
3029
breadcrumbs,
31-
contextSelector,
3230
filters,
3331
namespace,
3432
pageControls,
@@ -56,7 +54,6 @@ export class PartnerHeader extends React.Component<IProps> {
5654
}
5755
breadcrumbs={<Breadcrumbs links={breadcrumbs} />}
5856
pageControls={pageControls}
59-
contextSelector={contextSelector}
6057
className='header'
6158
>
6259
{namespace.description ? <div>{namespace.description}</div> : null}

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

+32-19
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ import {
66
InputGroupText,
77
} from '@patternfly/react-core';
88
import React from 'react';
9+
import { Constants } from 'src/constants';
10+
import { useContext } from 'src/loaders/app-context';
911

1012
interface IProps {
1113
selectedRepo: string;
1214
}
1315

1416
export const RepoSelector = ({ selectedRepo }: IProps) => {
17+
const { featureFlags } = useContext();
18+
19+
if (DEPLOYMENT_MODE === Constants.INSIGHTS_DEPLOYMENT_MODE) {
20+
return null;
21+
}
22+
if (!featureFlags.display_repositories) {
23+
return null;
24+
}
25+
1526
const repoName =
1627
{
1728
community: t`Community`,
@@ -23,24 +34,26 @@ export const RepoSelector = ({ selectedRepo }: IProps) => {
2334
}[selectedRepo] || selectedRepo;
2435

2536
return (
26-
<Flex>
27-
<FlexItem>
28-
<InputGroup>
29-
<InputGroupText style={{ paddingLeft: 0 }} variant='plain'>
30-
{t`Repository`}
31-
</InputGroupText>
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',
38-
}}
39-
>
40-
{repoName}
41-
</InputGroupText>
42-
</InputGroup>
43-
</FlexItem>
44-
</Flex>
37+
<div className='breadcrumb-container'>
38+
<Flex>
39+
<FlexItem>
40+
<InputGroup>
41+
<InputGroupText style={{ paddingLeft: 0 }} variant='plain'>
42+
{t`Repository`}
43+
</InputGroupText>
44+
<InputGroupText
45+
variant='plain'
46+
style={{
47+
backgroundColor: 'var(--pf-global--disabled-color--300)',
48+
color: 'var(--pf-global--Color--100)',
49+
height: '36px',
50+
}}
51+
>
52+
{repoName}
53+
</InputGroupText>
54+
</InputGroup>
55+
</FlexItem>
56+
</Flex>
57+
</div>
4558
);
4659
};

src/containers/ansible-remote/tab-access.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ interface TabProps {
1616
item: AnsibleRemoteType;
1717
actionContext: {
1818
addAlert: (alert) => void;
19-
state: { params };
19+
featureFlags;
2020
hasPermission;
21+
state: { params };
2122
user;
2223
};
2324
}
@@ -26,8 +27,9 @@ export const RemoteAccessTab = ({
2627
item,
2728
actionContext: {
2829
addAlert,
29-
state: { params },
30+
featureFlags,
3031
hasPermission,
32+
state: { params },
3133
user,
3234
},
3335
}: TabProps) => {
@@ -57,6 +59,7 @@ export const RemoteAccessTab = ({
5759
hasObjectPermission: (p: string): boolean =>
5860
permissions.includes(p),
5961
user,
62+
featureFlags,
6063
}),
6164
);
6265
AnsibleRemoteAPI.listRoles(id)

src/containers/ansible-repository/tab-access.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ interface TabProps {
1616
item: AnsibleRepositoryType;
1717
actionContext: {
1818
addAlert: (alert) => void;
19-
state: { params };
19+
featureFlags;
2020
hasPermission;
21+
state: { params };
2122
user;
2223
};
2324
}
@@ -26,8 +27,9 @@ export const RepositoryAccessTab = ({
2627
item,
2728
actionContext: {
2829
addAlert,
29-
state: { params },
30+
featureFlags,
3031
hasPermission,
32+
state: { params },
3133
user,
3234
},
3335
}: TabProps) => {
@@ -57,6 +59,7 @@ export const RepositoryAccessTab = ({
5759
hasObjectPermission: (p: string): boolean =>
5860
permissions.includes(p),
5961
user,
62+
featureFlags,
6063
}),
6164
);
6265
AnsibleRepositoryAPI.listRoles(id)

src/permissions.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FeatureFlagsType, SettingsType, UserType } from 'src/api';
22

33
export type PermissionContextType = (
44
o: {
5-
featureFlags?: FeatureFlagsType;
5+
featureFlags: FeatureFlagsType;
66
settings?: SettingsType;
77
user: UserType;
88
hasPermission: (string) => boolean;
@@ -54,8 +54,9 @@ export const canEditAnsibleRepository = has_model_or_obj_perms(
5454
'ansible.change_ansiblerepository',
5555
);
5656
export const canSyncAnsibleRepository = canEditAnsibleRepository;
57-
// everybody can list/view, not has_model_or_obj_perms('ansible.view_ansiblerepository')
58-
export const canViewAnsibleRepositories = isLoggedIn;
57+
// everybody can list/view, not has_model_or_obj_perms('ansible.view_ansiblerepository'); under feature flag
58+
export const canViewAnsibleRepositories = ({ user, featureFlags }) =>
59+
user && featureFlags?.display_repositories;
5960
export const canEditAnsibleRepositoryAccess = has_model_or_obj_perms(
6061
'ansible.manage_roles_ansiblerepository',
6162
);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_ACCESS='true'
22
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_DOWNLOAD='false'
33
PULP_GALAXY_REQUIRE_CONTENT_APPROVAL='false'
4+
PULP_GALAXY_FEATURE_FLAGS__display_repositories=false
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_ACCESS='true'
22
PULP_GALAXY_ENABLE_UNAUTHENTICATED_COLLECTION_DOWNLOAD='true'
33
PULP_GALAXY_REQUIRE_CONTENT_APPROVAL='false'
4+
PULP_GALAXY_FEATURE_FLAGS__display_repositories=false

0 commit comments

Comments
 (0)