added notice popup screen when no api key exists

This commit is contained in:
Nikita 2023-08-04 12:44:21 +03:00
parent 9cc4d6a7b3
commit 24e76280d4
7 changed files with 124 additions and 6 deletions

View file

@ -11,6 +11,7 @@ import { Modal } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { rawHandler } from '@wordpress/blocks';
import domReady from '@wordpress/dom-ready';
import clsx from 'clsx';
/**
* Internal dependencies
@ -19,6 +20,9 @@ import Input from './components/input';
import LoadingLine from './components/loading-line';
import Content from './components/content';
import Footer from './components/footer';
import NotConnectedScreen from './components/not-connected-screen';
const { connected } = window.mindData;
const POPUP_CONTAINER_CLASS = 'mind-popup-container';
@ -89,7 +93,10 @@ export default function Popup() {
return (
<Modal
title={false}
className="mind-popup"
className={clsx(
'mind-popup',
!connected && 'mind-popup-not-connected'
)}
overlayClassName="mind-popup-overlay"
onRequestClose={() => {
reset();
@ -97,10 +104,16 @@ export default function Popup() {
}}
__experimentalHideHeader
>
<Input onInsert={onInsert} />
{loading && <LoadingLine />}
<Content />
<Footer onInsert={onInsert} />
{connected ? (
<>
<Input onInsert={onInsert} />
{loading && <LoadingLine />}
<Content />
<Footer onInsert={onInsert} />
</>
) : (
<NotConnectedScreen />
)}
</Modal>
);
}