-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui changes for pipeline summarization using genai
- Loading branch information
Showing
12 changed files
with
372 additions
and
107 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
92 changes: 92 additions & 0 deletions
92
...lineDetails/PipelineDetailsTopPanel/PipelineDetailsButtons/PipelineGenaiSummaryButton.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,92 @@ | ||
/* | ||
* Copyright © 2024 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import React, { useEffect, useRef, useState } from 'react'; | ||
import classnames from 'classnames'; | ||
import GraphicEqIcon from '@material-ui/icons/GraphicEq'; | ||
import T from 'i18n-react'; | ||
import { PrimaryTextLowercaseButton } from 'components/shared/Buttons/PrimaryTextLowercaseButton'; | ||
import styled from 'styled-components'; | ||
import { PipelineGenaiSummaryModal } from '../PipelineGenaiSummaryModal'; | ||
import { MyAppApi } from 'api/app'; | ||
import { getCurrentNamespace } from 'services/NamespaceStore'; | ||
|
||
const PREFIX = 'features.PipelineDetails.TopPanel'; | ||
|
||
interface IPipelineGenaiSummaryButtonProps { | ||
pipelineName: string; | ||
} | ||
|
||
const StyledSummarizeIcon = styled(GraphicEqIcon)` | ||
margin-bottom: -4px; | ||
`; | ||
|
||
const GenaiButton = styled.div` | ||
padding: 0; | ||
`; | ||
|
||
export const PipelineGenaiSummaryButton = ({ pipelineName }: IPipelineGenaiSummaryButtonProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [summary, setSummary] = useState(''); | ||
const buttonRef = useRef(null); | ||
|
||
useEffect(() => { | ||
MyAppApi.summarize({ | ||
namespace: getCurrentNamespace(), | ||
appId: pipelineName, | ||
}).subscribe((res) => { | ||
setSummary(res); | ||
}); | ||
}, []); | ||
|
||
const toggleButton = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const renderPipelineGenaiSummaryBtn = () => { | ||
return ( | ||
<GenaiButton className="btn pipeline-action-btn" ref={buttonRef}> | ||
<PrimaryTextLowercaseButton | ||
onClick={toggleButton} | ||
data-cy="pipeline-genai-summary-btn" | ||
data-testid="pipeline-genai-summary-btn" | ||
> | ||
<div className="btn-container"> | ||
<StyledSummarizeIcon viewBox="1 1 22 22" /> | ||
<div className="button-label">{T.translate(`${PREFIX}.genaiSummarize`)}</div> | ||
</div> | ||
</PrimaryTextLowercaseButton> | ||
</GenaiButton> | ||
); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={classnames('pipeline-action-container pipeline-history-container', { | ||
active: isOpen, | ||
})} | ||
> | ||
{renderPipelineGenaiSummaryBtn()} | ||
<PipelineGenaiSummaryModal | ||
isOpen={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
anchorEl={buttonRef.current} | ||
pipelineName={pipelineName} | ||
summary={summary} | ||
/> | ||
</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
85 changes: 85 additions & 0 deletions
85
app/cdap/components/PipelineDetails/PipelineDetailsTopPanel/PipelineGenaiSummaryModal.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,85 @@ | ||
/* | ||
* Copyright © 2024 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import T from 'i18n-react'; | ||
import PipelineModeless from 'components/PipelineDetails/PipelineModeless'; | ||
import MarkdownWithStyles from 'components/shared/Markdown'; | ||
import LoadingSVG from 'components/shared/LoadingSVG'; | ||
|
||
const PREFIX = 'features.PipelineDetails.TopPanel'; | ||
|
||
interface IPipelineGenaiSummaryModalProps { | ||
pipelineName?: string; | ||
summary: string; | ||
anchorEl: any; | ||
onClose: () => void; | ||
isOpen: boolean; | ||
} | ||
|
||
const SummaryContainer = styled.div` | ||
height: 100%; | ||
width: 100%; | ||
max-width: 880px; | ||
max-height: min(60vh, 800px); | ||
padding: 0 20px; | ||
overflow: auto; | ||
`; | ||
|
||
const PopperClass = styled.div` | ||
max-width: 880px; | ||
`; | ||
|
||
const LoadingContainer = styled.div` | ||
width: 100%; | ||
height: 100px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const PipelineGenaiSummaryModal = ({ | ||
pipelineName, | ||
summary, | ||
anchorEl, | ||
onClose, | ||
isOpen, | ||
}: IPipelineGenaiSummaryModalProps) => { | ||
return ( | ||
<PipelineModeless | ||
open={isOpen} | ||
onClose={onClose} | ||
anchorEl={anchorEl} | ||
popoverClassName={String(PopperClass)} | ||
title={ | ||
pipelineName | ||
? T.translate(`${PREFIX}.genaiSummaryOfPipeline`, { pipelineName }) | ||
: T.translate(`${PREFIX}.genaiSummaryOfUnnamedPipeline`) | ||
} | ||
> | ||
<SummaryContainer> | ||
{summary ? ( | ||
<MarkdownWithStyles markdown={summary} /> | ||
) : ( | ||
<LoadingContainer> | ||
<LoadingSVG /> | ||
</LoadingContainer> | ||
)} | ||
</SummaryContainer> | ||
</PipelineModeless> | ||
); | ||
}; |
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
Oops, something went wrong.