2022-01-27 10:33:12 -08:00
|
|
|
import { Tabs, Typography } from 'antd';
|
2024-07-26 11:10:13 -07:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2022-01-27 10:33:12 -08:00
|
|
|
import styled from 'styled-components';
|
|
|
|
import { IngestionSourceList } from './source/IngestionSourceList';
|
2024-07-22 20:25:12 +05:30
|
|
|
import { useAppConfig } from '../useAppConfig';
|
|
|
|
import { useUserContext } from '../context/useUserContext';
|
2022-01-27 10:33:12 -08:00
|
|
|
import { SecretsList } from './secret/SecretsList';
|
2022-12-07 16:21:55 -08:00
|
|
|
import { OnboardingTour } from '../onboarding/OnboardingTour';
|
|
|
|
import {
|
|
|
|
INGESTION_CREATE_SOURCE_ID,
|
|
|
|
INGESTION_REFRESH_SOURCES_ID,
|
|
|
|
} from '../onboarding/config/IngestionOnboardingConfig';
|
2025-01-29 20:42:01 -05:00
|
|
|
import { useShowNavBarRedesign } from '../useShowNavBarRedesign';
|
2022-01-27 10:33:12 -08:00
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
const PageContainer = styled.div<{ $isShowNavBarRedesign?: boolean }>`
|
2022-01-27 10:33:12 -08:00
|
|
|
padding-top: 20px;
|
2025-01-29 20:42:01 -05:00
|
|
|
background-color: white;
|
|
|
|
border-radius: ${(props) =>
|
|
|
|
props.$isShowNavBarRedesign ? props.theme.styles['border-radius-navbar-redesign'] : '8px'};
|
|
|
|
${(props) =>
|
|
|
|
props.$isShowNavBarRedesign &&
|
|
|
|
`
|
|
|
|
overflow: hidden;
|
|
|
|
margin: 5px;
|
|
|
|
box-shadow: ${props.theme.styles['box-shadow-navbar-redesign']};
|
|
|
|
height: 100%;
|
|
|
|
`}
|
2022-01-27 10:33:12 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const PageHeaderContainer = styled.div`
|
|
|
|
&& {
|
|
|
|
padding-left: 24px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const PageTitle = styled(Typography.Title)`
|
|
|
|
&& {
|
|
|
|
margin-bottom: 12px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledTabs = styled(Tabs)`
|
|
|
|
&&& .ant-tabs-nav {
|
|
|
|
margin-bottom: 0;
|
|
|
|
padding-left: 28px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Tab = styled(Tabs.TabPane)`
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 22px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ListContainer = styled.div``;
|
|
|
|
|
|
|
|
enum TabType {
|
|
|
|
Sources = 'Sources',
|
|
|
|
Secrets = 'Secrets',
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ManageIngestionPage = () => {
|
|
|
|
/**
|
|
|
|
* Determines which view should be visible: ingestion sources or secrets.
|
|
|
|
*/
|
2024-07-22 20:25:12 +05:30
|
|
|
const me = useUserContext();
|
2024-07-26 11:10:13 -07:00
|
|
|
const { config, loaded } = useAppConfig();
|
2024-12-12 20:49:25 +05:30
|
|
|
const isIngestionEnabled = config?.managedIngestionConfig?.enabled;
|
2024-07-22 20:25:12 +05:30
|
|
|
const showIngestionTab = isIngestionEnabled && me && me.platformPrivileges?.manageIngestion;
|
|
|
|
const showSecretsTab = isIngestionEnabled && me && me.platformPrivileges?.manageSecrets;
|
2024-07-26 11:10:13 -07:00
|
|
|
const [selectedTab, setSelectedTab] = useState<TabType>(TabType.Sources);
|
2025-01-29 20:42:01 -05:00
|
|
|
const isShowNavBarRedesign = useShowNavBarRedesign();
|
2024-07-26 11:10:13 -07:00
|
|
|
|
|
|
|
// defaultTab might not be calculated correctly on mount, if `config` or `me` haven't been loaded yet
|
|
|
|
useEffect(() => {
|
|
|
|
if (loaded && me.loaded && !showIngestionTab && selectedTab === TabType.Sources) {
|
|
|
|
setSelectedTab(TabType.Secrets);
|
|
|
|
}
|
|
|
|
}, [loaded, me.loaded, showIngestionTab, selectedTab]);
|
2022-01-27 10:33:12 -08:00
|
|
|
|
|
|
|
const onClickTab = (newTab: string) => {
|
|
|
|
setSelectedTab(TabType[newTab]);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2025-01-29 20:42:01 -05:00
|
|
|
<PageContainer $isShowNavBarRedesign={isShowNavBarRedesign}>
|
2022-12-07 16:21:55 -08:00
|
|
|
<OnboardingTour stepIds={[INGESTION_CREATE_SOURCE_ID, INGESTION_REFRESH_SOURCES_ID]} />
|
2022-07-01 18:08:08 -04:00
|
|
|
<PageHeaderContainer>
|
2024-07-01 16:43:21 -07:00
|
|
|
<PageTitle level={3}>Manage Data Sources</PageTitle>
|
2022-07-01 18:08:08 -04:00
|
|
|
<Typography.Paragraph type="secondary">
|
2024-07-01 16:43:21 -07:00
|
|
|
Configure and schedule syncs to import data from your data sources
|
2022-07-01 18:08:08 -04:00
|
|
|
</Typography.Paragraph>
|
|
|
|
</PageHeaderContainer>
|
|
|
|
<StyledTabs activeKey={selectedTab} size="large" onTabClick={(tab: string) => onClickTab(tab)}>
|
2024-07-22 20:25:12 +05:30
|
|
|
{showIngestionTab && <Tab key={TabType.Sources} tab={TabType.Sources} />}
|
|
|
|
{showSecretsTab && <Tab key={TabType.Secrets} tab={TabType.Secrets} />}
|
2022-07-01 18:08:08 -04:00
|
|
|
</StyledTabs>
|
|
|
|
<ListContainer>{selectedTab === TabType.Sources ? <IngestionSourceList /> : <SecretsList />}</ListContainer>
|
|
|
|
</PageContainer>
|
2022-01-27 10:33:12 -08:00
|
|
|
);
|
|
|
|
};
|