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

fix(ui/ingest): ingest tab should show with manage ingestion privilege #10483

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
16 changes: 13 additions & 3 deletions datahub-web-react/src/app/ingest/ManageIngestionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Tabs, Typography } from 'antd';
import React, { useState } from 'react';
import styled from 'styled-components';
import { IngestionSourceList } from './source/IngestionSourceList';
import { useAppConfig } from '../useAppConfig';
import { useUserContext } from '../context/useUserContext';
import { SecretsList } from './secret/SecretsList';
import { OnboardingTour } from '../onboarding/OnboardingTour';
import {
Expand Down Expand Up @@ -48,7 +50,15 @@ export const ManageIngestionPage = () => {
/**
* Determines which view should be visible: ingestion sources or secrets.
*/
const [selectedTab, setSelectedTab] = useState<TabType>(TabType.Sources);
const me = useUserContext();
const { config } = useAppConfig();
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
const showIngestionTab =
isIngestionEnabled && me && me.platformPrivileges?.manageIngestion;
const showSecretsTab =
isIngestionEnabled && me && me.platformPrivileges?.manageSecrets;
const defaultTab = showIngestionTab ? TabType.Sources : TabType.Secrets;
const [selectedTab, setSelectedTab] = useState<TabType>(defaultTab);

const onClickTab = (newTab: string) => {
setSelectedTab(TabType[newTab]);
Expand All @@ -64,8 +74,8 @@ export const ManageIngestionPage = () => {
</Typography.Paragraph>
</PageHeaderContainer>
<StyledTabs activeKey={selectedTab} size="large" onTabClick={(tab: string) => onClickTab(tab)}>
<Tab key={TabType.Sources} tab={TabType.Sources} />
<Tab key={TabType.Secrets} tab={TabType.Secrets} />
{showIngestionTab && <Tab key={TabType.Sources} tab={TabType.Sources} />}
{showSecretsTab && <Tab key={TabType.Secrets} tab={TabType.Secrets} />}
</StyledTabs>
<ListContainer>{selectedTab === TabType.Sources ? <IngestionSourceList /> : <SecretsList />}</ListContainer>
</PageContainer>
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/app/ingest/secret/SecretsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const SecretsList = () => {
{
urn: res.data?.createSecret || '',
name: state.name,
description: state.description,
description: state.description || '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!!!

},
client,
pageSize,
Expand All @@ -127,7 +127,7 @@ export const SecretsList = () => {
.catch((e) => {
message.destroy();
message.error({
content: `Failed to update ingestion source!: \n ${e.message || ''}`,
content: `Failed to update secret!: \n ${e.message || ''}`,
duration: 3,
});
});
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/shared/admin/HeaderLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function HeaderLinks(props: Props) {
const showAnalytics = (isAnalyticsEnabled && me && me?.platformPrivileges?.viewAnalytics) || false;
const showSettings = true;
const showIngestion =
isIngestionEnabled && me && me.platformPrivileges?.manageIngestion && me.platformPrivileges?.manageSecrets;
isIngestionEnabled && me && (me.platformPrivileges?.manageIngestion || me.platformPrivileges?.manageSecrets);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice work - thank you!


useToggleEducationStepIdsAllowList(!!showIngestion, HOME_PAGE_INGESTION_ID);

Expand Down
Loading