Skip to content

Commit dd4eaa5

Browse files
authored
Finish release/2022-04
Release/2022 04
2 parents 6654979 + 6a76680 commit dd4eaa5

File tree

6 files changed

+201
-20
lines changed

6 files changed

+201
-20
lines changed

.github/workflows/npmpublish.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,38 @@ name: Node.js Package
55

66
on:
77
release:
8-
types: [created]
8+
types: [published]
99

1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: olegtarasov/get-tag@v2.1
15+
id: tagName
1416
- uses: actions/checkout@v2
1517
- uses: actions/setup-node@v1
1618
with:
1719
node-version: 12
20+
- name: update the version with TAG
21+
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
1822
- run: yarn install
19-
- run: yarn build
23+
- run: yarn build
24+
2025

2126
publish-npm:
2227
needs: build
2328
runs-on: ubuntu-latest
2429
steps:
30+
- uses: olegtarasov/get-tag@v2.1
31+
id: tagName
2532
- uses: actions/checkout@v2
2633
- uses: actions/setup-node@v1
2734
with:
2835
node-version: 12
2936
registry-url: https://registry.npmjs.org/
3037
scope: openimis
38+
- name: update the version with TAG
39+
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
3140
- run: yarn install
3241
- run: yarn build
3342
- run: npm publish --access public
@@ -38,11 +47,15 @@ jobs:
3847
needs: build
3948
runs-on: ubuntu-latest
4049
steps:
50+
- uses: olegtarasov/get-tag@v2.1
51+
id: tagName
4152
- uses: actions/checkout@v2
4253
- uses: actions/setup-node@v1
4354
with:
4455
node-version: 12
4556
registry-url: https://npm.pkg.github.com/
57+
- name: update the version with TAG
58+
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
4659
- run: yarn install
4760
- run: yarn build
4861
- run: npm publish

lokalise_upload.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// request Upload file
2+
(function(callback) {
3+
'use strict';
4+
5+
if (!process.env.LOKALISE_APIKEY) {
6+
console.log("Please setup the LOKALISE_APIKEY env before using this script");
7+
return;
8+
}
9+
const httpTransport = require('https');
10+
const responseEncoding = 'utf8';
11+
const httpOptions = {
12+
hostname: 'api.lokalise.com',
13+
port: '443',
14+
path: '/api2/projects/983881975d551c5fdba845.54008358/files/upload',
15+
method: 'POST',
16+
headers: {"Content-Type":"application/json","x-api-token":process.env.LOKALISE_APIKEY}
17+
};
18+
httpOptions.headers['User-Agent'] = 'node ' + process.version;
19+
20+
const fs = require('fs');
21+
const contents = fs.readFileSync('src/translations/en.json', {encoding: 'base64'});
22+
//console.log("file contents", contents);
23+
24+
const request = httpTransport.request(httpOptions, (res) => {
25+
let responseBufs = [];
26+
let responseStr = '';
27+
28+
res.on('data', (chunk) => {
29+
if (Buffer.isBuffer(chunk)) {
30+
responseBufs.push(chunk);
31+
}
32+
else {
33+
responseStr = responseStr + chunk;
34+
}
35+
}).on('end', () => {
36+
responseStr = responseBufs.length > 0 ?
37+
Buffer.concat(responseBufs).toString(responseEncoding) : responseStr;
38+
39+
callback(null, res.statusCode, res.headers, responseStr);
40+
});
41+
42+
})
43+
.setTimeout(0)
44+
.on('error', (error) => {
45+
callback(error);
46+
});
47+
request.write("{\"filename\":\"en.json\",\"data\":\"" + contents + "\",\"lang_iso\":\"en\",\"tags\":[\"js_upload\",\"profile\"]}")
48+
request.end();
49+
50+
51+
})((error, statusCode, headers, body) => {
52+
console.log('ERROR:', error);
53+
console.log('STATUS:', statusCode);
54+
console.log('HEADERS:', JSON.stringify(headers));
55+
console.log('BODY:', body);
56+
});
57+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openimis/fe-profile",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"license": "AGPL-3.0-only",
55
"description": "openIMIS Frontend Profile reference module",
66
"repository": "openimis/openimis-fe-profile_js",
Lines changed: 114 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,118 @@
1-
import React, { Component } from "react";
2-
import { ProxyPage } from "@openimis/fe-core";
1+
import React, { useState, useMemo } from "react";
2+
import { Box, Button, Paper, Typography, Grid } from "@material-ui/core";
3+
import { makeStyles } from "@material-ui/styles";
4+
import {
5+
useGraphqlMutation,
6+
useTranslations,
7+
useModulesManager,
8+
TextInput,
9+
useAuthentication,
10+
} from "@openimis/fe-core";
311

12+
const useStyles = makeStyles((theme) => ({
13+
page: theme.page,
14+
paper: theme.paper.paper,
15+
title: theme.paper.title,
16+
}));
417

