Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Content] Enable ai assistant for all instances #3030

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 102 additions & 106 deletions src/shell/components/withAi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,114 +111,110 @@ export const withAI = (WrappedComponent: ComponentType) =>
}
};

if (isEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this variable?

Copy link
Contributor Author

@finnar-bin finnar-bin Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it in case we decide to lock this again to certain instances so we can just re-add the variable without having to rewrite the logic again. But I can remove it if it's preferred.

return (
<>
<WrappedComponent
{...props}
key={key}
endLabel={
<ThemeProvider theme={theme}>
<Button
data-cy="AIOpen"
size="xsmall"
endIcon={<Brain />}
variant="text"
color="inherit"
onClick={handleClick}
ref={aiButtonRef}
sx={{
return (
<>
<WrappedComponent
{...props}
key={key}
endLabel={
<ThemeProvider theme={theme}>
<Button
data-cy="AIOpen"
size="xsmall"
endIcon={<Brain />}
variant="text"
color="inherit"
onClick={handleClick}
ref={aiButtonRef}
sx={{
backgroundColor: (theme) =>
Boolean(anchorEl)
? alpha(theme.palette.primary.main, 0.08)
: "transparent",
minWidth: 0,
fontWeight: 600,
fontSize: 14,
lineHeight: "14px",
px: 0.5,
py: 0.25,
color: Boolean(anchorEl) ? "primary.main" : "text.disabled",

"&:hover": {
backgroundColor: (theme) =>
alpha(theme.palette.primary.main, 0.08),
color: "primary.main",
},

"&:hover .MuiButton-endIcon .MuiSvgIcon-root": {
fill: (theme) => theme.palette.primary.main,
},

"& .MuiButton-endIcon": {
ml: 0.5,
mr: 0,
},

"& .MuiButton-endIcon .MuiSvgIcon-root": {
fontSize: 16,
fill: (theme) =>
Boolean(anchorEl)
? alpha(theme.palette.primary.main, 0.08)
: "transparent",
minWidth: 0,
fontWeight: 600,
fontSize: 14,
lineHeight: "14px",
px: 0.5,
py: 0.25,
color: Boolean(anchorEl) ? "primary.main" : "text.disabled",

"&:hover": {
backgroundColor: (theme) =>
alpha(theme.palette.primary.main, 0.08),
color: "primary.main",
},

"&:hover .MuiButton-endIcon .MuiSvgIcon-root": {
fill: (theme) => theme.palette.primary.main,
},

"& .MuiButton-endIcon": {
ml: 0.5,
mr: 0,
},

"& .MuiButton-endIcon .MuiSvgIcon-root": {
fontSize: 16,
fill: (theme) =>
Boolean(anchorEl)
? theme.palette.primary.main
: theme.palette.action.active,
},
}}
>
AI
</Button>
</ThemeProvider>
}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ThemeProvider theme={theme}>
<Popover
data-cy="AIPopover"
open={Boolean(anchorEl)}
anchorEl={anchorEl}
anchorOrigin={{
vertical: "top",
horizontal: "right",
}}
elevation={24}
onClose={() => {
console.log("closing ai generator");
handleClose("close");
}}
slotProps={{
paper: {
sx: {
overflowY: "hidden",

"&:after": {
content: '""',
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
background:
"linear-gradient(0deg, rgba(255,93,10,1) 0%, rgba(18,183,106,1) 25%, rgba(11,165,236,1) 50%, rgba(238,70,188,1) 75%, rgba(105,56,239,1) 100%)",
animation: `${rotateAnimation} 1.5s linear alternate infinite`,
backgroundSize: "300% 300%",
},
? theme.palette.primary.main
: theme.palette.action.active,
},
}}
>
AI
</Button>
</ThemeProvider>
}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ThemeProvider theme={theme}>
<Popover
data-cy="AIPopover"
open={Boolean(anchorEl)}
anchorEl={anchorEl}
anchorOrigin={{
vertical: "top",
horizontal: "right",
}}
elevation={24}
onClose={() => {
console.log("closing ai generator");
handleClose("close");
}}
slotProps={{
paper: {
sx: {
overflowY: "hidden",

"&:after": {
content: '""',
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
background:
"linear-gradient(0deg, rgba(255,93,10,1) 0%, rgba(18,183,106,1) 25%, rgba(11,165,236,1) 50%, rgba(238,70,188,1) 75%, rgba(105,56,239,1) 100%)",
animation: `${rotateAnimation} 1.5s linear alternate infinite`,
backgroundSize: "300% 300%",
},
},
}}
>
<AIGenerator
fieldZUID={props.ZUID}
onApprove={handleApprove}
onClose={(reason) => handleClose(reason)}
aiType={props.aiType}
label={props.label}
isAIAssistedFlow={props.isAIAssistedFlow}
/>
</Popover>
</ThemeProvider>
</>
);
} else {
return <WrappedComponent {...props} />;
}
},
}}
>
<AIGenerator
fieldZUID={props.ZUID}
onApprove={handleApprove}
onClose={(reason) => handleClose(reason)}
aiType={props.aiType}
label={props.label}
isAIAssistedFlow={props.isAIAssistedFlow}
/>
</Popover>
</ThemeProvider>
</>
);
});
Loading