Skip to content

Commit

Permalink
feat(ChatbotAttachment): Add AttachmentEdit modal
Browse files Browse the repository at this point in the history
AttachmentEdit modal needs substantial updates. Wiring this in for functionality demo purposes.
  • Loading branch information
rebeccaalpert committed Sep 4, 2024
1 parent efdb070 commit a8a177b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Message from '@patternfly/virtual-assistant/dist/dynamic/Message';
import FileDropZone from '@patternfly/virtual-assistant/dist/dynamic/FileDropZone';
import FileDetailsLabel from '@patternfly/virtual-assistant/dist/dynamic/FileDetailsLabel';
import PreviewAttachment from '@patternfly/virtual-assistant/dist/dynamic/PreviewAttachment';
import AttachmentEdit from '@patternfly/virtual-assistant/dist/dynamic/AttachmentEdit';

### Basic example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import FileDropZone from '@patternfly/virtual-assistant/dist/dynamic/FileDropZon
import { DropEvent } from '@patternfly/react-core';
import FileDetailsLabel from '@patternfly/virtual-assistant/dist/dynamic/FileDetailsLabel';
import PreviewAttachment from '@patternfly/virtual-assistant/dist/dynamic/PreviewAttachment';
import AttachmentEdit from '@patternfly/virtual-assistant/dist/dynamic/AttachmentEdit';

const footnoteProps = {
label: 'Lightspeed uses AI. Check for mistakes.',
Expand Down Expand Up @@ -73,7 +74,8 @@ export const BasicDemo: React.FunctionComponent = () => {
onAttachmentClose,
onAttachmentClick: () => {
setCurrentModalData({ fileName: 'auth-operator.yml', code: 'test' });
setIsPreviewModalOpen(!isPreviewModalOpen);
setIsEditModalOpen(false);
setIsPreviewModalOpen(true);
}
},
{
Expand All @@ -88,6 +90,7 @@ export const BasicDemo: React.FunctionComponent = () => {
const [isLoadingFile, setIsLoadingFile] = React.useState<boolean>(false);
const [messages, setMessages] = React.useState<MessageProps[]>(initialMessages);
const [isPreviewModalOpen, setIsPreviewModalOpen] = React.useState<boolean>(false);
const [isEditModalOpen, setIsEditModalOpen] = React.useState<boolean>(false);
const [currentModalData, setCurrentModalData] = React.useState<ModalData>();
const handleSend = (message) => alert(message);

Expand Down Expand Up @@ -151,11 +154,24 @@ export const BasicDemo: React.FunctionComponent = () => {
isModalOpen={isPreviewModalOpen}
onEdit={() => {
setIsPreviewModalOpen(false);
setIsEditModalOpen(true);
}}
onDismiss={() => setCurrentModalData(undefined)}
handleModalToggle={() => setIsPreviewModalOpen(false)}
/>
)}
{currentModalData && (
<AttachmentEdit
code={currentModalData?.code}
fileName={currentModalData?.fileName}
isModalOpen={isEditModalOpen}
onSave={() => {
setIsEditModalOpen(false);
}}
onCancel={() => setCurrentModalData(undefined)}
handleModalToggle={() => setIsEditModalOpen(false)}
/>
)}
</>
);
};

0 comments on commit a8a177b

Please sign in to comment.