Skip to content

Commit

Permalink
Merge branch 'release/23.10' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
delcroip authored Dec 6, 2023
2 parents 420ed2b + 8965bcf commit 1d254d8
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 50 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Module SonarCloud CI Pipeline
on:
push:
branches:
- main
- 'release/**'
- develop
- 'feature/**'
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
- run: yarn install
- run: yarn build


publish-npm:
needs: build
Expand Down Expand Up @@ -60,4 +59,4 @@ jobs:
- run: yarn build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ None
* `state.core.user`, to access user info (rights,...)

## Configurations Options
None
- `passwordGeneratorOptions`, array with possible configuration options, default:{ length: 10, isNumberRequired: true,
isLowerCaseRequired: true, isUpperCaseRequired: true, isSpecialSymbolRequired: true }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
"dependencies": {
"@material-ui/lab": "^4.0.0-alpha.60"
}
}
}
7 changes: 7 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# must be unique in a given SonarScanner instance
sonar.projectKey=openimis_openimis-fe-admin_js
sonar.organization=openimis-1
sonar.projectName=openimis-fe-admin_js

sonar.sources=src
sonar.sourceEncoding=UTF-8
3 changes: 3 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const USER_SUMMARY_PROJECTION = [
"officer{id,dob,phone,lastName,otherNames,email}",
"iUser{id,phone,lastName,otherNames,email,roles{id,name}}",
"claimAdmin{id,phone,lastName,otherNames,emailId,dob}",
"validityTo",
"clientMutationId",
];
const DISTRICT_DATA_FETCH_PARAMS = "id, uuid, code, name, parent { id, uuid, name, code }";
Expand Down Expand Up @@ -158,6 +159,7 @@ export function fetchUser(mm, userId, clientMutationId) {
const filters = [];
if (userId) {
filters.push(`id: "${decodeId(userId)}"`);
filters.push("showDeleted: true");
} else if (clientMutationId) {
filters.push(`clientMutationId: "${clientMutationId}"`);
}
Expand All @@ -171,6 +173,7 @@ export function fetchUser(mm, userId, clientMutationId) {
clientMutationId
id
username
validityTo
officer {
id
uuid
Expand Down
1 change: 1 addition & 0 deletions src/components/AdminMainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
LocalPharmacy,
LocalPharmacyOutlined,
Person,
People,
PinDrop,
Tune,
} from "@material-ui/icons";
Expand Down
75 changes: 42 additions & 33 deletions src/components/UserFilter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import React, { Component } from "react";
import { injectIntl } from "react-intl";
import _debounce from "lodash/debounce";

import { withTheme, withStyles } from "@material-ui/core/styles";
import { injectIntl } from "react-intl";
import { Grid, Checkbox, FormControlLabel, } from "@material-ui/core";
import { withModulesManager, decodeId, PublishedComponent, ControlledField, TextInput, formatMessage } from "@openimis/fe-core";
import { Grid, Checkbox, FormControlLabel } from "@material-ui/core";

import {
withModulesManager,
decodeId,
PublishedComponent,
ControlledField,
TextInput,
formatMessage,
} from "@openimis/fe-core";

const styles = (theme) => ({
dialogTitle: theme.dialog.title,
Expand All @@ -26,6 +36,7 @@ const extractLocations = (locations) => {
const village = municipality && locationsArray.find((l) => l.parent && l.parent.id === municipality.id);

return { region, district, municipality, village };

};

const getParentLocation = (locations) => {
Expand Down Expand Up @@ -61,56 +72,57 @@ const getParentLocation = (locations) => {
};
}
return newLocation;

};

class UserFilter extends Component {
state = {
currentUserType: undefined,
currentUserRoles: undefined,
locationFilters: {},
selectedDistrict: {},
showHistory: false,
};

debouncedOnChangeFilter = _debounce(
this.props.onChangeFilters,
this.props.modulesManager.getConf("fe-admin", "debounceTime", 800),
this.props.modulesManager.getConf("fe-admin", "debounceTime", 200),
);

filterValue = (k) => {
const { filters } = this.props;
return !!filters && !!filters[k] ? filters[k].value : null;
};


filterTextFieldValue = (k) => {
const { filters } = this.props;
return !!filters && !!filters[k] ? filters[k].value : "";
};

filterDistrict = (locations) => {
const extractedLocations = extractLocations(locations);
const { district } = extractedLocations;

return district;
};

onChangeShowHistory = () => {

onChangeCheckbox = (key, value) => {
const filters = [
{
id: "showHistory",
value: !this.state.showHistory,
filter: `showHistory: ${!this.state.showHistory}`,
id: key,
value,
filter: `${key}: ${value}`,
},
];
this.props.onChangeFilters(filters);
this.setState((state) => ({
showHistory: !state.showHistory,
}));
};

onChangeUserTypes = (currentUserType) => {
const { onChangeFilters } = this.props;
this.setState({ currentUserType });
onChangeFilters([
{
id: "userTypes",
value: currentUserType,
filter: currentUserType ? `userTypes: [${currentUserType}]` : null,
filter: currentUserType ? `userTypes: [${currentUserType}]` : [],
},
]);
};
Expand All @@ -122,7 +134,7 @@ class UserFilter extends Component {
{
id: "roles",
value: currentUserRoles,
filter: currentUserRoles ? `roles: [${currentUserRoles.map((ur) => decodeId(ur.id)).join(",")}]` : null,
filter: currentUserRoles ? `roles: [${currentUserRoles.map((ur) => decodeId(ur.id)).join(",")}]` : [],
},
]);
};
Expand Down Expand Up @@ -165,7 +177,7 @@ class UserFilter extends Component {
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="admin.UserTypesPicker"
value={currentUserType}
value={this.filterValue("userTypes")}
onChange={(v) => this.onChangeUserTypes(v)}
/>
</Grid>
Expand All @@ -178,7 +190,7 @@ class UserFilter extends Component {
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="admin.UserRolesPicker"
value={currentUserRoles}
value={this.filterValue("roles")}
onChange={(v) => this.onChangeUserRoles(v)}
/>
</Grid>
Expand All @@ -193,6 +205,7 @@ class UserFilter extends Component {
pubRef="location.HealthFacilityPicker"
withNull={true}
value={this.filterValue("healthFacilityId") || ""}

district={selectedDistrict}
onChange={(v) => {
onChangeFilters([
Expand All @@ -208,13 +221,12 @@ class UserFilter extends Component {
}
/>
</Grid>

<Grid container>
<Grid item xs={12}>
<PublishedComponent
pubRef="location.DetailedLocationFilter"
withNull={true}
filters={locationFilters}
filters={filters}
onChangeFilters={this.onChangeLocation}
anchor="parentLocation"
/>
Expand All @@ -230,7 +242,7 @@ class UserFilter extends Component {
module="user"
label="admin.user.username"
name="username"
value={this.filterValue("username")}
value={this.filterTextFieldValue("username")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
Expand All @@ -253,7 +265,7 @@ class UserFilter extends Component {
module="user"
label="admin.user.lastName"
name="lastName"
value={this.filterValue("lastName")}
value={this.filterTextFieldValue("lastName")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
Expand All @@ -276,7 +288,7 @@ class UserFilter extends Component {
module="user"
label="admin.user.otherNames"
name="otherNames"
value={this.filterValue("otherNames")}
value={this.filterTextFieldValue("otherNames")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
Expand All @@ -299,7 +311,7 @@ class UserFilter extends Component {
module="user"
label="admin.user.email"
name="email"
value={this.filterValue("email")}
value={this.filterTextFieldValue("email")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
Expand All @@ -324,7 +336,7 @@ class UserFilter extends Component {
module="user"
label="admin.user.phone"
name="phone"
value={this.filterValue("phone")}
value={this.filterTextFieldValue("phone")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
Expand Down Expand Up @@ -384,22 +396,19 @@ class UserFilter extends Component {
/>
<ControlledField
module="policy"
id="PolicyFilter.showHistory"
id="PolicyFilter.showDeleted"
field={
<Grid item xs={2} className={classes.item}>
<FormControlLabel
control={
<Checkbox
color="primary"
checked={this.state.showHistory}
onChange={(e) => this.onChangeShowHistory()}
checked={!!this.filterValue("showDeleted")}
onChange={(event) => this.onChangeCheckbox("showDeleted", event.target.checked)}
/>
}
label={formatMessage(
intl,
"admin",
"UserFilter.showHistory"
)}
label={formatMessage(intl, "admin", "UserFilter.showDeleted")}

/>
</Grid>
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class UserForm extends Component {
},
].filter(Boolean);
return (
<div className={isInMutation ? classes.lockedPage : null}>
<div className={isInMutation || !!user?.validityTo ? classes.lockedPage : null}>
<Helmet title={formatMessageWithValues(this.props.intl, "admin.user", "UserOverview.title", { label: "" })} />
<ProgressOrError progress={fetchingUser} error={errorUser} />
{(!userId || user?.id === userId) && (
Expand All @@ -230,8 +230,8 @@ class UserForm extends Component {
Panels={[EnrolmentOfficerFormPanel, ClaimAdministratorFormPanel]}
user={user}
onEditedChanged={this.onEditedChanged}
canSave={this.canSave}
save={save ? this.save : null}
canSave={!user.validityTo && this.canSave}
save={save && !user.validityTo ? this.save : null}
onActionToConfirm={this.onActionToConfirm}
obligatory_user_fields={obligatoryUserFields}
obligatory_eo_fields={obligatoryEoFields}
Expand Down
Loading

0 comments on commit 1d254d8

Please sign in to comment.