mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): allow editing calendar name (#12251)
close AF-2569 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to edit calendar subscription names directly within the interface using an inline editor. - **Style** - Improved the appearance of calendar subscription names by updating layout and alignment for better readability. - **Bug Fixes** - Ensured that custom calendar subscription names are displayed and updated correctly. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -80,6 +80,9 @@ export const name = style({
|
|||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
|
padding: '0px 4px',
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const allDayEventsContainer = style({
|
export const allDayEventsContainer = style({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Menu, useConfirmModal } from '@affine/component';
|
import { Button, InlineEdit, Menu, useConfirmModal } from '@affine/component';
|
||||||
import {
|
import {
|
||||||
type CalendarSubscription,
|
type CalendarSubscription,
|
||||||
IntegrationService,
|
IntegrationService,
|
||||||
@@ -41,6 +41,13 @@ export const SubscriptionSetting = ({
|
|||||||
});
|
});
|
||||||
}, [calendar, subscription.url, config?.showAllDayEvents]);
|
}, [calendar, subscription.url, config?.showAllDayEvents]);
|
||||||
|
|
||||||
|
const handleNameChange = useCallback(
|
||||||
|
(value: string) => {
|
||||||
|
calendar.updateSubscription(subscription.url, { name: value });
|
||||||
|
},
|
||||||
|
[calendar, subscription.url]
|
||||||
|
);
|
||||||
|
|
||||||
if (!config) return null;
|
if (!config) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -61,7 +68,13 @@ export const SubscriptionSetting = ({
|
|||||||
style={{ color: config.color }}
|
style={{ color: config.color }}
|
||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
<div className={styles.name}>{name}</div>
|
<InlineEdit
|
||||||
|
className={styles.name}
|
||||||
|
editable
|
||||||
|
trigger="click"
|
||||||
|
value={name}
|
||||||
|
onChange={handleNameChange}
|
||||||
|
/>
|
||||||
<UnsubscribeButton url={subscription.url} name={name} />
|
<UnsubscribeButton url={subscription.url} name={name} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.divider} />
|
<div className={styles.divider} />
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ export class CalendarSubscription extends Entity<{ url: string }> {
|
|||||||
this.store.watchSubscriptionCache(this.props.url),
|
this.store.watchSubscriptionCache(this.props.url),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
name$ = this.content$.selector(content => {
|
name$ = LiveData.computed(get => {
|
||||||
|
const config = get(this.config$);
|
||||||
|
if (config?.name !== undefined) {
|
||||||
|
return config.name;
|
||||||
|
}
|
||||||
|
const content = get(this.content$);
|
||||||
if (!content) return '';
|
if (!content) return '';
|
||||||
try {
|
try {
|
||||||
const jCal = ICAL.parse(content ?? '');
|
const jCal = ICAL.parse(content ?? '');
|
||||||
@@ -42,6 +47,7 @@ export class CalendarSubscription extends Entity<{ url: string }> {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventsByDateMap$ = LiveData.computed(get => {
|
eventsByDateMap$ = LiveData.computed(get => {
|
||||||
const content = get(this.content$);
|
const content = get(this.content$);
|
||||||
const config = get(this.config$);
|
const config = get(this.config$);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { WorkspaceService } from '../../workspace';
|
|||||||
|
|
||||||
export interface CalendarSubscriptionConfig {
|
export interface CalendarSubscriptionConfig {
|
||||||
color: string;
|
color: string;
|
||||||
|
name?: string;
|
||||||
showEvents?: boolean;
|
showEvents?: boolean;
|
||||||
showAllDayEvents?: boolean;
|
showAllDayEvents?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user