({ handleLeftDrawerToggle })
| 143 | } |
| 144 | |
| 145 | const 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') |
nothing calls this directly
no test coverage detected