Skip to content

Commit

Permalink
Merge branch 'main' into fix-analysis-details-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Jul 5, 2023
2 parents c04ac4a + 54f156b commit 90144b3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@
"scheduled": "Scheduled",
"select": "Select",
"settingsAllowApps": "Allow reviewing applications without running an assessment first",
"showLess": "Show less",
"showMore": "Show more",
"source": "Source",
"sourceBranch": "Branch",
"sourceCode": "Source code",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.tracker-status-code {
min-width: 30em;
max-width: 60em;
}

.tracker-status-code .pf-c-code-block__content {
max-height: 450px;
overflow: auto;
}
35 changes: 33 additions & 2 deletions client/src/app/pages/external/jira/components/tracker-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ import {
Button,
CodeBlock,
CodeBlockCode,
ExpandableSectionToggle,
Popover,
Text,
TextContent,
} from "@patternfly/react-core";
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon";

import "./tracker-status.css";

interface ITrackerStatusProps {
name: string;
connected: boolean;
message: string;
}
const TrackerStatus = ({ name, connected, message }: ITrackerStatusProps) => {
const { t } = useTranslation();

const [isExpanded, setIsExpanded] = useState(false);
const needsExpanding = message.length > 300;
const messageFirst = message.slice(0, 300);
const messageRest = message.slice(300);

return (
<>
<StatusIcon
Expand All @@ -34,12 +43,34 @@ const TrackerStatus = ({ name, connected, message }: ITrackerStatusProps) => {
alertSeverityVariant="danger"
headerIcon={<ExclamationCircleIcon />}
headerContent={t("composed.error", { what: t("terms.instance") })}
hasAutoWidth
onHidden={() => setIsExpanded(false)}
bodyContent={
<TextContent>
<Text>{t("message.jiraInstanceNotConnected", { name })}</Text>
<Text>{t("message.reasonForError")}</Text>
<CodeBlock>
<CodeBlockCode id="code-content">{message}</CodeBlockCode>
<CodeBlock
className="tracker-status-code"
actions={[
needsExpanding && (
<ExpandableSectionToggle
disabled={!needsExpanding}
isExpanded={isExpanded}
onToggle={setIsExpanded}
contentId="code-block-expand"
direction="up"
>
{isExpanded
? t("terms.showLess")
: t("terms.showMore")}
</ExpandableSectionToggle>
),
].filter(Boolean)}
>
<CodeBlockCode id="code-content">
{messageFirst}
{isExpanded ? messageRest : ""}
</CodeBlockCode>
</CodeBlock>
</TextContent>
}
Expand Down

0 comments on commit 90144b3

Please sign in to comment.