mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
ui: Hide organization settings when user is not admin (PROJQUAY-4053) (#1829)
- Remove organization settings when user not admin
This commit is contained in:
@@ -15,6 +15,7 @@ export interface IOrganization {
|
||||
can_create_repo?: boolean;
|
||||
public?: boolean;
|
||||
is_org_admin?: boolean;
|
||||
is_admin?: boolean;
|
||||
preferred_namespace?: boolean;
|
||||
teams?: string[];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {useCallback, useState} from 'react';
|
||||
import RepositoriesList from 'src/routes/RepositoriesList/RepositoriesList';
|
||||
import Settings from './Tabs/Settings/Settings';
|
||||
import {QuayBreadcrumb} from 'src/components/breadcrumb/Breadcrumb';
|
||||
import { useOrganization } from 'src/hooks/UseOrganization';
|
||||
import RobotAccountsList from 'src/routes/RepositoriesList/RobotAccountsList';
|
||||
|
||||
export default function Organization() {
|
||||
@@ -19,6 +20,8 @@ export default function Organization() {
|
||||
const {organizationName} = useParams();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
const {organization} = useOrganization(orgName)
|
||||
|
||||
const [activeTabKey, setActiveTabKey] = useState<string>(
|
||||
searchParams.get('tab') || 'Repositories',
|
||||
);
|
||||
@@ -35,14 +38,18 @@ export default function Organization() {
|
||||
{
|
||||
name: 'Repositories',
|
||||
component: <RepositoriesList organizationName={organizationName} />,
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
name: 'Robot accounts',
|
||||
component: <RobotAccountsList organizationName={organizationName} />,
|
||||
visible: organization.is_org_admin || organization.is_admin,
|
||||
|
||||
},
|
||||
{
|
||||
name: 'Settings',
|
||||
component: <Settings organizationName={organizationName} />,
|
||||
visible: organization.is_org_admin || organization.is_admin,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -62,15 +69,17 @@ export default function Organization() {
|
||||
padding={{default: 'noPadding'}}
|
||||
>
|
||||
<Tabs activeKey={activeTabKey} onSelect={onTabSelect}>
|
||||
{repositoriesSubNav.map((nav) => (
|
||||
<Tab
|
||||
key={nav.name}
|
||||
eventKey={nav.name}
|
||||
title={<TabTitleText>{nav.name}</TabTitleText>}
|
||||
>
|
||||
{nav.component}
|
||||
</Tab>
|
||||
))}
|
||||
{repositoriesSubNav.map((nav) => {
|
||||
nav.visible && (
|
||||
<Tab
|
||||
key={nav.name}
|
||||
eventKey={nav.name}
|
||||
title={<TabTitleText>{nav.name}</TabTitleText>}
|
||||
>
|
||||
{nav.component}
|
||||
</Tab>
|
||||
);
|
||||
})}
|
||||
</Tabs>
|
||||
</PageSection>
|
||||
</Page>
|
||||
|
||||
Reference in New Issue
Block a user