mirror of https://github.com/FlowiseAI/Flowise.git
Add roles and permissons
parent
2a6ada5283
commit
8ebcf8ca8f
|
|
@ -26,6 +26,7 @@
|
|||
"axios": "1.6.2",
|
||||
"clsx": "^1.1.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"flagsmith": "^4.0.3",
|
||||
"aai-embed": "workspace:*",
|
||||
"aai-embed-react": "workspace:*",
|
||||
"flowise-react-json-view": "*",
|
||||
|
|
|
|||
|
|
@ -14,13 +14,28 @@ import themes from '@/themes'
|
|||
import NavigationScroll from '@/layout/NavigationScroll'
|
||||
import { useAuth0 } from '@auth0/auth0-react'
|
||||
import useNotifyParentOfNavigation from './utils/useNotifyParentOfNavigation'
|
||||
import { useFlagsmith } from 'flagsmith/react'
|
||||
|
||||
// ==============================|| APP ||============================== //
|
||||
|
||||
const App = () => {
|
||||
const customization = useSelector((state) => state.customization)
|
||||
const { getAccessTokenSilently, error } = useAuth0()
|
||||
const { user, getAccessTokenSilently, error } = useAuth0()
|
||||
const flagsmith = useFlagsmith()
|
||||
useNotifyParentOfNavigation()
|
||||
React.useEffect(() => {
|
||||
if (user)
|
||||
flagsmith.identify(
|
||||
`user_${
|
||||
user.email
|
||||
? user.email.split('').reduce((a, b) => {
|
||||
a = (a << 5) - a + b.charCodeAt(0)
|
||||
return a & a
|
||||
}, 0)
|
||||
: ''
|
||||
}`
|
||||
)
|
||||
}, [user, flagsmith])
|
||||
React.useEffect(() => {
|
||||
;(async () => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import { Provider } from 'react-redux'
|
|||
import { SnackbarProvider } from 'notistack'
|
||||
import ConfirmContextProvider from '@/store/context/ConfirmContextProvider'
|
||||
import { ReactFlowContext } from '@/store/context/ReactFlowContext'
|
||||
import flagsmith from 'flagsmith'
|
||||
import { FlagsmithProvider } from 'flagsmith/react'
|
||||
|
||||
const container = document.getElementById('root')
|
||||
const root = createRoot(container)
|
||||
|
|
@ -26,22 +28,29 @@ const authorizationParams = {
|
|||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<Auth0Provider
|
||||
domain={import.meta.env.VITE_AUTH_DOMAIN}
|
||||
clientId={import.meta.env.VITE_AUTH_CLIENT_ID}
|
||||
authorizationParams={authorizationParams}
|
||||
<FlagsmithProvider
|
||||
options={{
|
||||
environmentID: 'AtPisjg2ZzdPuDKYNDDcBa'
|
||||
}}
|
||||
flagsmith={flagsmith}
|
||||
>
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<SnackbarProvider>
|
||||
<ConfirmContextProvider>
|
||||
<ReactFlowContext>
|
||||
<App />
|
||||
</ReactFlowContext>
|
||||
</ConfirmContextProvider>
|
||||
</SnackbarProvider>
|
||||
</BrowserRouter>
|
||||
</Provider>
|
||||
</Auth0Provider>
|
||||
<Auth0Provider
|
||||
domain={import.meta.env.VITE_AUTH_DOMAIN}
|
||||
clientId={import.meta.env.VITE_AUTH_CLIENT_ID}
|
||||
authorizationParams={authorizationParams}
|
||||
>
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<SnackbarProvider>
|
||||
<ConfirmContextProvider>
|
||||
<ReactFlowContext>
|
||||
<App />
|
||||
</ReactFlowContext>
|
||||
</ConfirmContextProvider>
|
||||
</SnackbarProvider>
|
||||
</BrowserRouter>
|
||||
</Provider>
|
||||
</Auth0Provider>
|
||||
</FlagsmithProvider>
|
||||
</React.StrictMode>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,14 +7,19 @@ import { Divider, List, Typography } from '@mui/material'
|
|||
// project imports
|
||||
import NavItem from '../NavItem'
|
||||
import NavCollapse from '../NavCollapse'
|
||||
import { useFlags } from 'flagsmith/react'
|
||||
|
||||
// ==============================|| SIDEBAR MENU LIST GROUP ||============================== //
|
||||
|
||||
const NavGroup = ({ item }) => {
|
||||
const theme = useTheme()
|
||||
|
||||
const flags = useFlags(['org:admin'])
|
||||
const ADMIN_ACTIONS = ['agentflows', 'tools', 'assistants', 'credentials', 'variables', 'apikey']
|
||||
// menu list collapse & items
|
||||
const items = item.children?.map((menu) => {
|
||||
if (ADMIN_ACTIONS?.includes(menu.id) && !flags?.org_admin?.enabled) {
|
||||
return null
|
||||
}
|
||||
switch (menu.type) {
|
||||
case 'collapse':
|
||||
return <NavCollapse key={menu.id} menu={menu} level={1} />
|
||||
|
|
|
|||
|
|
@ -4,20 +4,23 @@ import PropTypes from 'prop-types'
|
|||
import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackbarAction, SET_CHATFLOW } from '@/store/actions'
|
||||
|
||||
// material-ui
|
||||
import { Button, Box, Typography, FormGroup, FormLabel, FormControl, FormControlLabel, Checkbox } from '@mui/material'
|
||||
import { Button, Box, Typography, FormGroup, FormLabel, FormControl, FormControlLabel, Checkbox, Tooltip } from '@mui/material'
|
||||
import { IconX } from '@tabler/icons-react'
|
||||
|
||||
// Project import
|
||||
import { StyledButton } from '@/ui-component/button/StyledButton'
|
||||
|
||||
// store
|
||||
// Hooks
|
||||
import useNotifier from '@/utils/useNotifier'
|
||||
import { useFlags } from 'flagsmith/react'
|
||||
|
||||
// API
|
||||
import chatflowsApi from '@/api/chatflows'
|
||||
import { TooltipWithParser } from '../tooltip/TooltipWithParser'
|
||||
|
||||
const AnswersSettings = ({ dialogProps }) => {
|
||||
const flags = useFlags(['chatflow:share:internal', 'org:admin'])
|
||||
|
||||
const dispatch = useDispatch()
|
||||
const chatflow = useSelector((state) => state.canvas.chatflow)
|
||||
|
||||
|
|
@ -89,14 +92,25 @@ const AnswersSettings = ({ dialogProps }) => {
|
|||
</Typography>
|
||||
<FormControl component='fieldset' sx={{ width: '100%', mb: 2 }}>
|
||||
<FormGroup>
|
||||
{['Private', 'Organization', 'AnswerAI', 'Marketplace', 'Browser Extension'].map((type) => (
|
||||
<FormControlLabel
|
||||
key={type}
|
||||
disabled={type === 'Private'}
|
||||
control={<Checkbox checked={visibility.includes(type)} onChange={(event) => handleChange(event, type)} />}
|
||||
label={type}
|
||||
/>
|
||||
))}
|
||||
{['Private', 'Organization', 'AnswerAI', 'Marketplace', 'Browser Extension'].map((type) => {
|
||||
const isDisabled =
|
||||
type === 'Private' ||
|
||||
(!flags['org:admin']?.enabled && type === 'Browser Extension') ||
|
||||
(!flags['org:admin']?.enabled && type === 'Organization') ||
|
||||
(!flags['chatflow:share:internal']?.enabled && type === 'Marketplace')
|
||||
return (
|
||||
<FormControlLabel
|
||||
key={type}
|
||||
control={
|
||||
<Tooltip title={isDisabled ? 'Contact your org admin to enable this option' : ''}>
|
||||
<Checkbox checked={visibility.includes(type)} onChange={(event) => handleChange(event, type)} />
|
||||
</Tooltip>
|
||||
}
|
||||
label={type}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</FormGroup>
|
||||
</FormControl>
|
||||
<StyledButton variant='contained' onClick={onSave}>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import chatflowsApi from '@/api/chatflows'
|
|||
|
||||
// Hooks
|
||||
import useApi from '@/hooks/useApi'
|
||||
import { useFlags } from 'flagsmith/react'
|
||||
|
||||
// utils
|
||||
import { generateExportFlowData } from '@/utils/genericHelper'
|
||||
|
|
@ -34,6 +35,7 @@ import ViewLeadsDialog from '@/ui-component/dialog/ViewLeadsDialog'
|
|||
|
||||
const CanvasHeader = ({ chatflow, isAgentCanvas, handleSaveFlow, handleDeleteFlow, handleLoadFlow }) => {
|
||||
const theme = useTheme()
|
||||
const flags = useFlags(['chatflow:share:external'])
|
||||
const dispatch = useDispatch()
|
||||
const navigate = useNavigate()
|
||||
const flowNameRef = useRef()
|
||||
|
|
@ -329,7 +331,7 @@ const CanvasHeader = ({ chatflow, isAgentCanvas, handleSaveFlow, handleDeleteFlo
|
|||
</Box>
|
||||
</Stack>
|
||||
<Box>
|
||||
{chatflow?.id && (
|
||||
{chatflow?.id && flags?.['chatflow:share:external']?.enabled && (
|
||||
<ButtonBase title='API Endpoint' sx={{ borderRadius: '50%', mr: 2 }}>
|
||||
<Avatar
|
||||
variant='rounded'
|
||||
|
|
|
|||
|
|
@ -830,6 +830,9 @@ importers:
|
|||
dotenv:
|
||||
specifier: ^16.0.0
|
||||
version: 16.4.5
|
||||
flagsmith:
|
||||
specifier: ^4.0.3
|
||||
version: 4.0.3
|
||||
flowise-react-json-view:
|
||||
specifier: '*'
|
||||
version: 1.21.7(@types/react@18.0.32)(encoding@0.1.13)(react-dom@18.3.1(react@18.2.0))(react@18.2.0)
|
||||
|
|
@ -8785,6 +8788,9 @@ packages:
|
|||
resolution: {integrity: sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
||||
flagsmith@4.0.3:
|
||||
resolution: {integrity: sha512-F2lI84yCwxP9RZMcqDgpj9cjWfgQ6YQLS1/bXNp4iltZz6K8lr4zECjBbqqZSUBpxpKBOxfPFX6XGdDurAKOuA==}
|
||||
|
||||
flat-cache@3.2.0:
|
||||
resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==}
|
||||
engines: {node: ^10.12.0 || >=12.0.0}
|
||||
|
|
@ -27546,6 +27552,8 @@ snapshots:
|
|||
|
||||
flagged-respawn@1.0.1: {}
|
||||
|
||||
flagsmith@4.0.3: {}
|
||||
|
||||
flat-cache@3.2.0:
|
||||
dependencies:
|
||||
flatted: 3.3.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue