Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject informations into about dialog #104

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions package-lock.json

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

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "gridmerge-app",
"version": "0.1.0",
"license": "MPL-2.0",
"homepage": ".",
"private": true,
"dependencies": {
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",
"@gridsuite/commons-ui": "0.41.0",
"@gridsuite/commons-ui": "^0.42.0",
"@mui/icons-material": "^5.5.1",
"@mui/lab": "^5.0.0-alpha.75",
"@mui/material": "^5.5.3",
Expand All @@ -23,6 +24,7 @@
"prop-types": "^15.7.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-hook-form": "^7.48.2",
"react-intl": "^6.0.0",
"react-redux": "^8.0.0",
"react-router-dom": "^6.0.0",
Expand All @@ -34,7 +36,8 @@
"reconnecting-websocket": "^4.4.0",
"redux": "^4.0.5",
"typeface-roboto": "^1.0.0",
"typescript": "^5.1.3"
"typescript": "^5.1.3",
"yup": "^1.3.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -68,8 +71,6 @@
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-prettier": "^4.0.0",
"http-proxy-middleware": "^2.0.0",
"prettier": "^2.0.5",
"react-hook-form": "^7.48.2",
"yup": "^1.3.2"
"prettier": "^2.0.5"
}
}
80 changes: 53 additions & 27 deletions src/components/app-top-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { LIGHT_THEME, logout, TopBar } from '@gridsuite/commons-ui';
import Parameters, { useParameterState } from './parameters';
import { PARAM_LANGUAGE, PARAM_THEME } from '../utils/config-params';
import { useDispatch, useSelector } from 'react-redux';
import { fetchAppsAndUrls, fetchMergeConfigs } from '../utils/rest-api';
import {
fetchAppsAndUrls,
fetchMergeConfigs,
fetchVersion,
getServersInfos,
} from '../utils/rest-api';
import PropTypes from 'prop-types';
import { useNavigate, useMatch } from 'react-router-dom';
import { ReactComponent as GridMergeLogoLight } from '../images/GridMerge_logo_light.svg';
Expand All @@ -19,6 +24,7 @@ import { FormattedMessage } from 'react-intl';
import ProcessesConfigurationDialog from './processes-configuration-dialog';
import { makeStyles } from '@mui/styles';
import { initProcesses } from '../redux/actions';
import AppPackage from '../../package.json';

export const PREFIX_URL_PROCESSES = '/processes';

Expand Down Expand Up @@ -81,26 +87,6 @@ const AppTopBar = ({ user, userManager }) => {
return index !== -1 ? matchProcess.params.processName : false;
}, [configs, matchProcess]);

function toggleTab(newTabValue) {
navigate(PREFIX_URL_PROCESSES + '/' + newTabValue);
}

function showParametersClicked() {
setShowParameters(true);
}

function hideParameters() {
setShowParameters(false);
}

function onLogoClicked() {
navigate('/', { replace: true });
}

const showPopupConfigurationProcesses = () => {
setShowConfigurationProcesses(true);
};

Comment on lines -84 to -103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do not belong to this PR

Copy link
Contributor Author

@Tristan-WorkGH Tristan-WorkGH Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did like in gridstudy-app PR

