Skip to content

Commit

Permalink
[Content] Enable ai assistant for all instances (#3030)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin and agalin920 authored Oct 23, 2024
1 parent 889b64b commit 0f4d085
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 110 deletions.
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) {
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>
</>
);
});

0 comments on commit 0f4d085

Please sign in to comment.