MCPcopy
hub / github.com/FlowiseAI/Flowise / Header

Function Header

packages/ui/src/layout/MainLayout/Header/index.jsx:145–317  ·  view source on GitHub ↗
({ handleLeftDrawerToggle })

Source from the content-addressed store, hash-verified

143}
144
145const Header = ({ handleLeftDrawerToggle }) => {
146 const theme = useTheme()
147 const navigate = useNavigate()
148
149 const customization = useSelector((state) => state.customization)
150 const logoutApi = useApi(accountApi.logout)
151
152 const [isDark, setIsDark] = useState(customization.isDarkMode)
153 const dispatch = useDispatch()
154 const { isEnterpriseLicensed, isCloud, isOpenSource } = useConfig()
155 const currentUser = useSelector((state) => state.auth.user)
156 const isAuthenticated = useSelector((state) => state.auth.isAuthenticated)
157 const [isPricingOpen, setIsPricingOpen] = useState(false)
158 const [starCount, setStarCount] = useState(0)
159
160 useNotifier()
161
162 const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
163 const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))
164
165 const changeDarkMode = () => {
166 dispatch({ type: SET_DARKMODE, isDarkMode: !isDark })
167 setIsDark((isDark) => !isDark)
168 localStorage.setItem('isDarkMode', !isDark)
169 }
170
171 const signOutClicked = () => {
172 logoutApi.request()
173 enqueueSnackbar({
174 message: 'Logging out...',
175 options: {
176 key: new Date().getTime() + Math.random(),
177 variant: 'success',
178 action: (key) => (
179 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
180 <IconX />
181 </Button>
182 )
183 }
184 })
185 }
186
187 useEffect(() => {
188 try {
189 if (logoutApi.data && logoutApi.data.message === 'logged_out') {
190 store.dispatch(logoutSuccess())
191 window.location.href = logoutApi.data.redirectTo
192 }
193 } catch (e) {
194 console.error(e)
195 }
196 }, [logoutApi.data])
197
198 useEffect(() => {
199 if (isCloud || isOpenSource) {
200 const fetchStarCount = async () => {
201 try {
202 const response = await fetch('https://api.github.com/repos/FlowiseAI/Flowise')

Callers

nothing calls this directly

Calls 4

useConfigFunction · 0.90
useNotifierFunction · 0.85
fetchStarCountFunction · 0.85
downMethod · 0.45

Tested by

no test coverage detected