-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ View files task attachments (#1954)
Resolves: #1929 Functional changes: 1. document to be viewed is selected from the list (first action above the editor) or via URL 2. display language toggle based on languages supported by the document. For attachments the list consists of plain text and optionally a second language discovered based on file extension (YAML or JSON). 3. replace "merged" checkbox with an option in the select Related refactorings: 1. split getTaskById() query into specialized queries: a) getTaskById() returning Promise<Task> for working with the object b) getTaskByIdAndFormat() returning Promise<string> for displaying the task as a formatted text 2. configure AnalysisDetails component to respond to 2 routes: existing details route and newly added /applications/:applicationId/analysis-details/:taskId/attachments/:attachmentId 3. persist merge mode in the URL as search param "merged" Signed-off-by: Radoslaw Szwajkowski <[email protected]>
- Loading branch information
Showing
11 changed files
with
396 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
client/src/app/components/simple-document-viewer/AttachmentToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { FC, useState } from "react"; | ||
|
||
import { | ||
Select, | ||
SelectOption, | ||
SelectList, | ||
MenuToggleElement, | ||
MenuToggle, | ||
} from "@patternfly/react-core"; | ||
import { Document } from "./SimpleDocumentViewer"; | ||
import "./SimpleDocumentViewer.css"; | ||
|
||
export const AttachmentToggle: FC<{ | ||
onSelect: (docId: string | number) => void; | ||
documents: (Document & { isSelected: boolean })[]; | ||
}> = ({ onSelect, documents }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const onToggle = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
return ( | ||
<div className="simple-task-viewer-attachment-toggle"> | ||
<Select | ||
isOpen={isOpen} | ||
onSelect={(_event, selectedId: string | number | undefined) => { | ||
if (selectedId) { | ||
onSelect(selectedId); | ||
} | ||
onToggle(); | ||
}} | ||
onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
toggle={(toggleRef: React.Ref<MenuToggleElement>) => ( | ||
<MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen}> | ||
{documents.find(({ isSelected }) => isSelected)?.name} | ||
</MenuToggle> | ||
)} | ||
shouldFocusToggleOnSelect | ||
> | ||
<SelectList> | ||
{documents.map(({ id, name, isSelected, description }) => ( | ||
<SelectOption | ||
isSelected={isSelected} | ||
key={id} | ||
value={id} | ||
description={description} | ||
> | ||
{name} | ||
</SelectOption> | ||
))} | ||
</SelectList> | ||
</Select> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.