Skip to content

Commit 28d67e8

Browse files
committed
feat(calendar-web): default captions for empty custom toolbar items, custom view tab visibility
1 parent 3c7846d commit 28d67e8

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

packages/pluggableWidgets/calendar-web/src/Calendar.editorConfig.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@ export function getProperties(values: CalendarPreviewProps, defaultProperties: P
3232
}
3333

3434
if (values.view === "standard") {
35-
hidePropertiesIn(defaultProperties, values, ["defaultViewCustom"]);
35+
hidePropertiesIn(defaultProperties, values, [
36+
"defaultViewCustom",
37+
"toolbarItems",
38+
"customViewShowMonday",
39+
"customViewShowTuesday",
40+
"customViewShowWednesday",
41+
"customViewShowThursday",
42+
"customViewShowFriday",
43+
"customViewShowSaturday",
44+
"customViewShowSunday"
45+
]);
3646
} else {
3747
hidePropertyIn(defaultProperties, values, "defaultViewStandard");
3848
}

packages/pluggableWidgets/calendar-web/src/components/Toolbar.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export type ResolvedToolbarItem = {
5656
};
5757

5858
export function createConfigurableToolbar(items: ResolvedToolbarItem[]): (props: ToolbarProps) => ReactElement {
59-
return function ConfigurableToolbar({ label, localizer, onNavigate, onView, view, views }: ToolbarProps) {
59+
return function ConfigurableToolbar({ label, localizer, onNavigate, onView, view }: ToolbarProps) {
6060
const renderButton = (
6161
key: string,
6262
content: ReactElement | string,
@@ -75,10 +75,6 @@ export function createConfigurableToolbar(items: ResolvedToolbarItem[]): (props:
7575
</Button>
7676
);
7777

78-
const isViewEnabled = (name: View): boolean => {
79-
return Array.isArray(views) ? (views as View[]).includes(name) : true;
80-
};
81-
8278
const groups: Record<"left" | "center" | "right", ResolvedToolbarItem[]> = {
8379
left: [],
8480
center: [],
@@ -100,9 +96,10 @@ export function createConfigurableToolbar(items: ResolvedToolbarItem[]): (props:
10096
item.tooltip
10197
);
10298
case "today":
99+
// Always provide a default caption for 'today' button
103100
return renderButton(
104101
"today",
105-
(item.caption ?? localizer.messages.today) as unknown as ReactElement,
102+
(item.caption || localizer.messages.today) as unknown as ReactElement,
106103
() => onNavigate(Navigate.TODAY),
107104
false,
108105
item.renderMode,
@@ -118,6 +115,7 @@ export function createConfigurableToolbar(items: ResolvedToolbarItem[]): (props:
118115
item.tooltip
119116
);
120117
case "title":
118+
// Title always shows the formatted label, regardless of caption
121119
return (
122120
<span key="title" className="calendar-label" title={item.tooltip}>
123121
{label}
@@ -129,10 +127,8 @@ export function createConfigurableToolbar(items: ResolvedToolbarItem[]): (props:
129127
case "day":
130128
case "agenda": {
131129
const name = item.itemType as View;
132-
if (!isViewEnabled(name)) {
133-
return null;
134-
}
135-
const caption = item.caption ?? localizer.messages[name];
130+
// Provide default caption from localizer messages if not specified
131+
const caption = item.caption || localizer.messages[name];
136132
return renderButton(
137133
name,
138134
caption as unknown as ReactElement,

packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ export class CalendarPropsBuilder {
4141
? createConfigurableToolbar(this.toolbarItems)
4242
: CustomToolbar;
4343

44+
// Use custom caption for work_week if provided in toolbar items, else default to "Custom"
45+
const workWeekCaption = this.toolbarItems?.find(item => item.itemType === "work_week")?.caption || "Custom";
46+
4447
return {
4548
components: {
4649
toolbar
4750
},
4851
defaultView: this.defaultView,
4952
messages: {
50-
work_week: "Custom"
53+
work_week: workWeekCaption
5154
},
5255
events: this.events,
5356
formats,

0 commit comments

Comments
 (0)