MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / Header

Function Header

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

Source from the content-addressed store, hash-verified

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

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