Skip to content
Closed
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
9 changes: 9 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
"webiny": {
"command": "npx",
"args": ["webiny-mcp", "serve", "--skills=./skills"]
},
"stdlib": {
"command": "npx",
"args": ["-y", "@webiny/stdlib", "serve"]
},
"codegraph": {
"type": "stdio",
"command": "codegraph",
"args": ["serve", "--mcp"]
}
}
}
14 changes: 14 additions & 0 deletions extensions/folderDropConfirmation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import { ContentEntryListConfig } from "webiny/admin/cms/entry/list";

const { Browser } = ContentEntryListConfig;

const FolderDropConfirmationExtension = () => {
return (
<ContentEntryListConfig>
<Browser.Folder.DropConfirmation value={true} />
</ContentEntryListConfig>
);
};

export default FolderDropConfirmationExtension;
5 changes: 4 additions & 1 deletion packages/admin-ui/src/Sidebar/components/SidebarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const SidebarContent = ({ className, children, ...props }: React.ComponentProps<
return (
<ScrollArea
data-sidebar="content"
className={cn("flex text-neutral-primary min-h-0 flex-1 flex-col gap-2", className)}
className={cn(
"flex text-neutral-primary min-h-0 flex-1 flex-col gap-2 [&_[data-radix-scroll-area-viewport]>div]:!block",
className
)}
{...restProps}
>
{children}
Expand Down
5 changes: 4 additions & 1 deletion packages/admin-ui/src/Sidebar/components/SidebarRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const SidebarRoot = ({ side = "left", className, children, ...props }: SidebarRo
)}
{...props}
>
<div data-sidebar="sidebar" className="flex h-full w-full py-xs flex-col">
<div
data-sidebar="sidebar"
className="flex h-full w-full py-xs flex-col overflow-hidden"
>
{children}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { cva } from "~/utils.js";
import { cn, cva } from "~/utils.js";
import type { SidebarMenuItemProps } from "./SidebarMenuRootItem.js";
import { DivButton } from "./DivButton.js";
import { SidebarMenuItemBadge } from "./SidebarMenuItemBadge.js";
Expand Down Expand Up @@ -58,14 +58,16 @@ const SidebarMenuSubButton = ({
const sharedProps = {
"data-sidebar": "menu-sub-button",
"data-active": active,
className: variants({ variant, disabled, className }),
className: variants({ variant, disabled, className: cn(className, action && "pr-xl") }),
onClick
};

const textContent = <span className="truncate">{text}</span>;

const content = to ? (
<LinkComponent {...sharedProps} to={to} {...linkProps}>
{icon}
{text}
{textContent}
{badge && (typeof badge === "string" ? <SidebarMenuItemBadge text={badge} /> : badge)}
</LinkComponent>
) : (
Expand All @@ -77,13 +79,13 @@ const SidebarMenuSubButton = ({
tabIndex={variant === "group-label" ? -1 : undefined}
>
{icon}
{text}
{textContent}
{badge && (typeof badge === "string" ? <SidebarMenuItemBadge text={badge} /> : badge)}
</DivButton>
);

return (
<div className={"flex items-center w-full relative group/menu-sub-button"}>
<div className={"flex items-center w-full min-w-0 relative group/menu-sub-button"}>
{content}

{action && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const SidebarMenuSubItem = ({

if (!collapsible) {
return (
<div className={"flex items-center"}>
<div className={"flex items-center min-w-0"}>
<SidebarMenuSubItemIndentation
lvl={currentLevel}
variant={buttonProps.variant}
Expand All @@ -177,7 +177,7 @@ const SidebarMenuSubItem = ({
open={isSectionExpanded}
onOpenChange={toggleSectionExpanded}
>
<div className={"flex items-center"}>
<div className={"flex items-center min-w-0"}>
<SidebarMenuSubItemIndentation
lvl={currentLevel}
variant={buttonProps.variant}
Expand Down Expand Up @@ -213,7 +213,7 @@ const SidebarMenuSubItem = ({
<>
<li
data-sidebar="menu-sub-item"
className={cn("group/menu-sub-item relative flex", className)}
className={cn("group/menu-sub-item relative flex min-w-0", className)}
>
{sidebarMenuSubButton}
</li>
Expand Down
10 changes: 7 additions & 3 deletions packages/admin-ui/src/Tree/useTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export const useTree = <TData = Record<string, any>>(props: TreeProps<TData>) =>
});
});

await presenter.handleDrop(newNodeTree);

if (props.onDrop) {
const { dragSourceId, dropTargetId } = options;

Expand All @@ -70,8 +68,14 @@ export const useTree = <TData = Record<string, any>>(props: TreeProps<TData>) =>
dropTarget: newTreeDto.find(node => node.id === String(options.dropTargetId))
};

await props.onDrop(newTreeDto, dropOptions);
try {
await props.onDrop(newTreeDto, dropOptions);
} catch {
return;
}
}

await presenter.handleDrop(newNodeTree);
};

const changeOpen = (newOpenIds: NodeModel<TData>["id"][]) => {
Expand Down
10 changes: 10 additions & 0 deletions packages/api-scheduler/__tests__/SchedulerService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CreateScheduleCommand,
DeleteScheduleCommand,
GetScheduleCommand,
ResourceNotFoundException,
SchedulerClient,
UpdateScheduleCommand
} from "@webiny/aws-sdk/client-scheduler/index.js";
Expand Down Expand Up @@ -46,6 +47,15 @@ describe("SchedulerService", () => {

it("throws if creating a schedule in the past", async () => {
const client = mockClient(SchedulerClient);
client.on(GetScheduleCommand).rejects(
new ResourceNotFoundException({
Message: "Resource not found.",
message: "Resource not found.",
$metadata: {
httpStatusCode: 404
}
})
);
const service = new EventBridgeSchedulerService(() => client, config);

const input: SchedulerServiceCreateInput = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
DeleteScheduleCommand,
GetScheduleCommand,
type SchedulerClient,
UpdateScheduleCommand
UpdateScheduleCommand,
ResourceNotFoundException
} from "@webiny/aws-sdk/client-scheduler/index.js";
import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "~/constants.js";
import type { IScheduledActionEventPayload } from "~/createEventHandler.js";
Expand All @@ -34,6 +35,66 @@ export class EventBridgeSchedulerService implements SchedulerService.Interface {
) {}

public async create(params: SchedulerService.CreateParams): Promise<void> {
// Check if schedule already exists (for auto-update logic)
const exists = await this.exists(params);
if (exists) {
return this.updateInternal(params);
}

return await this.createInternal(params);
}

public async update(params: SchedulerService.UpdateParams): Promise<void> {
const exists = await this.exists(params);
if (exists) {
return await this.updateInternal(params);
}
return await this.create(params);
}

public async delete(params: SchedulerService.DeleteParams): Promise<void> {
const client = this.getClient();

const exists = await this.exists(params);
if (!exists) {
throw new WebinyError(
`Cannot delete schedule "${params.id}", tenant "${params.tenant}", because it does not exist.`
);
}

const name = this.createScheduleName(params);

try {
await client.send(new DeleteScheduleCommand({ Name: name }));
} catch (ex) {
if (ex instanceof ResourceNotFoundException) {
return;
} else if (ex.name === "ResourceNotFoundException") {
return;
}
throw WebinyError.from(ex);
}
}

public async exists(params: SchedulerService.ExistsParams): Promise<boolean> {
const client = this.getClient();

const name = this.createScheduleName(params);

try {
await client.send(new GetScheduleCommand({ Name: name }));
return true;
} catch (ex) {
if (ex instanceof ResourceNotFoundException) {
return false;
} else if (ex.name === "ResourceNotFoundException") {
return false;
}
throw ex;
}
}

private async createInternal(params: SchedulerService.CreateParams): Promise<void> {
const { id, scheduleFor, tenant } = params;

// Validate date is in future
Expand All @@ -51,12 +112,6 @@ export class EventBridgeSchedulerService implements SchedulerService.Interface {

const client = this.getClient();

// Check if schedule already exists (for auto-update logic)
const exists = await this.exists(params);
if (exists) {
return this.update(params);
}

await client.send(
new CreateScheduleCommand({
Name: this.createScheduleName(params),
Expand All @@ -74,7 +129,7 @@ export class EventBridgeSchedulerService implements SchedulerService.Interface {
);
}

public async update(params: SchedulerService.UpdateParams): Promise<void> {
private async updateInternal(params: SchedulerService.UpdateParams): Promise<void> {
const { id, scheduleFor } = params;

// Validate date is in future
Expand Down Expand Up @@ -108,44 +163,6 @@ export class EventBridgeSchedulerService implements SchedulerService.Interface {
);
}

public async delete(params: SchedulerService.DeleteParams): Promise<void> {
const client = this.getClient();

const exists = await this.exists(params);
if (!exists) {
throw new WebinyError(
`Cannot delete schedule "${params.id}", tenant "${params.tenant}", because it does not exist.`
);
}

const name = this.createScheduleName(params);

try {
await client.send(new DeleteScheduleCommand({ Name: name }));
} catch (ex) {
if (ex.name === "ResourceNotFoundException") {
return;
}
throw WebinyError.from(ex);
}
}

public async exists(params: SchedulerService.ExistsParams): Promise<boolean> {
const client = this.getClient();

const name = this.createScheduleName(params);

try {
await client.send(new GetScheduleCommand({ Name: name }));
return true;
} catch (ex) {
if (ex.name === "ResourceNotFoundException") {
return false;
}
throw ex;
}
}

private createScheduleExpression(scheduleFor: Date): string {
// Format: at(YYYY-MM-DDTHH:mm:ss) - EventBridge expects this format
return `at(${scheduleFor.toISOString().replace(/\.\d{3}Z$/, "")})`;
Expand Down
22 changes: 15 additions & 7 deletions packages/app-aco/src/components/FolderTree/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,25 @@ export const List = ({

// Abort if either folder is not found
if (!folder || !targetFolder) {
return;
throw new Error("Folder not found");
}

showConfirmMoveFolderDialog({
folder,
targetFolder,
onAccept: runDrop
await new Promise<void>((resolve, reject) => {
showConfirmMoveFolderDialog({
folder,
targetFolder,
onAccept: async () => {
await runDrop();
resolve();
},
onClose: () => {
reject(new Error("cancelled"));
}
});
});
} else {
// Otherwise, perform the drop immediately
await runDrop();
// Fire API call without awaiting — optimistic UI
runDrop();
}
},
[folders, dropConfirmation, showConfirmMoveFolderDialog]
Expand Down
6 changes: 4 additions & 2 deletions packages/app-aco/src/dialogs/useConfirmMoveFolderDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface ShowDialogParams {
folder: FolderDto;
targetFolder: FolderDto;
onAccept: (folder: FolderDto, targetFolder: FolderDto) => Promise<void>;
onClose?: () => void;
}

interface UseConfirmMoveFolderDialogResponse {
Expand All @@ -14,14 +15,15 @@ interface UseConfirmMoveFolderDialogResponse {
export const useConfirmMoveFolderDialog = (): UseConfirmMoveFolderDialogResponse => {
const dialogs = useDialogs();

const showDialog = ({ folder, targetFolder, onAccept }: ShowDialogParams) => {
const showDialog = ({ folder, targetFolder, onAccept, onClose }: ShowDialogParams) => {
dialogs.showDialog({
title: "Move folder",
content: `You are about to move the folder "${folder.title}" into "${targetFolder.title}"! Are you sure you want to continue?`,
acceptLabel: "Move folder",
cancelLabel: "Cancel",
loadingLabel: "Moving folder...",
onAccept: () => onAccept(folder, targetFolder)
onAccept: () => onAccept(folder, targetFolder),
onClose
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const SidebarContent = () => {
<div className={"flex-1 overflow-y-scroll"}>
<FolderTree
folderActions={browser.folder.actions}
dropConfirmation={browser.folder.dropConfirmation}
focusedFolderId={currentFolderId}
onFolderClick={data => navigateToFolder(data.id)}
enableActions={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TemplateGridItem = makeDecoratable(
<Text size={"md"} className={"mb-xs text-neutral-primary font-semibold"}>
{template.name}
</Text>
<Text size={"sm"} as={"div"} className={"text-neutral-muted"}>
<Text size={"sm"} as={"div"} className={"text-neutral-muted line-clamp-2"}>
{template.description}
</Text>
</div>
Expand Down
Loading