Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jorism/fix-code-flow-…
Browse files Browse the repository at this point in the history
…authentication
  • Loading branch information
TheMaskedTurtle committed Feb 1, 2024
2 parents f2d1e33 + 7e8540a commit e1062a6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 47 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,33 @@ jobs:
with:
persist-credentials: false

- name: Parse tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF_NAME#v}

- name: Install and Build
run: |
npm install
npm run-script test
npm run-script build
npm run-script test
- name: Build and publish Docker image
- name: Build and publish Docker image - Main
if: github.ref == 'refs/heads/main'
uses: elgohr/Publish-Docker-Github-Action@33a481be3e179353cb7793a92b57cf9a6c985860 # v4
with:
name: gridsuite/gridXXX-app
username: gridsuiteci
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and publish Docker image - Tag
if: startsWith(github.ref, 'refs/tags/')
uses: elgohr/Publish-Docker-Github-Action@33a481be3e179353cb7793a92b57cf9a6c985860 # v4
with:
name: gridsuite/gridstudy-app
username: gridsuiteci
password: ${{ secrets.DOCKERHUB_TOKEN }}
tags: ${{ steps.vars.outputs.tag }}

- name: Broadcast update event
if: github.ref == 'refs/heads/main'
uses: gridsuite/broadcast-event@main
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Template app that bootstraps the creation of gridsuite apps.
The template setup the authentication mechanism and provide a configured empty application.

To customize this repository for an app, search and replace the string XXX with the name of the app. For example, GridXXX -> GridFoo, gridXXX-app -> gridfoo-app.
To customize this repository for an app, search and replace the string `XXX` with the name of the app. For example, GridXXX -> GridFoo, gridXXX-app -> gridfoo-app.

Create a new view in study-server and replace `yyy` with the new token in rest api `src/rest/study.ts`.

## Typescript config

Expand Down
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
Expand Up @@ -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",
Expand Down
39 changes: 3 additions & 36 deletions src/components/app-top-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
9 changes: 7 additions & 2 deletions src/rest/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?view=yyy`,
{
headers: {
Accept: 'application/json',
Expand All @@ -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
Expand Up @@ -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() {
Expand Down

0 comments on commit e1062a6

Please sign in to comment.