Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide "Sync your account with existing owner" with no authentication method configured #1626

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
);
Comment on lines +25 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's a good practice to use useMemo hook for that types of variables but it's not necessary in that particular case. And it seems we don't need data type coercion here

Suggested change
const isShowOwnerAssociation = Boolean(
appInfo?.authType && appInfo.authType !== 'DISABLED'
);
const isShowOwnerAssociation = useMemo(() =>
appInfo?.authType && appInfo.authType !== 'DISABLED',
[appInfo?.authType])


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
Loading