return (
<>
<TopBar
Expand All @@ -113,23 +99,63 @@ const AppTopBar = ({ user, userManager }) => {
<GridMergeLogoDark />
)
}
onParametersClick={() => showParametersClicked()}
appVersion={AppPackage.version}
appLicense={AppPackage.license}
onParametersClick={() => setShowParameters(true)}
onLogoutClick={() => logout(dispatch, userManager.instance)}
onLogoClick={() => onLogoClicked()}
onLogoClick={() => navigate('/', { replace: true })}
user={user}
appsAndUrls={appsAndUrls}
onThemeClick={handleChangeTheme}
theme={themeLocal}
onAboutClick={() => console.debug('about')}
onLanguageClick={handleChangeLanguage}
language={languageLocal}
getGlobalVersion={(setGlobalVersion) =>
fetchVersion()
.then((res) => setGlobalVersion(res.deployVersion))
.catch((reason) => {
console.error(
'Error while fetching the version : ' + reason
);
setGlobalVersion(null);
})
}
getAdditionalModules={(setServers) =>
getServersInfos()
.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);
})
}
>
<Tabs
value={selectedTabId}
indicatorColor="primary"
variant="scrollable"
scrollButtons="auto"
onChange={(event, newValue) => toggleTab(newValue)}
onChange={(event, newValue) =>
navigate(PREFIX_URL_PROCESSES + '/' + newValue)
}
aria-label="parameters"
className={classes.process}
>
Expand All @@ -145,7 +171,7 @@ const AppTopBar = ({ user, userManager }) => {
<>
<Button
className={classes.btnConfigurationProcesses}
onClick={showPopupConfigurationProcesses}
onClick={() => setShowConfigurationProcesses(true)}
>
<FormattedMessage id="configureProcesses" />
</Button>
Expand All @@ -161,7 +187,7 @@ const AppTopBar = ({ user, userManager }) => {
</TopBar>
<Parameters
showParameters={showParameters}
hideParameters={hideParameters}
hideParameters={() => setShowParameters(false)}
/>
</>
);
Expand Down
68 changes: 39 additions & 29 deletions src/utils/rest-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const PREFIX_CONFIG_NOTIFICATION_WS =
process.env.REACT_APP_WS_GATEWAY + '/config-notification';
const PREFIX_CONFIG_QUERIES = process.env.REACT_APP_API_GATEWAY + '/config';
const PREFIX_BOUNDARY_QUERIES = process.env.REACT_APP_API_GATEWAY + '/boundary';
const PREFIX_STUDY_QUERIES = process.env.REACT_APP_API_GATEWAY + '/study';

function getToken() {
const state = store.getState();
Expand Down Expand Up @@ -234,44 +235,48 @@ export function getExportMergeUrl(processUuid, date, format) {
return getUrlWithToken(url);
}

function fetchEnv() {
return fetch('env.json').then((res) => res.json());
}

export function fetchAuthorizationCodeFlowFeatureFlag() {
console.info(`Fetching authorization code flow feature flag...`);
return fetch('env.json')
return fetchEnv()
.then((res) =>
fetch(res.appsMetadataServerUrl + '/authentication.json')
)
.then((res) => res.json())
.then((res) => {
return fetch(res.appsMetadataServerUrl + '/authentication.json')
.then((res) => res.json())
.then((res) => {
console.log(
`Authorization code flow is ${
res.authorizationCodeFlowFeatureFlag
? 'enabled'
: 'disabled'
}`
);
return res.authorizationCodeFlowFeatureFlag;
})
.catch((error) => {
console.error(error);
console.warn(
`Something wrong happened when retrieving authentication.json: authorization code flow will be disabled`
);
return false;
});
console.log(
`Authorization code flow is ${
res.authorizationCodeFlowFeatureFlag
? 'enabled'
: 'disabled'
}`
);
return res.authorizationCodeFlowFeatureFlag;
})
.catch((error) => {
console.error(error);
console.warn(
`Something wrong happened when retrieving authentication.json: authorization code flow will be disabled`
);
return false;
});
}

export function fetchAppsAndUrls() {
console.info(`Fetching apps and urls...`);
return fetch('env.json')
.then((res) => res.json())
.then((res) => {
return fetch(
res.appsMetadataServerUrl + '/apps-metadata.json'
).then((response) => {
return response.json();
});
});
return fetchEnv()
.then((env) => fetch(env.appsMetadataServerUrl + '/apps-metadata.json'))
.then((response) => response.json());
}

export function fetchVersion() {
console.info(`Fetching global metadata...`);
return fetchEnv()
.then((env) => fetch(env.appsMetadataServerUrl + '/version.json'))
.then((response) => response.json());
}

/**
Expand Down Expand Up @@ -464,3 +469,8 @@ export const MergeType = PropTypes.shape({
})
),
});

export function getServersInfos() {
console.info('get backend servers informations');
return backendFetchJson(PREFIX_STUDY_QUERIES + '/v1/servers/infos');
}