diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index b3d2f4d05d..264f5451d4 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -176,6 +176,7 @@ config.MD033 = { "DbAccessPHP", "SettingsPHP", "LocalLib", + "ReleaseStateSummary", ] }; diff --git a/data/versions.json b/data/versions.json index 2816c89de5..f914973d3b 100644 --- a/data/versions.json +++ b/data/versions.json @@ -3,6 +3,7 @@ "versions": [ { "name": "4.5", + "codeFreezeDate": "26 August 2024", "releaseDate": "7 October 2024", "generalEndDate": "6 October 2025", "securityEndDate": "6 October 2027", diff --git a/docs/intro.md b/docs/intro.md index cb78db2442..35cce0e5c0 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -20,3 +20,7 @@ This documentation is version-specific and includes a range of useful guides and {/*- You may want to read the [Release notes](/general/releases/4.5) for Moodle 4.5 */} ::: + +import ReleaseStateSummary from '@site/src/components/ReleaseStateSummary'; + + diff --git a/src/components/ReleaseStateSummary/index.tsx b/src/components/ReleaseStateSummary/index.tsx new file mode 100644 index 0000000000..3cb7e55086 --- /dev/null +++ b/src/components/ReleaseStateSummary/index.tsx @@ -0,0 +1,170 @@ +/** + * Copyright (c) Moodle Pty Ltd. + * + * Moodle is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Moodle is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Moodle. If not, see . + */ + +import React from 'react'; +import type { majorVersionData } from '@site/src/utils/SupportedReleases'; +import { getReleaseStatus, getVersion } from '@site/src/utils/SupportedReleases'; +import Link from '@docusaurus/Link'; +import Admonition from '@theme/Admonition'; +import Heading from '@theme/Heading'; + +export interface ReleaseInfoProps { + releaseName: string, +} + +function supportedRelease({ releaseData }: majorVersionData): JSX.Element { + const generalEndDate = new Date(releaseData.generalEndDate); + const securityEndDate = new Date(releaseData.securityEndDate); + + return ( + <> + Release status + +

+ Moodle + {' '} + {releaseData.name} + , which + {' '} + {releaseData.isLTS && is an LTS release} + {!releaseData.isLTS && is not an LTS release} + , was released on + {' '} + + {releaseData.releaseDate} + + . +

+

+ General support + {' '} + {generalEndDate < new Date() && <>ended} + {generalEndDate >= new Date() && <>will end} + {' '} + on + {' '} + + {releaseData.generalEndDate} + + . +

+

+ Security support + {' '} + {securityEndDate < new Date() && <>ended} + {securityEndDate >= new Date() && <>will end} + {' '} + on + {' '} + + {releaseData.securityEndDate} + + . +

+
+ + ); +} + +function getAdmonitionType(date): string { + const today = new Date(); + if (date < today) { + return 'danger'; + } + + return 'info'; +} + +function futureRelease({ releaseData }: majorVersionData): JSX.Element { + const today = new Date(); + const codeFreezeDate = new Date(releaseData.codeFreezeDate); + + console.log(releaseData); + return ( + <> + Release status + +

+ Moodle + {' '} + {releaseData.name} + , which + {' '} + {releaseData.isLTS && will be an LTS release} + {!releaseData.isLTS && will not an LTS release} + , is scheduled for release on + {' '} + + {releaseData.releaseDate} + + . +

+

+ The + {' '} + + code freeze + + {' '} + {codeFreezeDate < today && started} + {codeFreezeDate >= today && will start} + {' '} + on + {' '} + + {releaseData.codeFreezeDate} + + . +

+

+ General support will end on + {' '} + + {releaseData.generalEndDate} + + . +

+

+ Security support will end on + {' '} + + {releaseData.securityEndDate} + + . +

+
+ + ); +} + +export default function ReleaseStateSummary({ releaseName }: ReleaseInfoProps): JSX.Element { + const releaseData = getVersion(releaseName); + const status = getReleaseStatus(releaseData); + + if (status === 'future') { + return futureRelease({ releaseData }); + } + + if (status === 'current' || status === 'security') { + return supportedRelease({ releaseData }); + } + + return ( + <> + + ); +} diff --git a/src/utils/SupportedReleases.ts b/src/utils/SupportedReleases.ts index c842db4287..3b1a691494 100644 --- a/src/utils/SupportedReleases.ts +++ b/src/utils/SupportedReleases.ts @@ -31,6 +31,7 @@ export interface versionInfo { export interface majorVersionData { name: string, + codeFreezeDate?: string, releaseDate: string, generalEndDate: string, securityEndDate: string, diff --git a/static/schema/versions.json b/static/schema/versions.json index b2d2dd1c4e..9d056700f5 100644 --- a/static/schema/versions.json +++ b/static/schema/versions.json @@ -24,6 +24,9 @@ "releaseDate": { "type": "string" }, + "codeFreezeDate": { + "type": "string" + }, "generalEndDate": { "type": "string" }, diff --git a/versioned_docs/version-4.1/intro.md b/versioned_docs/version-4.1/intro.md index 1ad0b7d82b..67a5072132 100644 --- a/versioned_docs/version-4.1/intro.md +++ b/versioned_docs/version-4.1/intro.md @@ -20,3 +20,7 @@ This documentation is version-specific and includes a range of useful guides and - Interested in supporting the Moodle App in your plugins? Read the [Moodle App documentation](/general/app) ::: + +import ReleaseStateSummary from '@site/src/components/ReleaseStateSummary'; + + diff --git a/versioned_docs/version-4.2/intro.md b/versioned_docs/version-4.2/intro.md index 67d393d07c..839b2f3674 100644 --- a/versioned_docs/version-4.2/intro.md +++ b/versioned_docs/version-4.2/intro.md @@ -20,3 +20,7 @@ This documentation is version-specific and includes a range of useful guides and - Interested in supporting the Moodle App in your plugins? Read the [Moodle App documentation](/general/app) ::: + +import ReleaseStateSummary from '@site/src/components/ReleaseStateSummary'; + + diff --git a/versioned_docs/version-4.3/intro.md b/versioned_docs/version-4.3/intro.md index dd2390f407..f02ccac98d 100644 --- a/versioned_docs/version-4.3/intro.md +++ b/versioned_docs/version-4.3/intro.md @@ -20,3 +20,7 @@ This documentation is version-specific and includes a range of useful guides and - Interested in supporting the Moodle App in your plugins? Read the [Moodle App documentation](/general/app) ::: + +import ReleaseStateSummary from '@site/src/components/ReleaseStateSummary'; + + diff --git a/versioned_docs/version-4.4/intro.md b/versioned_docs/version-4.4/intro.md index acd4467e4b..e5bff8a9b4 100644 --- a/versioned_docs/version-4.4/intro.md +++ b/versioned_docs/version-4.4/intro.md @@ -20,3 +20,7 @@ This documentation is version-specific and includes a range of useful guides and - You may want to read the [Release notes](/general/releases/4.4) for Moodle 4.4 ::: + +import ReleaseStateSummary from '@site/src/components/ReleaseStateSummary'; + +