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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cypress/e2e/content/content.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ describe("Content Specs", () => {
cy.get("#12-f3db44-c8kt0q")
.find("[data-cy='dateTimeInputField']")
.find("input")
.should("have.value", "11:00 pm");
.should("have.value", "12:00 pm");
});
});
});
8 changes: 5 additions & 3 deletions src/shell/components/FieldTypeDateTime/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1470,16 +1470,18 @@ export const TIMEZONES = [
] as const;

// Specify exact ISO format. This ensures consistent parsing across different browsers.
const ISO_FORMAT = "MM/DD/YYYY HH:mm:ss.SSSSSS";
const ISO_FORMAT = "YYYY-MM-DD h:mm a";

export const toISOString = (timeString: string) => {
return moment(`01-01-2024 ${timeString}`, ISO_FORMAT).format(
return moment(`2024-01-01 ${timeString}`, ISO_FORMAT).format(
"HH:mm:ss.SSSSSS"
);
};

export const to12HrTime = (isoTime: string) => {
return moment(`01/01/2024 ${isoTime}`, ISO_FORMAT).format("h:mm a");
return moment(`2024-01-01 ${isoTime}`, "YYYY-MM-DD HH:mm:ss.SSSSSS").format(
"h:mm a"
);
};

const generateTimeOptions = () => {
Expand Down
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