Skip to content

Commit

Permalink
Hide "Sync your account with existing owner" with no authentication m…
Browse files Browse the repository at this point in the history
…ethod configured (#1626)

Co-authored-by: vburlachenko <[email protected]>
Co-authored-by: ayemets-corcentric <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2024
1 parent bbcea54 commit e44f37e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package org.opendatadiscovery.oddplatform.controller;

import lombok.RequiredArgsConstructor;
import org.opendatadiscovery.oddplatform.api.contract.api.AppInfoApi;
import org.opendatadiscovery.oddplatform.api.contract.model.AppInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.BuildProperties;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@RestController
@RequiredArgsConstructor
public class AppInfoController implements AppInfoApi {
private final BuildProperties buildProperties;
private final String authType;

public AppInfoController(final BuildProperties buildProperties,
@Value("${auth.type}") final String authType) {
this.buildProperties = buildProperties;
this.authType = authType;
}

@Override
public Mono<ResponseEntity<AppInfo>> getAppInfo(final ServerWebExchange exchange) {
return Mono.just(new AppInfo().projectVersion(buildProperties.getVersion()))
return Mono.just(new AppInfo()
.projectVersion(buildProperties.getVersion())
.authType(authType))
.map(ResponseEntity::ok);
}
}
2 changes: 2 additions & 0 deletions odd-platform-specification/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,8 @@ components:
properties:
projectVersion:
type: string
authType:
type: string

LinkedTerm:
type: object
Expand Down
21 changes: 13 additions & 8 deletions odd-platform-ui/src/components/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MainSearch, SkeletonWrapper } from 'components/shared/elements';
import { WithPermissionsProvider } from 'components/shared/contexts';
import { Permission } from 'generated-sources';
import { useAppSelector } from 'redux/lib/hooks';
import { useAppInfo } from 'lib/hooks/api';
import Domains from 'components/Overview/Domains/Domains';
import { useGetPopularTags } from 'lib/hooks/api/tags';
import DataEntitiesUsageInfo from './DataEntitiesUsageInfo/DataEntitiesUsageInfo';
Expand All @@ -20,6 +21,10 @@ const Overview: React.FC = () => {
page: 1,
size: 30,
});
const { data: appInfo } = useAppInfo();
const isShowOwnerAssociation = Boolean(
appInfo?.authType && appInfo.authType !== 'DISABLED'
);

const isLoading = React.useMemo(
() => isIdentityFetching || isTagsFetching,
Expand All @@ -41,17 +46,17 @@ const Overview: React.FC = () => {
<Grid container justifyContent='center' sx={{ pt: 4, pb: 5 }}>
<MainSearch mainSearch />
</Grid>
<S.TagsContainer container>
{tags ? <TopTagsList tags={tags} /> : null}
</S.TagsContainer>
<S.TagsContainer container>{tags && <TopTagsList tags={tags} />}</S.TagsContainer>
<Domains />
<DataEntitiesUsageInfo />
<Directory />
<WithPermissionsProvider
allowedPermissions={[Permission.DIRECT_OWNER_SYNC]}
resourcePermissions={[]}
Component={OwnerAssociation}
/>
{isShowOwnerAssociation && (
<WithPermissionsProvider
allowedPermissions={[Permission.DIRECT_OWNER_SYNC]}
resourcePermissions={[]}
Component={OwnerAssociation}
/>
)}
</S.Container>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as S from 'components/shared/elements/AppToolbar/AppInfoMenu/AppInfoMen
import Button from 'components/shared/elements/Button/Button';

const AppInfoMenu: React.FC = () => {
const { data: version } = useAppInfo();
const { data: appInfo } = useAppInfo();
const { data: links } = useAppLinks();

const gitbookLink = 'https://docs.opendatadiscovery.org/';
Expand All @@ -35,7 +35,7 @@ const AppInfoMenu: React.FC = () => {
};

const projectVersion = React.useMemo(() => {
if (!version) return null;
if (!appInfo?.projectVersion) return null;

return (
<Link to={githubLink} target='_blank'>
Expand All @@ -44,13 +44,13 @@ const AppInfoMenu: React.FC = () => {
<GitHubIcon />
</S.Icon>
<Grid container flexDirection='column'>
<Typography variant='h4'>{version}</Typography>
<Typography variant='h4'>{appInfo.projectVersion}</Typography>
<Typography variant='subtitle1'>ODD Platform version</Typography>
</Grid>
</S.MenuItem>
</Link>
);
}, [version]);
}, [appInfo?.projectVersion]);

const projectLinks = React.useMemo(() => {
if (!links || links.length === 0) return null;
Expand Down
1 change: 0 additions & 1 deletion odd-platform-ui/src/lib/hooks/api/appInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export function useAppInfo() {
return useQuery({
queryKey: ['appInfo'],
queryFn: () => appInfoApi.getAppInfo(),
select: data => data.projectVersion,
});
}

Expand Down

0 comments on commit e44f37e

Please sign in to comment.