-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(ui): Show all views in settings #14971
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
Open
sakethvarma397
wants to merge
2
commits into
master
Choose a base branch
from
sv--cus-4956-show-allviews
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
117 changes: 102 additions & 15 deletions
117
datahub-web-react/src/app/entityV2/view/ManageViews.tsx
This file contains hidden or 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 |
---|---|---|
@@ -1,51 +1,138 @@ | ||
import { Typography } from 'antd'; | ||
import React from 'react'; | ||
import { Button, PageTitle, Tabs, colors } from '@components'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { Tab } from '@components/components/Tabs/Tabs'; | ||
|
||
import { ViewBuilder } from '@app/entity/view/builder/ViewBuilder'; | ||
import { ViewBuilderMode } from '@app/entity/view/builder/types'; | ||
import { ViewsList } from '@app/entityV2/view/ViewsList'; | ||
|
||
import { DataHubViewType } from '@types'; | ||
|
||
const PageContainer = styled.div` | ||
padding-top: 20px; | ||
padding: 16px 20px; | ||
width: 100%; | ||
overflow: hidden; | ||
flex: 1; | ||
gap: 20px; | ||
display: flex; | ||
flex-direction: column; | ||
overflow: auto; | ||
`; | ||
|
||
const PageHeaderContainer = styled.div` | ||
&& { | ||
padding-left: 24px; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
`; | ||
|
||
const PageTitle = styled(Typography.Title)` | ||
&& { | ||
margin-bottom: 12px; | ||
} | ||
const TitleContainer = styled.div` | ||
flex: 1; | ||
`; | ||
|
||
const HeaderActionsContainer = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
`; | ||
|
||
const ListContainer = styled.div` | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
&&& .ant-tabs-nav { | ||
margin: 0; | ||
} | ||
color: ${colors.gray[600]}; | ||
overflow: auto; | ||
`; | ||
|
||
enum TabType { | ||
Personal = 'My Views', | ||
Global = 'Public Views', | ||
} | ||
|
||
const tabUrlMap = { | ||
[TabType.Personal]: '/settings/views/personal', | ||
[TabType.Global]: '/settings/views/public', | ||
}; | ||
|
||
/** | ||
* Component used for displaying the 'Manage Views' experience. | ||
*/ | ||
export const ManageViews = () => { | ||
const [showViewBuilder, setShowViewBuilder] = useState(false); | ||
const [selectedTab, setSelectedTab] = useState<TabType | undefined | null>(); | ||
|
||
const onCloseModal = () => { | ||
setShowViewBuilder(false); | ||
}; | ||
|
||
const tabs: Tab[] = [ | ||
{ | ||
component: <ViewsList viewType={DataHubViewType.Personal} />, | ||
key: TabType.Personal, | ||
name: TabType.Personal, | ||
}, | ||
{ | ||
component: <ViewsList viewType={DataHubViewType.Global} />, | ||
key: TabType.Global, | ||
name: TabType.Global, | ||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
if (selectedTab === undefined) { | ||
const currentPath = window.location.pathname; | ||
|
||
const currentTab = Object.entries(tabUrlMap).find(([, url]) => url === currentPath)?.[0] as TabType; | ||
if (currentTab) { | ||
setSelectedTab(currentTab); | ||
} else { | ||
setSelectedTab(null); | ||
} | ||
} | ||
}, [selectedTab]); | ||
|
||
const getCurrentUrl = useCallback(() => window.location.pathname, []); | ||
|
||
return ( | ||
<PageContainer> | ||
<PageHeaderContainer> | ||
<PageTitle level={3}>Manage Views</PageTitle> | ||
<Typography.Paragraph type="secondary"> | ||
Create, edit, and remove your Views. Views allow you to save and share sets of filters for reuse | ||
when browsing DataHub. | ||
</Typography.Paragraph> | ||
<TitleContainer> | ||
<PageTitle | ||
title="Views" | ||
subTitle="Create, edit, and remove your Views. Views allow you to save and share sets of filters for reuse when browsing DataHub." | ||
/> | ||
</TitleContainer> | ||
<HeaderActionsContainer> | ||
<Button | ||
variant="filled" | ||
id="create-new-view-button" | ||
onClick={() => setShowViewBuilder(true)} | ||
data-testid="create-new-view-button" | ||
icon={{ icon: 'Plus', source: 'phosphor' }} | ||
disabled={false} | ||
> | ||
Create View | ||
</Button> | ||
</HeaderActionsContainer> | ||
</PageHeaderContainer> | ||
<ListContainer> | ||
<ViewsList /> | ||
<Tabs | ||
tabs={tabs} | ||
selectedTab={selectedTab as string} | ||
onChange={(tab) => setSelectedTab(tab as TabType)} | ||
urlMap={tabUrlMap} | ||
defaultTab={TabType.Personal} | ||
getCurrentUrl={getCurrentUrl} | ||
/> | ||
</ListContainer> | ||
{showViewBuilder && ( | ||
<ViewBuilder mode={ViewBuilderMode.EDITOR} onSubmit={onCloseModal} onCancel={onCloseModal} /> | ||
)} | ||
</PageContainer> | ||
); | ||
}; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's always try to use
location
fromuseLocation
instead of the window object directly - it's generally safer and factors in stuff like if we have a basePath prefixed to our site. which we now support :)