5-
class ChangePasswordPage extends Component {
6-
render() {
7-
return <ProxyPage url="/ChangePassword.aspx" />
18+
const ChangePasswordPage = (props) => {
19+
const classes = useStyles();
20+
const modulesManager = useModulesManager();
21+
const { formatMessage } = useTranslations("profile.ChangePasswordPage", modulesManager);
22+
const [formValues, setFormValues] = useState({});
23+
const [error, setError] = useState("");
24+
25+
const isValid = useMemo(
26+
() => formValues.password && formValues.password === formValues.confirmPassword && formValues.oldPassword,
27+
[formValues]
28+
);
29+
30+
const { mutate, isLoading } = useGraphqlMutation(
31+
`
32+
mutation changePassword ($input: ChangePasswordMutationInput!) {
33+
changePassword(input: $input) {
34+
clientMutationId
35+
success
36+
error
37+
}
38+
}
39+
`,
40+
{ wait: false }
41+
);
42+
43+
const onSubmit = async (e) => {
44+
e.preventDefault();
45+
if (isValid) {
46+
setError(null);
47+
const result = await mutate({
48+
oldPassword: formValues.oldPassword,
49+
newPassword: formValues.password,
50+
});
51+
52+
setError(result.changePassword?.error);
853
}
9-
}
54+
};
55+
56+
return (
57+
<Box className={classes.page}>
58+
<Paper className={classes.paper}>
59+
<Typography className={classes.title} variant="h6">
60+
{formatMessage("title")}
61+
</Typography>
62+
<Box padding="10px">
63+
<form onSubmit={onSubmit}>
64+
<Grid container spacing={2}>
65+
<Grid xs={4} item>
66+
<TextInput
67+
module="profile"
68+
required
69+
readOnly={isLoading}
70+
type="password"
71+
label={"ChangePasswordPage.oldPasswordLabel"}
72+
onChange={(oldPassword) => setFormValues({ ...formValues, oldPassword })}
73+
/>
74+
</Grid>
75+
<Grid xs={4} item>
76+
<TextInput
77+
module="profile"
78+
required
79+
readOnly={isLoading}
80+
type="password"
81+
label={"ChangePasswordPage.newPasswordLabel"}
82+
onChange={(password) => setFormValues({ ...formValues, password })}
83+
/>
84+
</Grid>
85+
<Grid xs={4} item>
86+
<TextInput
87+
module="profile"
88+
readOnly={isLoading}
89+
required
90+
type="password"
91+
label={"ChangePasswordPage.confirmPasswordLabel"}
92+
onChange={(confirmPassword) => setFormValues({ ...formValues, confirmPassword })}
93+
/>
94+
</Grid>
95+
{formValues.password !== formValues.confirmPassword && formValues.confirmPassword && formValues.password && (
96+
<Grid item xs={12}>
97+
<Box color="error.main">{formatMessage("notEqualError")}</Box>
98+
</Grid>
99+
)}
100+
{error && (
101+
<Grid item xs={12}>
102+
<Box color="error.main">{error}</Box>
103+
</Grid>
104+
)}
105+
<Grid item>
106+
<Button type="submit" color="primary" variant="contained" disabled={!isValid || isLoading}>
107+
{formatMessage("submitButton")}
108+
</Button>
109+
</Grid>
110+
</Grid>
111+
</form>
112+
</Box>
113+
</Paper>
114+
</Box>
115+
);
116+
};
10117

11-
export { ChangePasswordPage };
118+
export default ChangePasswordPage;

src/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import ProfileMainMenu from "./components/ProfileMainMenu";
2-
import { ChangePasswordPage } from "./components/ChangePasswordPage";
2+
import ChangePasswordPage from "./components/ChangePasswordPage";
33
import messages_en from "./translations/en.json";
44

55
const DEFAULT_CONFIG = {
66
"translations": [{ key: "en", messages: messages_en }],
7-
"core.Router": [
8-
{ path: "profile/changePassword", component: ChangePasswordPage },
9-
],
10-
"core.MainMenu": [ProfileMainMenu]
11-
}
7+
"core.Router": [{ path: "profile/changePassword", component: ChangePasswordPage }],
8+
"core.MainMenu": [ProfileMainMenu],
9+
};
1210

1311
export const ProfileModule = (cfg) => {
1412
return { ...DEFAULT_CONFIG, ...cfg };
15-
}
13+
};

src/translations/en.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2-
"profile.mainMenu": "Profile",
3-
"profile.menu.changePassword": "Change Password"
4-
}
2+
"profile.mainMenu": "Profile",
3+
"profile.menu.changePassword": "Change Password",
4+
"profile.ChangePasswordPage.title": "Change Password",
5+
"profile.ChangePasswordPage.notEqualError": "The passwords are not the same",
6+
"profile.ChangePasswordPage.oldPasswordLabel": "Current Password",
7+
"profile.ChangePasswordPage.newPasswordLabel": "New Password",
8+
"profile.ChangePasswordPage.confirmPasswordLabel": "Confirm New Password",
9+
"profile.ChangePasswordPage.submitButton": "Submit"
10+
}

0 commit comments

Comments
 (0)