()
| 95 | }; |
| 96 | |
| 97 | export const Workspace: React.FC<React.PropsWithChildren<unknown>> = () => { |
| 98 | const dispatch = useDispatch(); |
| 99 | const localSize = getStorage(StorageName.SplitPos); |
| 100 | const defaultSidePanelSize = localSize && localSize !== 280 ? localSize : 335; |
| 101 | const editNodeId = useAppSelector((state: IReduxState) => state.catalogTree.editNodeId); |
| 102 | const favoriteEditNodeId = useAppSelector((state: IReduxState) => state.catalogTree.favoriteEditNodeId); |
| 103 | const userSpaceId = useAppSelector((state: IReduxState) => state.user.info!.spaceId); |
| 104 | const { getTreeDataReq } = useCatalogTreeRequest(); |
| 105 | const { run: getTreeData } = useRequest(getTreeDataReq, { manual: true }); |
| 106 | const { screenIsAtMost } = useResponsive(); |
| 107 | const menuRef = useRef<HTMLDivElement | null>(null); |
| 108 | const [templeVisible, setTempleVisible] = useState(false); |
| 109 | const isMobile = screenIsAtMost(ScreenSize.md); |
| 110 | const query = useQuery(); |
| 111 | const router = useRouter(); |
| 112 | const theme = useTheme(); |
| 113 | const spaceInfo = useAppSelector((state) => state.space.curSpaceInfo); |
| 114 | const social = spaceInfo?.social; |
| 115 | const nodeId = useAppSelector((state) => state.pageParams.nodeId); |
| 116 | |
| 117 | // Directory tree toggle source status, directory tree click status, sidebar switch. |
| 118 | const [toggleType, setToggleType] = useState<SideBarType>(SideBarType.None); |
| 119 | const [clickType, setClickType] = useState<SideBarClickType>(SideBarClickType.None); |
| 120 | const [panelVisible, setPanelVisible] = useState(false); |
| 121 | const [newTdbId, setNewTdbId] = useState(''); |
| 122 | const sideBarVisible = useAppSelector((state) => state.space.sideBarVisible); |
| 123 | const showUpgradeSpaceModal = useRef(false); |
| 124 | |
| 125 | usePaymentReminder(); |
| 126 | |
| 127 | useEffect(() => { |
| 128 | if (showUpgradeSpaceModal.current) return; |
| 129 | if (!query.get('choosePlan') || isMobile) return; |
| 130 | if (!social || social?.appType === 1 || social?.appType === 2) { |
| 131 | return; |
| 132 | } |
| 133 | showUpgradeSpaceModal.current = true; |
| 134 | expandUpgradeSpace(); |
| 135 | }); |
| 136 | |
| 137 | useEffect(() => { |
| 138 | if (getEnvVariables().IS_APITABLE) return; |
| 139 | if (document.querySelector('#VIKA_USAGE_WARN_MODAL')) return; |
| 140 | if (!SubscribeUsageTipType || !triggerUsageAlert || !subscribeUsageCheck || !spaceInfo) return; |
| 141 | if (subscribeUsageCheck.shouldAlertToUser('maxSeats', spaceInfo?.seats, true)) { |
| 142 | triggerUsageAlert('maxSeats', { usage: spaceInfo?.seats, alwaysAlert: true }, SubscribeUsageTipType.Alert); |
| 143 | } |
| 144 | }, [nodeId, spaceInfo]); |
| 145 | |
| 146 | useMount(() => { |
| 147 | if (!query.get('stripePaySuccess') || isMobile) return; |
| 148 | showOrderModal({ |
| 149 | modalTitle: t(Strings.upgrade_success_model, { orderType: t(Strings.upgrade) }), |
| 150 | modalSubTitle: () => ( |
| 151 | <> |
| 152 | <div className={styles.desc1} style={{ marginTop: 24, fontSize: 16 }}> |
| 153 | { |
| 154 | <TComponent |
nothing calls this directly
no test coverage detected