Skip to content

Commit

Permalink
Update "about" window (#56)
Browse files Browse the repository at this point in the history
Update commons-ui and use new API
Tristan-WorkGH authored Dec 27, 2023
1 parent 317bc80 commit 558fd23
Showing 5 changed files with 20 additions and 44 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",
"@gridsuite/commons-ui": "^0.42.0",
"@gridsuite/commons-ui": "^0.43.0",
"@hookform/resolvers": "^3.3.1",
"@mui/icons-material": "^5.5.1",
"@mui/lab": "^5.0.0-alpha.75",
39 changes: 3 additions & 36 deletions src/components/app-top-bar.js
Original file line number Diff line number Diff line change
@@ -59,43 +59,10 @@ const AppTopBar = ({ user, userManager }) => {
onLogoClick={() => navigate.replace('/')}
user={user}
appsAndUrls={appsAndUrls}
getGlobalVersion={(setGlobalVersion) =>
fetchVersion()
.then((res) => setGlobalVersion(res.deployVersion))
.catch((reason) => {
console.error(
'Error while fetching the version : ' + reason
);
setGlobalVersion(null);
})
}
getAdditionalModules={(setServers) =>
getServersInfos(user?.id_token)
.then((res) =>
setServers(
Object.entries(res).map(([name, infos]) => ({
name:
infos?.build?.name ||
infos?.build?.artifact ||
name,
type: 'server',
version: infos?.build?.version,
gitTag:
infos?.git?.tags ||
infos?.git?.commit?.id[
'describe-short'
],
}))
)
)
.catch((reason) => {
console.error(
'Error while fetching the servers infos : ' +
reason
);
setServers(null);
})
globalVersionPromise={() =>
fetchVersion().then((res) => res?.deployVersion)
}
additionalModulesPromise={getServersInfos}
onThemeClick={handleChangeTheme}
theme={themeLocal}
onLanguageClick={handleChangeLanguage}
9 changes: 7 additions & 2 deletions src/rest/study.js
Original file line number Diff line number Diff line change
@@ -5,14 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { backendFetchJson } from '../utils/rest-api';

const API_URL =
'/api/' +
(process.env.REACT_APP_USE_AUTHENTICATION === 'true'
? process.env.REACT_APP_API_GATEWAY + '/study/v1'
: process.env.REACT_APP_SRV_STUDY_URI + '/v1');

export function getServersInfos(token) {
return backendFetchJson(
`${API_URL}/servers/infos`,
`${API_URL}/servers/about`,
{
headers: {
Accept: 'application/json',
@@ -21,5 +23,8 @@ export function getServersInfos(token) {
cache: 'default',
},
token
);
).catch((reason) => {
console.error('Error while fetching the servers infos : ' + reason);
return reason;
});
}
6 changes: 5 additions & 1 deletion src/utils/rest-api.js
Original file line number Diff line number Diff line change
@@ -190,7 +190,11 @@ export function fetchVersion() {
console.info(`Fetching global metadata...`);
return fetchEnv()
.then((env) => fetch(env.appsMetadataServerUrl + '/version.json'))
.then((response) => response.json());
.then((response) => response.json())
.catch((reason) => {
console.error('Error while fetching the version : ' + reason);
return reason;
});
}

export function fetchAppsAndUrls() {

0 comments on commit 558fd23

Please sign in to comment.