#637 modify resource

This commit is contained in:
lethemanh
2026-03-18 20:13:18 +07:00
parent 3a84756872
commit c2c94a9bf2
9 changed files with 84 additions and 36 deletions
+7 -2
View File
@@ -14,7 +14,7 @@ import {
} from "@linagora/twake-mui"; } from "@linagora/twake-mui";
import ContentCopyIcon from "@mui/icons-material/ContentCopy"; import ContentCopyIcon from "@mui/icons-material/ContentCopy";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import { useEffect, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useI18n } from "twake-i18n"; import { useI18n } from "twake-i18n";
import { ErrorSnackbar } from "../Error/ErrorSnackbar"; import { ErrorSnackbar } from "../Error/ErrorSnackbar";
import { FieldWithLabel } from "../Event/components/FieldWithLabel"; import { FieldWithLabel } from "../Event/components/FieldWithLabel";
@@ -38,6 +38,11 @@ export function AccessTab({
const calDAVLink = `${window.DAV_BASE_URL}${calendar.link.replace(".json", "")}`; const calDAVLink = `${window.DAV_BASE_URL}${calendar.link.replace(".json", "")}`;
const isResource = useMemo(
() => calendar?.owner?.resource,
[calendar?.owner?.resource]
);
const [secretLink, setSecretLink] = useState(""); const [secretLink, setSecretLink] = useState("");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -99,7 +104,7 @@ export function AccessTab({
onInvitesLoaded={onInvitesLoaded} onInvitesLoaded={onInvitesLoaded}
/> />
{!!window.DAV_BASE_URL && ( {!!window.DAV_BASE_URL && !isResource && (
<FieldWithLabel label={t("calendar.caldav_access")} isExpanded={false}> <FieldWithLabel label={t("calendar.caldav_access")} isExpanded={false}>
<Box mt={2}> <Box mt={2}>
<TextField <TextField
@@ -219,8 +219,9 @@ export default function CalendarSelection({
}} }}
showAddButton showAddButton
handleToggle={handleCalendarToggle} handleToggle={handleCalendarToggle}
setOpen={(_) => { setOpen={(id: string) => {
// TO DO: Implement open resource selection setAnchorElCal(document.body);
setSelectedCalId(id);
}} }}
defaultExpanded defaultExpanded
hideOwner={true} hideOwner={true}
+40 -3
View File
@@ -7,13 +7,17 @@ import {
ToggleButton, ToggleButton,
ToggleButtonGroup, ToggleButtonGroup,
Typography, Typography,
useTheme,
} from "@linagora/twake-mui"; } from "@linagora/twake-mui";
import LockOutlineIcon from "@mui/icons-material/LockOutline"; 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 PublicIcon from "@mui/icons-material/Public";
import { useEffect, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useI18n } from "twake-i18n"; import { useI18n } from "twake-i18n";
import { AddDescButton } from "../Event/AddDescButton"; import { AddDescButton } from "../Event/AddDescButton";
import { ColorPicker } from "./CalendarColorPicker"; import { ColorPicker } from "./CalendarColorPicker";
import { InfoRow } from "../Event/InfoRow";
export function SettingsTab({ export function SettingsTab({
name, name,
@@ -41,6 +45,14 @@ export function SettingsTab({
const userId = const userId =
useAppSelector((state) => state.user.userData?.openpaasId) ?? ""; useAppSelector((state) => state.user.userData?.openpaasId) ?? "";
const isOwn = calendar ? extractEventBaseUuid(calendar.id) === userId : true; 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(() => { useEffect(() => {
if (description) setToggleDesc(true); if (description) setToggleDesc(true);
@@ -50,10 +62,32 @@ export function SettingsTab({
<> <>
{/* Form group 1: Name field - first group, margin top 0 */} {/* Form group 1: Name field - first group, margin top 0 */}
<Box mt={0}> <Box mt={0}>
<Typography variant="h6" sx={{ margin: 0 }}> <Typography
{t("calendarPopover.settings.calendarName")} variant="h6"
sx={{ margin: 0, marginBottom: isResource ? "16px" : 0 }}
>
{t(
isResource
? "calendarPopover.settings.resourceName"
: "calendarPopover.settings.calendarName"
)}
</Typography> </Typography>
<Box sx={{ marginTop: "6px" }}> <Box sx={{ marginTop: "6px" }}>
{isResource ? (
<InfoRow
alignItems="flex-start"
icon={
<Box sx={infoIconSx}>
<LayersOutlinedIcon />
</Box>
}
text={name}
style={{
fontSize: "16px",
fontFamily: "'Inter', sans-serif",
}}
/>
) : (
<TextField <TextField
fullWidth fullWidth
label="" label=""
@@ -69,10 +103,12 @@ export function SettingsTab({
}, },
}} }}
/> />
)}
</Box> </Box>
</Box> </Box>
{/* Form group 2: Description */} {/* Form group 2: Description */}
{!isResource && (
<Box mt={2}> <Box mt={2}>
<AddDescButton <AddDescButton
showDescription={toggleDesc} showDescription={toggleDesc}
@@ -82,6 +118,7 @@ export function SettingsTab({
setDescription={setDescription} setDescription={setDescription}
/> />
</Box> </Box>
)}
{/* Form group 3: Color */} {/* Form group 3: Color */}
<Box mt={2}> <Box mt={2}>
@@ -43,7 +43,7 @@ export const addCalendarResourceAsync = createAsyncThunk<
if (resourceId) { if (resourceId) {
try { try {
const resource = await getResourceDetails(resourceId!); const resource = await getResourceDetails(resourceId);
owner = { owner = {
...(await getUserDetails(resource.creator)), ...(await getUserDetails(resource.creator)),
resource: true, resource: true,
+1
View File
@@ -666,6 +666,7 @@ function EventPopover({
resetAllStateToDefault(); resetAllStateToDefault();
setStart(""); setStart("");
setEnd(""); setEnd("");
setSelectedResources([]);
shouldSyncFromRangeRef.current = true; // Reset for next time shouldSyncFromRangeRef.current = true; // Reset for next time
isCalendarIdUserSelectedRef.current = false; // Reset so next open gets fresh default isCalendarIdUserSelectedRef.current = false; // Reset so next open gets fresh default
}; };
+2 -1
View File
@@ -83,7 +83,8 @@
"import": "Import" "import": "Import"
}, },
"settings": { "settings": {
"calendarName": "Calendar name" "calendarName": "Calendar name",
"resourceName": "Resource name"
}, },
"access": { "access": {
"grantAccessRights": "Grant Access rights", "grantAccessRights": "Grant Access rights",
+2 -1
View File
@@ -85,7 +85,8 @@
"import": "Importer" "import": "Importer"
}, },
"settings": { "settings": {
"calendarName": "Nom du calendrier" "calendarName": "Nom du calendrier",
"resourceName": "Nom de la ressource"
}, },
"access": { "access": {
"grantAccessRights": "Accorder des droits d'accès", "grantAccessRights": "Accorder des droits d'accès",
+2 -1
View File
@@ -85,7 +85,8 @@
"import": "Импорт" "import": "Импорт"
}, },
"settings": { "settings": {
"calendarName": "Название календаря" "calendarName": "Название календаря",
"resourceName": "Название ресурса"
}, },
"access": { "access": {
"grantAccessRights": "Предоставить права доступа", "grantAccessRights": "Предоставить права доступа",
+2 -1
View File
@@ -83,7 +83,8 @@
"import": "Nhập" "import": "Nhập"
}, },
"settings": { "settings": {
"calendarName": "Tên lịch" "calendarName": "Tên lịch",
"resourceName": "Tên tài nguyên"
}, },
"access": { "access": {
"grantAccessRights": "Cấp quyền truy cập", "grantAccessRights": "Cấp quyền truy cập",