forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added hide content when there is no access on Dashboard and Chart pages
- Loading branch information
Showing
19 changed files
with
290 additions
and
99 deletions.
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
94 changes: 94 additions & 0 deletions
94
superset-frontend/src/DodoExtensions/components/AccessWarning/index.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,94 @@ | ||
import React from 'react'; | ||
import { t, styled } from '@superset-ui/core'; | ||
import CopyToClipboard from 'src/components/CopyToClipboard'; | ||
import Button from 'src/components/Button'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { formAccessOptionLabel } from '../AccessConfigurationModal/utils'; | ||
|
||
const StyledWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 16px; | ||
height: 100%; | ||
font-size: ${({ theme }) => theme.typography.sizes.l}px; | ||
p { | ||
margin: 0; | ||
text-align: center; | ||
} | ||
span { | ||
font-weight: ${({ theme }) => theme.typography.weights.bold}; | ||
} | ||
`; | ||
|
||
interface IProps { | ||
entity: 'dashboard' | 'chart'; | ||
owners: { | ||
id: number; | ||
email?: string; | ||
first_name?: string; | ||
last_name?: string; | ||
teams?: Array<{ name: string }>; | ||
user_info?: Array<{ country_name: string | null }>; | ||
}[]; | ||
} | ||
|
||
const AccessWarning = ({ entity, owners }: IProps) => { | ||
const { | ||
location: { pathname, search }, | ||
} = useHistory(); | ||
const { protocol, hostname, port } = window.location; | ||
|
||
const owner = owners?.[0]; | ||
|
||
const url = `${protocol}//${hostname}${ | ||
port ? `:${port}` : '' | ||
}${pathname}${search}`; | ||
|
||
const clipboardMessage = `${t( | ||
entity === 'dashboard' | ||
? "I'm requesting access to this dashboard:" | ||
: "I'm requesting access to this chart:", | ||
)} ${url}`; | ||
|
||
return ( | ||
<StyledWrapper> | ||
<p> | ||
{t( | ||
entity === 'dashboard' | ||
? "You don't have access to this dashboard." | ||
: "You don't have access to this chart.", | ||
)} | ||
</p> | ||
{owner && ( | ||
<> | ||
<p> | ||
{t('Contact the owner for access')}:{' '} | ||
<span>{formAccessOptionLabel(owners[0])}.</span> | ||
</p> | ||
<p>{t('You can copy a prepared message to send to the owner.')}</p> | ||
<CopyToClipboard | ||
copyNode={ | ||
<Button buttonSize="small" buttonStyle="primary"> | ||
{t('Copy to Clipboard')} | ||
</Button> | ||
} | ||
text={clipboardMessage} | ||
shouldShowText={false} | ||
hideTooltip | ||
/> | ||
</> | ||
)} | ||
{!owner && ( | ||
<p> | ||
{t("The %(entity)s doesn't have an owner.", { entity: t(entity) })} | ||
</p> | ||
)} | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default AccessWarning; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ const createProps = () => ({ | |
], | ||
}, | ||
}, | ||
owners: [], | ||
}, | ||
dashboardTitle: 'Title', | ||
// DODO added | ||
|
Oops, something went wrong.