From c2c94a9bf2b930b8d1f3ea1a7acca8bde72f1f4f Mon Sep 17 00:00:00 2001 From: lethemanh Date: Wed, 18 Mar 2026 20:13:18 +0700 Subject: [PATCH] #637 modify resource --- src/components/Calendar/AccessTab.tsx | 9 +- src/components/Calendar/CalendarSelection.tsx | 5 +- src/components/Calendar/SettingsTab.tsx | 91 +++++++++++++------ .../Calendars/api/addCalendarResourceAsync.ts | 2 +- src/features/Events/EventModal.tsx | 1 + src/locales/en.json | 3 +- src/locales/fr.json | 3 +- src/locales/ru.json | 3 +- src/locales/vi.json | 3 +- 9 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/components/Calendar/AccessTab.tsx b/src/components/Calendar/AccessTab.tsx index 3c6cbe4..1452a54 100644 --- a/src/components/Calendar/AccessTab.tsx +++ b/src/components/Calendar/AccessTab.tsx @@ -14,7 +14,7 @@ import { } from "@linagora/twake-mui"; import ContentCopyIcon from "@mui/icons-material/ContentCopy"; import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useI18n } from "twake-i18n"; import { ErrorSnackbar } from "../Error/ErrorSnackbar"; import { FieldWithLabel } from "../Event/components/FieldWithLabel"; @@ -38,6 +38,11 @@ export function AccessTab({ const calDAVLink = `${window.DAV_BASE_URL}${calendar.link.replace(".json", "")}`; + const isResource = useMemo( + () => calendar?.owner?.resource, + [calendar?.owner?.resource] + ); + const [secretLink, setSecretLink] = useState(""); const [open, setOpen] = useState(false); @@ -99,7 +104,7 @@ export function AccessTab({ onInvitesLoaded={onInvitesLoaded} /> - {!!window.DAV_BASE_URL && ( + {!!window.DAV_BASE_URL && !isResource && ( { - // TO DO: Implement open resource selection + setOpen={(id: string) => { + setAnchorElCal(document.body); + setSelectedCalId(id); }} defaultExpanded hideOwner={true} diff --git a/src/components/Calendar/SettingsTab.tsx b/src/components/Calendar/SettingsTab.tsx index 6051ee7..fae8442 100644 --- a/src/components/Calendar/SettingsTab.tsx +++ b/src/components/Calendar/SettingsTab.tsx @@ -7,13 +7,17 @@ import { ToggleButton, ToggleButtonGroup, Typography, + useTheme, } from "@linagora/twake-mui"; import LockOutlineIcon from "@mui/icons-material/LockOutline"; +import LayersOutlinedIcon from "@mui/icons-material/LayersOutlined"; +import { alpha } from "@mui/material/styles"; import PublicIcon from "@mui/icons-material/Public"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useI18n } from "twake-i18n"; import { AddDescButton } from "../Event/AddDescButton"; import { ColorPicker } from "./CalendarColorPicker"; +import { InfoRow } from "../Event/InfoRow"; export function SettingsTab({ name, @@ -41,6 +45,14 @@ export function SettingsTab({ const userId = useAppSelector((state) => state.user.userData?.openpaasId) ?? ""; const isOwn = calendar ? extractEventBaseUuid(calendar.id) === userId : true; + const theme = useTheme(); + const infoIconColor = alpha(theme.palette.grey[900], 0.9); + const infoIconSx = { minWidth: "25px", marginRight: 2, color: infoIconColor }; + + const isResource = useMemo( + () => calendar?.owner?.resource, + [calendar?.owner?.resource] + ); useEffect(() => { if (description) setToggleDesc(true); @@ -50,38 +62,63 @@ export function SettingsTab({ <> {/* Form group 1: Name field - first group, margin top 0 */} - - {t("calendarPopover.settings.calendarName")} + + {t( + isResource + ? "calendarPopover.settings.resourceName" + : "calendarPopover.settings.calendarName" + )} - setName(e.target.value)} - size="small" - sx={{ - "&.MuiFormControl-root": { - marginTop: 0, - marginBottom: 0, - }, - }} - /> + {isResource ? ( + + + + } + text={name} + style={{ + fontSize: "16px", + fontFamily: "'Inter', sans-serif", + }} + /> + ) : ( + setName(e.target.value)} + size="small" + sx={{ + "&.MuiFormControl-root": { + marginTop: 0, + marginBottom: 0, + }, + }} + /> + )} {/* Form group 2: Description */} - - - + {!isResource && ( + + + + )} {/* Form group 3: Color */} diff --git a/src/features/Calendars/api/addCalendarResourceAsync.ts b/src/features/Calendars/api/addCalendarResourceAsync.ts index 60ee6aa..910fa34 100644 --- a/src/features/Calendars/api/addCalendarResourceAsync.ts +++ b/src/features/Calendars/api/addCalendarResourceAsync.ts @@ -43,7 +43,7 @@ export const addCalendarResourceAsync = createAsyncThunk< if (resourceId) { try { - const resource = await getResourceDetails(resourceId!); + const resource = await getResourceDetails(resourceId); owner = { ...(await getUserDetails(resource.creator)), resource: true, diff --git a/src/features/Events/EventModal.tsx b/src/features/Events/EventModal.tsx index 1401540..f6b46b9 100644 --- a/src/features/Events/EventModal.tsx +++ b/src/features/Events/EventModal.tsx @@ -666,6 +666,7 @@ function EventPopover({ resetAllStateToDefault(); setStart(""); setEnd(""); + setSelectedResources([]); shouldSyncFromRangeRef.current = true; // Reset for next time isCalendarIdUserSelectedRef.current = false; // Reset so next open gets fresh default }; diff --git a/src/locales/en.json b/src/locales/en.json index e61a79d..9a5589c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -83,7 +83,8 @@ "import": "Import" }, "settings": { - "calendarName": "Calendar name" + "calendarName": "Calendar name", + "resourceName": "Resource name" }, "access": { "grantAccessRights": "Grant Access rights", diff --git a/src/locales/fr.json b/src/locales/fr.json index b9c0234..21c5a13 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -85,7 +85,8 @@ "import": "Importer" }, "settings": { - "calendarName": "Nom du calendrier" + "calendarName": "Nom du calendrier", + "resourceName": "Nom de la ressource" }, "access": { "grantAccessRights": "Accorder des droits d'accès", diff --git a/src/locales/ru.json b/src/locales/ru.json index 10d639e..885834e 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -85,7 +85,8 @@ "import": "Импорт" }, "settings": { - "calendarName": "Название календаря" + "calendarName": "Название календаря", + "resourceName": "Название ресурса" }, "access": { "grantAccessRights": "Предоставить права доступа", diff --git a/src/locales/vi.json b/src/locales/vi.json index cd47902..359099d 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -83,7 +83,8 @@ "import": "Nhập" }, "settings": { - "calendarName": "Tên lịch" + "calendarName": "Tên lịch", + "resourceName": "Tên tài nguyên" }, "access": { "grantAccessRights": "Cấp quyền truy cập",