-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Data sources associated objects tab (#1470)
Signed-off-by: Ryan Liang <[email protected]>
- Loading branch information
Showing
5 changed files
with
339 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
public/components/datasources/components/manage/accelerations_recommendation_callout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiCallOut } from '@elastic/eui'; | ||
import React from 'react'; | ||
|
||
export const AccelerationsRecommendationCallout = () => { | ||
return ( | ||
<EuiCallOut | ||
title="Accelerations recommended for tables. Setup acceleration or configure integrations" | ||
iconType="iInCircle" | ||
/> | ||
); | ||
}; |
197 changes: 197 additions & 0 deletions
197
public/components/datasources/components/manage/associated_objects_tab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
EuiInMemoryTable, | ||
EuiLink, | ||
EuiPanel, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiText, | ||
EuiHorizontalRule, | ||
EuiButton, | ||
EuiSpacer, | ||
EuiEmptyPrompt, | ||
} from '@elastic/eui'; | ||
import { AssociatedObject } from 'common/types/data_connections'; | ||
import { AccelerationsRecommendationCallout } from './accelerations_recommendation_callout'; | ||
|
||
interface AssociatedObjectsTabProps { | ||
associatedObjects: AssociatedObject[]; | ||
} | ||
|
||
export const AssociatedObjectsTab: React.FC<AssociatedObjectsTabProps> = ({ | ||
associatedObjects, | ||
}) => { | ||
const [lastUpdated, setLastUpdated] = useState(''); | ||
|
||
// TODO: FINISH THE REFRESH LOGIC | ||
const fetchAssociatedObjects = async () => { | ||
// Placeholder for data fetching logic | ||
// After fetching data: | ||
// setAssociatedObjects(fetchedData); | ||
const now = new Date(); | ||
setLastUpdated(now.toUTCString()); // Update last updated time | ||
}; | ||
|
||
useEffect(() => { | ||
fetchAssociatedObjects(); | ||
}, []); | ||
|
||
const AssociatedObjectsHeader = () => { | ||
return ( | ||
<EuiFlexGroup direction="row"> | ||
<EuiFlexItem> | ||
<EuiText size="m"> | ||
<h2 className="panel-title">Associated objects</h2> | ||
Manage objects associated with this data sources. | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<div style={{ textAlign: 'right' }}> | ||
<EuiText color="subdued" style={{ fontSize: 'small' }}> | ||
Last updated at: | ||
</EuiText> | ||
<EuiText color="subdued" style={{ fontSize: 'small' }}> | ||
{lastUpdated} | ||
</EuiText> | ||
</div> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
data-test-subj="freshButton" | ||
iconType="refresh" | ||
onClick={fetchAssociatedObjects} | ||
> | ||
Refresh | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; | ||
|
||
const noDataMessage = ( | ||
<EuiEmptyPrompt | ||
title={<h2>You have no associated objects</h2>} | ||
body={<p>Add or config tables from your data source or use Query Workbench.</p>} | ||
actions={ | ||
<EuiButton | ||
color="primary" | ||
fill | ||
onClick={() => window.open('https://example.com', '_blank')} | ||
iconType="popout" | ||
iconSide="left" | ||
> | ||
Query Workbench | ||
</EuiButton> | ||
} | ||
/> | ||
); | ||
|
||
const columns = [ | ||
{ | ||
field: 'name', | ||
name: 'Name', | ||
sortable: true, | ||
'data-test-subj': 'nameCell', | ||
render: (name: string) => ( | ||
<EuiLink href="https://example.com" target="_blank"> | ||
{name} | ||
</EuiLink> | ||
), | ||
}, | ||
{ | ||
field: 'database', | ||
name: 'Database', | ||
truncateText: true, | ||
render: (database: string) => ( | ||
<EuiLink href="https://example.com" target="_blank"> | ||
{database} | ||
</EuiLink> | ||
), | ||
}, | ||
{ | ||
field: 'type', | ||
name: 'Type', | ||
sortable: true, | ||
}, | ||
{ | ||
field: 'createdByIntegration', | ||
name: 'Created by Integration', | ||
sortable: true, | ||
}, | ||
{ | ||
field: 'accelerations', | ||
name: 'Accelerations', | ||
sortable: true, | ||
}, | ||
{ | ||
name: 'Actions', | ||
actions: [ | ||
{ | ||
name: 'Edit', | ||
description: 'Edit this object', | ||
type: 'icon', | ||
icon: 'discoverApp', | ||
onClick: (item: AssociatedObject) => console.log('Edit', item), | ||
}, | ||
{ | ||
name: 'Delete', | ||
description: 'Delete this object', | ||
type: 'icon', | ||
icon: 'bolt', | ||
onClick: (item: AssociatedObject) => console.log('Delete', item), | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const search = { | ||
box: { | ||
incremental: true, | ||
schema: { | ||
fields: { name: { type: 'string' }, database: { type: 'string' } }, | ||
}, | ||
}, | ||
}; | ||
|
||
const pagination = { | ||
initialPageSize: 10, | ||
pageSizeOptions: [10, 25, 50], | ||
}; | ||
|
||
const sorting = { | ||
sort: { | ||
field: 'name', | ||
direction: 'asc', | ||
}, | ||
}; | ||
|
||
return ( | ||
<> | ||
<EuiSpacer /> | ||
<EuiPanel> | ||
<AssociatedObjectsHeader /> | ||
<EuiHorizontalRule /> | ||
<AccelerationsRecommendationCallout /> | ||
<EuiSpacer /> | ||
{associatedObjects.length > 0 ? ( | ||
<EuiInMemoryTable | ||
items={associatedObjects} | ||
columns={columns} | ||
search={search} | ||
pagination={pagination} | ||
sorting={sorting} | ||
noItemsMessage={associatedObjects.length === 0 ? noDataMessage : undefined} | ||
/> | ||
) : ( | ||
noDataMessage | ||
)} | ||
</EuiPanel> | ||
<EuiSpacer /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters