Skip to content

Commit

Permalink
feat: add more tip in ai-assistant plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Nov 4, 2023
1 parent 86088a3 commit caad90c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
57 changes: 32 additions & 25 deletions client/web/plugins/com.msgbyte.ai-assistant/src/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const ActionButton = styled.div`
}
`;

const ActionTip = styled.div`
font-size: 12px;
opacity: 0.6;
`;

export const AssistantPopover: React.FC<{
onCompleted: () => void;
}> = React.memo((props) => {
Expand Down Expand Up @@ -115,31 +120,6 @@ export const AssistantPopover: React.FC<{

<Tip>{Translate.helpMeTo}</Tip>

{typeof message === 'string' && message.length > 0 && (
<>
<ActionButton
onClick={() => handleCallAI(improveTextPrompt + message)}
>
{Translate.improveText}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(shorterTextPrompt + message)}
>
{Translate.makeShorter}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(longerTextPrompt + message)}
>
{Translate.makeLonger}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(translateTextPrompt + message)}
>
{Translate.translateInputText}
</ActionButton>
</>
)}

<ActionButton
onClick={async () => {
const plainMessages = (
Expand All @@ -165,6 +145,33 @@ export const AssistantPopover: React.FC<{
>
{Translate.summaryMessages}
</ActionButton>

{typeof message === 'string' && message.length > 0 ? (
<>
<ActionButton
onClick={() => handleCallAI(improveTextPrompt + message)}
>
{Translate.improveText}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(shorterTextPrompt + message)}
>
{Translate.makeShorter}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(longerTextPrompt + message)}
>
{Translate.makeLonger}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(translateTextPrompt + message)}
>
{Translate.translateInputText}
</ActionButton>
</>
) : (
<ActionTip>{Translate.inputTextShowMoreActionTip}</ActionTip>
)}
</Root>
);
});
Expand Down
4 changes: 4 additions & 0 deletions client/web/plugins/com.msgbyte.ai-assistant/src/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const Translate = {
'zh-CN': '翻译输入内容',
'en-US': 'Translate Input',
}),
inputTextShowMoreActionTip: localTrans({
'zh-CN': '或者输入内容后展示更多操作',
'en-US': 'Or input message then show more actions',
}),
usage: localTrans({
'zh-CN': '用时',
'en-US': 'Usage',
Expand Down

0 comments on commit caad90c

Please sign in to comment.