diff --git a/i18n/en.pot b/i18n/en.pot
index fce321d..39ef187 100644
--- a/i18n/en.pot
+++ b/i18n/en.pot
@@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-"POT-Creation-Date: 2023-09-20T18:21:35.780Z\n"
-"PO-Revision-Date: 2023-09-20T18:21:35.780Z\n"
+"POT-Creation-Date: 2023-09-21T12:59:04.507Z\n"
+"PO-Revision-Date: 2023-09-21T12:59:04.507Z\n"
msgid "Version {{version}} installed"
msgstr "Version {{version}} installed"
diff --git a/src/components/AppDetails/Versions.js b/src/components/AppDetails/Versions.js
index 7c05f8e..4e81de0 100644
--- a/src/components/AppDetails/Versions.js
+++ b/src/components/AppDetails/Versions.js
@@ -1,4 +1,4 @@
-import { useAlert, useConfig } from '@dhis2/app-runtime'
+import { useAlert, useConfig, useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import {
@@ -88,6 +88,13 @@ ChannelsFilter.propTypes = {
versions: PropTypes.array.isRequired,
}
+const dataStoreQuery = {
+ groupVersions: {
+ resource: 'dataStore/app-management/capture',
+
+ }
+};
+
const VersionsTable = ({
installedVersion,
versions,
@@ -99,6 +106,12 @@ const VersionsTable = ({
{}
)
+ const { data: { groupVersions: dataStoreGroupVersions } = {}, loading } = useDataQuery(dataStoreQuery);
+
+ if (loading) {
+ return null;
+ }
+
return (
@@ -115,7 +128,13 @@ const VersionsTable = ({
- {versions.map((version) => (
+ {versions.map((version) => {
+ const versionActiveForUserGroup = Object
+ .entries(dataStoreGroupVersions)
+ .find(([, dataStoreVersion]) => dataStoreVersion === version.version)
+ ?.[0];
+
+ return (
{version.version}
@@ -129,6 +148,7 @@ const VersionsTable = ({
userGroups={userGroups}
version={version.version}
onSelect={setUserGroupVersionMap}
+ versionActiveForUserGroup={versionActiveForUserGroup}
/>
@@ -136,7 +156,7 @@ const VersionsTable = ({
small
secondary
className={styles.installBtn}
- disabled={version.version === installedVersion}
+ disabled={version.version === installedVersion || versionActiveForUserGroup}
onClick={() =>
onVersionInstall(
version,
@@ -149,7 +169,7 @@ const VersionsTable = ({
)
}
>
- {version.version === installedVersion
+ {version.version === installedVersion || versionActiveForUserGroup
? i18n.t('Installed')
: i18n.t('Install')}
@@ -164,7 +184,8 @@ const VersionsTable = ({
- ))}
+ )
+ })}
)
@@ -260,7 +281,7 @@ Versions.propTypes = {
installedVersion: PropTypes.string,
}
-const UserGroupSelector = ({ userGroups, version, onSelect }) => {
+const UserGroupSelector = ({ userGroups, version, onSelect, versionActiveForUserGroup }) => {
const [userGroup, setUserGroup] = useState('all')
const onChange = ({ selected }) => {
@@ -269,6 +290,20 @@ const UserGroupSelector = ({ userGroups, version, onSelect }) => {
onSelect({ [selected]: version })
}
+ if (versionActiveForUserGroup) {
+ const { displayName, id } = userGroups.find(group => group.id === versionActiveForUserGroup);
+
+ return (
+
+
+
+ );
+ }
+
return (