1
- import { Tabs , Typography } from 'antd ' ;
1
+ import { Button , PageTitle , Tabs } from '@components ' ;
2
2
import React , { useEffect , useState } from 'react' ;
3
3
import { useHistory } from 'react-router' ;
4
4
import styled from 'styled-components' ;
5
5
6
+ import { Tab } from '@components/components/Tabs/Tabs' ;
7
+
6
8
import { useUserContext } from '@app/context/useUserContext' ;
7
9
import { SecretsList } from '@app/ingestV2/secret/SecretsList' ;
8
10
import { IngestionSourceList } from '@app/ingestV2/source/IngestionSourceList' ;
9
11
import { TabType } from '@app/ingestV2/types' ;
10
12
import { OnboardingTour } from '@app/onboarding/OnboardingTour' ;
11
- import {
12
- INGESTION_CREATE_SOURCE_ID ,
13
- INGESTION_REFRESH_SOURCES_ID ,
14
- } from '@app/onboarding/config/IngestionOnboardingConfig' ;
13
+ import { INGESTION_CREATE_SOURCE_ID } from '@app/onboarding/config/IngestionOnboardingConfig' ;
15
14
import { useAppConfig } from '@app/useAppConfig' ;
16
15
import { useShowNavBarRedesign } from '@app/useShowNavBarRedesign' ;
17
16
@@ -30,32 +29,36 @@ const PageContainer = styled.div<{ $isShowNavBarRedesign?: boolean }>`
30
29
` }
31
30
` ;
32
31
33
- const PageHeaderContainer = styled . div `
34
- && {
35
- padding-left: 24px;
36
- }
32
+ const PageContentContainer = styled . div `
33
+ display: flex;
34
+ flex-direction: column;
35
+ gap: 24px;
36
+ flex: 1;
37
+ margin: 0 20px 20px 20px;
38
+ height: calc(100% - 80px);
37
39
` ;
38
40
39
- const PageTitle = styled ( Typography . Title ) `
41
+ const PageHeaderContainer = styled . div `
40
42
&& {
41
- margin-bottom: 12px;
43
+ padding-left: 20px;
44
+ padding-right: 20px;
45
+ display: flex;
46
+ flex-direction: row;
47
+ justify-content: space-between;
48
+ align-items: center;
49
+ margin-bottom: 16px;
42
50
}
43
51
` ;
44
52
45
- const StyledTabs = styled ( Tabs ) `
46
- &&& .ant-tabs-nav {
47
- margin-bottom: 0;
48
- padding-left: 28px;
49
- }
53
+ const TitleContainer = styled . div `
54
+ flex: 1;
50
55
` ;
51
56
52
- const Tab = styled ( Tabs . TabPane ) `
53
- font-size: 14px ;
54
- line-height: 22px ;
57
+ const HeaderActionsContainer = styled . div `
58
+ display: flex ;
59
+ justify-content: flex-end ;
55
60
` ;
56
61
57
- const ListContainer = styled . div `` ;
58
-
59
62
export const ManageIngestionPage = ( ) => {
60
63
/**
61
64
* Determines which view should be visible: ingestion sources or secrets.
@@ -67,6 +70,8 @@ export const ManageIngestionPage = () => {
67
70
const showSecretsTab = isIngestionEnabled && me && me . platformPrivileges ?. manageSecrets ;
68
71
const [ selectedTab , setSelectedTab ] = useState < TabType > ( TabType . Sources ) ;
69
72
const isShowNavBarRedesign = useShowNavBarRedesign ( ) ;
73
+ const [ showCreateSourceModal , setShowCreateSourceModal ] = useState < boolean > ( false ) ;
74
+ const [ showCreateSecretModal , setShowCreateSecretModal ] = useState < boolean > ( false ) ;
70
75
71
76
// defaultTab might not be calculated correctly on mount, if `config` or `me` haven't been loaded yet
72
77
useEffect ( ( ) => {
@@ -84,29 +89,76 @@ export const ManageIngestionPage = () => {
84
89
}
85
90
} ;
86
91
87
- const TabTypeToListComponent = {
88
- [ TabType . Sources ] : < IngestionSourceList /> ,
89
- [ TabType . Secrets ] : < SecretsList /> ,
92
+ const tabs : Tab [ ] = [
93
+ showIngestionTab && {
94
+ component : (
95
+ < IngestionSourceList
96
+ showCreateModal = { showCreateSourceModal }
97
+ setShowCreateModal = { setShowCreateSourceModal }
98
+ />
99
+ ) ,
100
+ key : TabType . Sources as string ,
101
+ name : TabType . Sources as string ,
102
+ } ,
103
+ showSecretsTab && {
104
+ component : (
105
+ < SecretsList showCreateModal = { showCreateSecretModal } setShowCreateModal = { setShowCreateSecretModal } />
106
+ ) ,
107
+ key : TabType . Secrets as string ,
108
+ name : TabType . Secrets as string ,
109
+ } ,
110
+ ] . filter ( ( tab ) : tab is Tab => Boolean ( tab ) ) ;
111
+
112
+ const handleCreateSource = ( ) => {
113
+ setShowCreateSourceModal ( true ) ;
114
+ } ;
115
+
116
+ const handleCreateSecret = ( ) => {
117
+ setShowCreateSecretModal ( true ) ;
90
118
} ;
91
119
92
120
return (
93
121
< PageContainer $isShowNavBarRedesign = { isShowNavBarRedesign } >
94
- < OnboardingTour stepIds = { [ INGESTION_CREATE_SOURCE_ID , INGESTION_REFRESH_SOURCES_ID ] } />
122
+ < OnboardingTour stepIds = { [ INGESTION_CREATE_SOURCE_ID ] } />
95
123
< PageHeaderContainer >
96
- < PageTitle level = { 3 } > Manage Data Sources</ PageTitle >
97
- < Typography . Paragraph type = "secondary" >
98
- Configure and schedule syncs to import data from your data sources
99
- </ Typography . Paragraph >
124
+ < TitleContainer >
125
+ < PageTitle
126
+ title = "Manage Data Sources"
127
+ subTitle = "Configure and schedule syncs to import data from your data sources"
128
+ />
129
+ </ TitleContainer >
130
+ < HeaderActionsContainer >
131
+ { selectedTab === TabType . Sources && showIngestionTab && (
132
+ < Button
133
+ variant = "filled"
134
+ id = { INGESTION_CREATE_SOURCE_ID }
135
+ onClick = { handleCreateSource }
136
+ data-testid = "create-ingestion-source-button"
137
+ icon = { { icon : 'Plus' , source : 'phosphor' } }
138
+ >
139
+ Create new source
140
+ </ Button >
141
+ ) }
142
+
143
+ { selectedTab === TabType . Secrets && showSecretsTab && (
144
+ < Button
145
+ variant = "filled"
146
+ onClick = { handleCreateSecret }
147
+ data-testid = "create-secret-button"
148
+ icon = { { icon : 'Plus' , source : 'phosphor' } }
149
+ >
150
+ Create new secret
151
+ </ Button >
152
+ ) }
153
+ </ HeaderActionsContainer >
100
154
</ PageHeaderContainer >
101
- < StyledTabs
102
- activeKey = { selectedTab }
103
- size = "large"
104
- onTabClick = { ( tab ) => onSwitchTab ( tab , { clearQueryParams : true } ) }
105
- >
106
- { showIngestionTab && < Tab key = { TabType . Sources } tab = { TabType . Sources } /> }
107
- { showSecretsTab && < Tab key = { TabType . Secrets } tab = { TabType . Secrets } /> }
108
- </ StyledTabs >
109
- < ListContainer > { TabTypeToListComponent [ selectedTab ] } </ ListContainer >
155
+ < PageContentContainer >
156
+ < Tabs
157
+ tabs = { tabs }
158
+ selectedTab = { selectedTab }
159
+ onChange = { ( tab ) => onSwitchTab ( tab , { clearQueryParams : true } ) }
160
+ />
161
+ </ PageContentContainer >
110
162
</ PageContainer >
111
163
) ;
112
164
} ;
0 commit comments