Skip to content

Commit

Permalink
Hides RH repo when snapshots not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar committed Dec 11, 2023
1 parent df78bfc commit da3dff8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/Pages/ContentListTable/ContentListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const ContentListTable = () => {
});

const setOriginAndSearchParams = (origin: ContentOrigin) => {
if (!features?.snapshots?.accessible) return;
setContentOrigin(origin);
setUrlSearchParams(origin === ContentOrigin.EXTERNAL ? {} : { origin });
};
Expand Down
60 changes: 31 additions & 29 deletions src/Pages/ContentListTable/components/ContentListFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const ContentListFilters = ({
contentOrigin,
}: Props) => {
const classes = useStyles();
const { rbac } = useAppContext();
const { rbac, features } = useAppContext();
const queryClient = useQueryClient();
const navigate = useNavigate();
const filters = ['Name/URL', 'Version', 'Architecture', 'Status'];
Expand Down Expand Up @@ -272,34 +272,36 @@ const ContentListFilters = ({
</InputGroupItem>
</InputGroup>
</FlexItem>
<FlexItem>
<ToggleGroup aria-label='Default with single selectable'>
<ToggleGroupItem
text='Custom'
buttonId='custom-repositories-toggle-button'
data-ouia-component-id='custom-repositories-toggle'
isSelected={contentOrigin === ContentOrigin.EXTERNAL}
onChange={() => {
if (contentOrigin !== ContentOrigin.EXTERNAL) {
setContentOrigin(ContentOrigin.EXTERNAL);
// clearFilters(); //This resets the filters when changing Origins if desired.
}
}}
/>
<ToggleGroupItem
text='Red Hat'
buttonId='redhat-repositories-toggle-button'
data-ouia-component-id='redhat-repositories-toggle'
isSelected={contentOrigin === ContentOrigin.REDHAT}
onChange={() => {
if (contentOrigin !== ContentOrigin.REDHAT) {
setContentOrigin(ContentOrigin.REDHAT);
// clearFilters();//This resets the filters when changing Origins if desired.
}
}}
/>
</ToggleGroup>
</FlexItem>
<Hide hide={!features?.snapshots?.accessible}>
<FlexItem>
<ToggleGroup aria-label='Default with single selectable'>
<ToggleGroupItem
text='Custom'
buttonId='custom-repositories-toggle-button'
data-ouia-component-id='custom-repositories-toggle'
isSelected={contentOrigin === ContentOrigin.EXTERNAL}
onChange={() => {
if (contentOrigin !== ContentOrigin.EXTERNAL) {
setContentOrigin(ContentOrigin.EXTERNAL);
// clearFilters(); //This resets the filters when changing Origins if desired.
}
}}
/>
<ToggleGroupItem
text='Red Hat'
buttonId='redhat-repositories-toggle-button'
data-ouia-component-id='redhat-repositories-toggle'
isSelected={contentOrigin === ContentOrigin.REDHAT}
onChange={() => {
if (contentOrigin !== ContentOrigin.REDHAT) {
setContentOrigin(ContentOrigin.REDHAT);
// clearFilters();//This resets the filters when changing Origins if desired.
}
}}
/>
</ToggleGroup>
</FlexItem>
</Hide>
<FlexItem className={classes.repositoryActions}>
<ConditionalTooltip
content='You do not have the required permissions to perform this action.'
Expand Down

0 comments on commit da3dff8

Please sign in to comment.