Skip to content

Commit

Permalink
Finish release/2022-04
Browse files Browse the repository at this point in the history
Release/2022 04
  • Loading branch information
hirensoni913 authored Oct 5, 2022
2 parents 1f09a61 + 08c1a0d commit d087c80
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 218 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,38 @@ name: Node.js Package

on:
release:
types: [created]
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: olegtarasov/get-tag@v2.1
id: tagName
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
- name: update the version with TAG
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
- run: yarn install
- run: yarn build
- run: yarn build


publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: olegtarasov/get-tag@v2.1
id: tagName
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org/
scope: openimis
- name: update the version with TAG
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
- run: yarn install
- run: yarn build
- run: npm publish --access public
Expand All @@ -38,11 +47,15 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: olegtarasov/get-tag@v2.1
id: tagName
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://npm.pkg.github.com/
- name: update the version with TAG
run: echo $(jq --arg a "$GIT_TAG_NAME" '.version = ($a)' package.json) > package.json
- run: yarn install
- run: yarn build
- run: npm publish
Expand Down
18 changes: 2 additions & 16 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const USER_SUMMARY_PROJECTION = [
"clientMutationId",
];

export const USER_PICKER_PROJECTION = ["id", "username", "iUser{id otherNames lastName}"];

export function fetchUsers(mm, filters = [], restrictHealthFacility = true) {
return (dispatch, getState) => {
if (restrictHealthFacility) {
Expand All @@ -34,22 +36,6 @@ export function fetchUsers(mm, filters = [], restrictHealthFacility = true) {
return dispatch(graphql(payload, "ADMIN_USERS", filters));
};
}

export function fetchUserRoles(mm, hf, str, prev) {
const filters = [];
if (hf) {
filters.push(`healthFacility_Uuid: "${hf.uuid}"`);
}
if (str) {
filters.push(`str: "${str}"`);
}
if (_.isEqual(filters, prev)) {
return (dispatch) => {};
}
const payload = formatPageQuery("role", filters, mm.getRef("admin.UserRolesPicker.projection"));
return graphql(payload, "ADMIN_USER_ROLES", filters);
}

export function fetchUsersSummaries(mm, filters) {
const payload = formatPageQueryWithCount("users", filters, USER_SUMMARY_PROJECTION);
return graphql(payload, "ADMIN_USERS_SUMMARIES");
Expand Down
9 changes: 0 additions & 9 deletions src/components/AdminMainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from "react";
import { injectIntl } from "react-intl";
import { connect } from "react-redux";
import {
AccountBalance,
LocationCity,
Healing,
HealingOutlined,
Expand All @@ -24,7 +23,6 @@ import {
// RIGHT_ENROLMENTOFFICER,
// RIGHT_CLAIMADMINISTRATOR,
RIGHT_USERS,
RIGHT_PAYERS,
RIGHT_LOCATIONS,
} from "../constants";

Expand Down Expand Up @@ -87,13 +85,6 @@ class AdminMainMenu extends Component {
route: "/admin/users",
});
}
if (rights.includes(RIGHT_PAYERS)) {
entries.push({
text: formatMessage(this.props.intl, "admin", "menu.payers"),
icon: <AccountBalance />,
route: "/admin/payers",
});
}
if (rights.includes(RIGHT_LOCATIONS)) {
entries.push({
text: formatMessage(this.props.intl, "admin", "menu.locations"),
Expand Down
1 change: 0 additions & 1 deletion src/components/EnrolmentOfficerFormPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const EnrolmentOfficerFormPanel = (props) => {
<PublishedComponent
pubRef="admin.EnrolmentOfficerPicker"
module="admin"
healthFacility={edited.healthFacility}
readOnly={readOnly}
label={formatMessage("substitutionOfficer")}
value={edited.substitutionOfficer}
Expand Down
10 changes: 0 additions & 10 deletions src/components/ProductsPage.js

This file was deleted.

12 changes: 2 additions & 10 deletions src/components/UserMasterPanel.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import React from "react";
import { withTheme, withStyles } from "@material-ui/core/styles";
import { injectIntl } from "react-intl";
import { Grid, Divider, Typography } from "@material-ui/core";
import {
withHistory,
withModulesManager,
useTranslations,
TextInput,
PublishedComponent,
combine,
} from "@openimis/fe-core";
import { withModulesManager, useTranslations, TextInput, PublishedComponent, combine } from "@openimis/fe-core";
import { CLAIM_ADMIN_USER_TYPE } from "../constants";

const styles = (theme) => ({
Expand Down Expand Up @@ -162,6 +154,6 @@ const UserMasterPanel = (props) => {
);
};

const enhance = combine(injectIntl, withModulesManager, withHistory, withTheme, withStyles(styles));
const enhance = combine(withModulesManager, withTheme, withStyles(styles));

export default enhance(UserMasterPanel);
11 changes: 7 additions & 4 deletions src/components/UserSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ const getAligns = () => {
class UserSearcher extends Component {
state = {
deleteUser: null,
params: {},
};

fetch = (prms) => {
this.props.fetchUsersSummaries(this.props.modulesManager, prms);
fetch = (params) => {
this.setState({ params });
this.props.fetchUsersSummaries(this.props.modulesManager, params);
};

filtersToQueryParams = (state) => {
Expand All @@ -75,12 +77,13 @@ class UserSearcher extends Component {
this.setState({ deleteUser: null });
} else {
const user = this.state.deleteUser;
this.setState({ deleteUser: null }, () => {
this.props.deleteUser(
this.setState({ deleteUser: null }, async () => {
await this.props.deleteUser(
this.props.modulesManager,
user,
formatMessage(this.props.intl, "admin.user", "deleteDialog.title"),
);
this.fetch(this.state.params);
});
}
};
Expand Down
84 changes: 20 additions & 64 deletions src/components/pickers/EnrolmentOfficerPicker.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { withTheme, withStyles } from "@material-ui/core/styles";
import { Autocomplete } from "@material-ui/lab";
import { TextField } from "@material-ui/core";
import { withModulesManager, useDebounceCb, useTranslations } from "@openimis/fe-core";
import { Autocomplete } from "@openimis/fe-core";
import { fetchEnrolmentOfficers } from "../../actions";

const styles = (theme) => ({
label: {
color: theme.palette.primary.main,
},
});

const formatSuggestion = (p) => {
if (!p) return "?";
return [p.code, p.lastName, p.otherNames].filter(Boolean).join(" ");
Expand All @@ -31,74 +22,39 @@ const EnrolmentOfficerPicker = (props) => {
placeholder,
multiple = false,
} = props;
const minCharLookup = modulesManager.getConf("fe-admin", "usersMinCharLookup", 2);
const dispatch = useDispatch();
const [searchString, setSearchString] = useState(null);
const { formatMessage } = useTranslations("admin.EnrolmentOfficerPicker", modulesManager);
const [open, setOpen] = useState(false);
const isLoading = useSelector((state) => state.admin.enrolmentOfficers.isFetching);
const items = useSelector((state) => state.admin.enrolmentOfficers.items);

const onInputChange = useDebounceCb(setSearchString, modulesManager.getConf("fe-admin", "debounceTime", 400));
// eslint-disable-next-line no-shadow
const handleChange = (__, value) => {
onChange(value);
if (!multiple) setOpen(false);
};
const isLoading = useSelector((state) => state.admin.enrolmentOfficers.isFetching);
const options = useSelector((state) => state.admin.enrolmentOfficers.items);

useEffect(() => {
if (searchString?.length > minCharLookup) {
dispatch(
fetchEnrolmentOfficers(modulesManager, {
searchString,
}),
);
}
dispatch(
fetchEnrolmentOfficers(modulesManager, {
first: searchString ? undefined : 10,
searchString,
}),
);
}, [searchString]);

useEffect(() => {
if (open) {
dispatch(
fetchEnrolmentOfficers(modulesManager, {
first: 10,
}),
);
}
}, [open]);

return (
<Autocomplete
loadingText={formatMessage("loadingText")}
openText={formatMessage("openText")}
closeText={formatMessage("closeText")}
clearText={formatMessage("clearText")}
openOnFocus
multiple={multiple}
disabled={readOnly}
options={items}
loading={isLoading}
open={open}
onOpen={() => setOpen(true)}
onClose={() => setOpen(false)}
autoComplete
required={required}
placeholder={placeholder}
label={label}
withLabel={withLabel}
readOnly={readOnly}
options={options}
isLoading={isLoading}
value={value}
getOptionLabel={(option) => formatSuggestion(option)}
getOptionSelected={(option, v) => option.id === v.id}
onChange={handleChange}
getOptionLabel={formatSuggestion}
onChange={onChange}
filterOptions={filterOptions}
filterSelectedOptions={filterSelectedOptions}
onInputChange={(__, query) => onInputChange(query)}
renderInput={(inputProps) => (
<TextField
{...inputProps}
variant="standard"
required={required}
label={withLabel && (label || formatMessage("label"))}
placeholder={placeholder}
/>
)}
onInputChange={setSearchString}
/>
);
};

export default withModulesManager(withTheme(withStyles(styles)(EnrolmentOfficerPicker)));
export default EnrolmentOfficerPicker;
Loading

0 comments on commit d087c80

Please sign in to comment.