[fix] removed added calendars old naming convention (#567)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -11,7 +11,8 @@ import {
|
||||
import { useState, useEffect } from "react";
|
||||
import { HexColorPicker } from "react-colorful";
|
||||
import { useI18n } from "twake-i18n";
|
||||
import { defaultColors, getAccessiblePair } from "./utils/calendarColorsUtils";
|
||||
import { getAccessiblePair } from "./utils/calendarColorsUtils";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
|
||||
export function ColorPicker({
|
||||
selectedColor,
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ResponsiveDialog } from "../Dialog";
|
||||
import { AccessTab } from "./AccessTab";
|
||||
import { ImportTab } from "./ImportTab";
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { defaultColors } from "./utils/calendarColorsUtils";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
|
||||
function CalendarPopover({
|
||||
open,
|
||||
|
||||
@@ -1,17 +1,42 @@
|
||||
import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import { Box, Typography } from "@linagora/twake-mui";
|
||||
import SquareRoundedIcon from "@mui/icons-material/SquareRounded";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
import { makeDisplayName } from "@/utils/makeDisplayName";
|
||||
import { OwnerCaption } from "./OwnerCaption";
|
||||
import { useAppSelector } from "@/app/hooks";
|
||||
|
||||
export function CalendarName({ calendar }: { calendar: Calendar }) {
|
||||
const userData = useAppSelector((state) => state.user.userData);
|
||||
const showCaption =
|
||||
calendar.name !== "#default" &&
|
||||
userData.openpaasId !== calendar.id.split("/")[0];
|
||||
|
||||
return (
|
||||
<Box style={{ display: "flex", flexDirection: "row", gap: 8 }}>
|
||||
<Box
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
gap: 8,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<SquareRoundedIcon
|
||||
style={{
|
||||
color: calendar.color?.light ?? "#3788D8",
|
||||
color: calendar.color?.light ?? defaultColors[0].light,
|
||||
width: 24,
|
||||
height: 24,
|
||||
}}
|
||||
/>
|
||||
<Typography sx={{ wordBreak: "break-word" }}>{calendar.name}</Typography>
|
||||
<Box style={{ display: "flex", flexDirection: "column" }}>
|
||||
<Typography sx={{ wordBreak: "break-word" }}>
|
||||
{calendar.name}
|
||||
</Typography>
|
||||
<OwnerCaption
|
||||
showCaption={showCaption}
|
||||
ownerDisplayName={makeDisplayName(calendar) ?? ""}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ import { PeopleSearch, User } from "../Attendees/PeopleSearch";
|
||||
import { ResponsiveDialog } from "../Dialog";
|
||||
import { stringAvatar } from "../Event/utils/eventUtils";
|
||||
import { ColorPicker } from "./CalendarColorPicker";
|
||||
import { defaultColors, getAccessiblePair } from "./utils/calendarColorsUtils";
|
||||
import { getAccessiblePair } from "./utils/calendarColorsUtils";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
|
||||
interface CalendarWithOwner {
|
||||
cal: CalendarData;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useAppDispatch, useAppSelector } from "@/app/hooks";
|
||||
import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import { removeCalendarAsync } from "@/features/Calendars/services";
|
||||
import { extractEventBaseUuid } from "@/utils/extractEventBaseUuid";
|
||||
import { makeDisplayName } from "@/utils/makeDisplayName";
|
||||
import { renameDefault } from "@/utils/renameDefault";
|
||||
import { trimLongTextWithoutSpace } from "@/utils/textUtils";
|
||||
import {
|
||||
@@ -23,6 +24,7 @@ import { useI18n } from "twake-i18n";
|
||||
import CalendarPopover from "./CalendarModal";
|
||||
import CalendarSearch from "./CalendarSearch";
|
||||
import { DeleteCalendarDialog } from "./DeleteCalendarDialog";
|
||||
import { OwnerCaption } from "./OwnerCaption";
|
||||
|
||||
function CalendarAccordion({
|
||||
title,
|
||||
@@ -260,6 +262,20 @@ function CalendarSelector({
|
||||
() => trimLongTextWithoutSpace(calendars[id].name),
|
||||
[calendars, id]
|
||||
);
|
||||
|
||||
const ownerDisplayName = useMemo(
|
||||
() => makeDisplayName(calendars[id]),
|
||||
[calendars, id]
|
||||
);
|
||||
|
||||
const displayName = useMemo(
|
||||
() => renameDefault(trimmedName, ownerDisplayName ?? "", t, isPersonal),
|
||||
[trimmedName, ownerDisplayName, t, isPersonal]
|
||||
);
|
||||
|
||||
const showCaption =
|
||||
!isPersonal && trimmedName !== "#default" && ownerDisplayName != null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListItem
|
||||
@@ -291,16 +307,30 @@ function CalendarSelector({
|
||||
size="small"
|
||||
checked={selectedCalendars.includes(id)}
|
||||
onChange={() => handleCalendarToggle(id)}
|
||||
inputProps={{ "aria-label": displayName }}
|
||||
/>
|
||||
<span
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
wordBreak: "break-word",
|
||||
padding: showCaption ? "6px" : undefined,
|
||||
}}
|
||||
>
|
||||
{renameDefault(trimmedName, calendars[id].owner, t, isPersonal)}
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
wordBreak: "break-word",
|
||||
}}
|
||||
>
|
||||
{displayName}
|
||||
</span>
|
||||
<OwnerCaption
|
||||
showCaption={showCaption}
|
||||
ownerDisplayName={ownerDisplayName ?? ""}
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
<IconButton className="MoreBtn" onClick={handleClick}>
|
||||
<MoreHorizIcon />
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Typography } from "@linagora/twake-mui";
|
||||
|
||||
export function OwnerCaption({
|
||||
showCaption,
|
||||
ownerDisplayName,
|
||||
}: {
|
||||
showCaption: boolean;
|
||||
ownerDisplayName: string;
|
||||
}) {
|
||||
return (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="text.secondary"
|
||||
style={{
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
wordBreak: "break-word",
|
||||
}}
|
||||
>
|
||||
{showCaption && ownerDisplayName}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { AppDispatch } from "@/app/store";
|
||||
import { updateCalColor } from "@/features/Calendars/CalendarSlice";
|
||||
import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import { darken, getContrastRatio, lighten, Theme } from "@linagora/twake-mui";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
|
||||
export function updateDarkColor(
|
||||
calendars: Record<string, Calendar>,
|
||||
@@ -53,10 +54,3 @@ export function getAccessiblePair(baseColor: string, theme: Theme): string {
|
||||
|
||||
return theme.palette.getContrastText(baseColor);
|
||||
}
|
||||
|
||||
export const defaultColors = [
|
||||
{ light: "#D0ECDA", dark: "#329655" },
|
||||
{ light: "#FAE3CE", dark: "#E15300" },
|
||||
{ light: "#F5CFD0", dark: "#BE0103" },
|
||||
{ light: "#AFCBEF", dark: "#0654B1" },
|
||||
];
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import { RepetitionObject } from "@/features/Events/EventsTypes";
|
||||
import { userAttendee } from "@/features/User/models/attendee";
|
||||
import iconCamera from "@/static/images/icon-camera.svg";
|
||||
import { defaultColors } from "@/utils/defaultColors";
|
||||
import { makeDisplayName } from "@/utils/makeDisplayName";
|
||||
import {
|
||||
addVideoConferenceToDescription,
|
||||
generateMeetingLink,
|
||||
@@ -35,6 +37,7 @@ import React from "react";
|
||||
import { useI18n } from "twake-i18n";
|
||||
import AttendeeSelector from "../Attendees/AttendeeSearch";
|
||||
import { CalendarItemList } from "../Calendar/CalendarItemList";
|
||||
import { OwnerCaption } from "../Calendar/OwnerCaption";
|
||||
import { SnackbarAlert } from "../Loading/SnackBarAlert";
|
||||
import { TimezoneAutocomplete } from "../Timezone/TimezoneAutocomplete";
|
||||
import { AddDescButton } from "./AddDescButton";
|
||||
@@ -775,7 +778,7 @@ export default function EventFormFields({
|
||||
sx={{
|
||||
color:
|
||||
userPersonalCalendars.find((cal) => cal.id === calendarid)
|
||||
?.color?.light ?? "#3788D8",
|
||||
?.color?.light ?? defaultColors[0].light,
|
||||
width: 24,
|
||||
height: 24,
|
||||
}}
|
||||
@@ -783,8 +786,34 @@ export default function EventFormFields({
|
||||
}
|
||||
onClick={() => setHasClickedCalendarSection(true)}
|
||||
>
|
||||
{userPersonalCalendars.find((cal) => cal.id === calendarid)?.name ||
|
||||
t("event.form.calendar")}
|
||||
{userPersonalCalendars.find((cal) => cal.id === calendarid)
|
||||
?.name ? (
|
||||
<Box style={{ display: "flex", flexDirection: "column" }}>
|
||||
<Typography sx={{ wordBreak: "break-word" }}>
|
||||
{
|
||||
userPersonalCalendars.find((cal) => cal.id === calendarid)
|
||||
?.name
|
||||
}
|
||||
</Typography>
|
||||
<OwnerCaption
|
||||
showCaption={
|
||||
delegatedCalendars.find((cal) => cal.id === calendarid) !==
|
||||
undefined &&
|
||||
userPersonalCalendars.find((cal) => cal.id === calendarid)
|
||||
?.name !== "#default"
|
||||
}
|
||||
ownerDisplayName={
|
||||
makeDisplayName(
|
||||
userPersonalCalendars.find(
|
||||
(cal) => cal.id === calendarid
|
||||
) ?? ({} as Calendar)
|
||||
) ?? ""
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
t("event.form.calendar")
|
||||
)}
|
||||
</SectionPreviewRow>
|
||||
) : (
|
||||
<FormControl fullWidth margin="dense" size="small">
|
||||
|
||||
Reference in New Issue
Block a user