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

Release 2.2.3 #117

Merged
merged 86 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
95ea3e8
Support multiple authentications on login form
jebesampaio Jan 27, 2022
cf5b5a5
Merge branch 'feature/FP-1293-LDAP-configuration-page' into feature/f…
jebesampaio Jan 31, 2022
4264332
More changes to login form
jebesampaio Feb 10, 2022
eba9707
Material table should receive all props
jebesampaio Feb 10, 2022
36d178d
Merge branch 'feature/FP-1358-support-different-authentications' into…
jebesampaio Feb 10, 2022
9b1b629
Merge remote-tracking branch 'origin/dev' into feature/fp-1357-epic-s…
jebesampaio Feb 15, 2022
e3c7355
Adjustments after API refactor
jebesampaio Mar 3, 2022
ef94875
Add check to multiple select
jebesampaio Mar 8, 2022
5d3d566
Profile menu onclick refactor
jebesampaio Mar 8, 2022
32b0080
Separate advanced section into its own component
jebesampaio Mar 8, 2022
31f1bc1
Add missing import for checkbox
jebesampaio Mar 8, 2022
90ef892
Extract styles to its own file
jebesampaio Mar 8, 2022
df408cb
Merge branch 'develop/2.2.3' into feature/fp-1357-epic-support-ldap-a…
jebesampaio Mar 8, 2022
3faff5e
Remove styles
jebesampaio Mar 9, 2022
9d5094c
Refactor style.js
jebesampaio Mar 9, 2022
e8daace
Adjustments do styles
jebesampaio Mar 9, 2022
eb68736
Adjust form controls width
jebesampaio Mar 9, 2022
2eb4703
Merge branch 'feature/FP-1293-LDAP-configuration-page' into feature/f…
jebesampaio Mar 10, 2022
0f3f51a
Add package.json
jebesampaio Mar 10, 2022
8011f59
Merge remote-tracking branch 'origin/dev' into feature/fp-1357-epic-s…
jebesampaio Mar 11, 2022
fe3b4f5
Fixed onClick event not being passed to item
jebesampaio Mar 28, 2022
57abcba
Merge pull request #65 from MOV-AI/feature/fp-1357-epic-support-ldap-…
jebesampaio Mar 28, 2022
49730ad
Remove withAuthentication duplicate user fetch to obtain its properties
jebesampaio Mar 30, 2022
05ebace
Merge branch 'dev' of github.com:MOV-AI/frontend-npm-lib-react into f…
jebesampaio Mar 30, 2022
6b3fa81
Merge branch 'develop/2.2.3' of github.com:MOV-AI/frontend-npm-lib-re…
jebesampaio Mar 30, 2022
6ec60e7
Merge remote-tracking branch 'origin/develop/2.2.3' into feature/FP-1…
jebesampaio Mar 30, 2022
2ca817e
Remove all the apps dependency on current user by passing it as insid…
jebesampaio Mar 31, 2022
8eba577
Merge branch 'dev' of github.com:MOV-AI/frontend-npm-lib-react into d…
jebesampaio Apr 5, 2022
b68bc39
Merge remote-tracking branch 'origin/develop/2.2.3' into feature/FP-1…
jebesampaio Apr 5, 2022
c9d4561
After successfull login and failed to obtain permissions show the mes…
jebesampaio Apr 5, 2022
208abb5
Replace console.log with console.warn in setLoggedIn defaultProp
jebesampaio Apr 6, 2022
2ab35f1
Merge pull request #80 from MOV-AI/feature/FP-1295-Support-new-token
MatheusFernandes-Movai Apr 6, 2022
170bc5a
Add changes to support fetching permissions for all types of users
jebesampaio Apr 12, 2022
15a79b2
Merge remote-tracking branch 'origin/dev' into develop/2.2.3
jebesampaio Apr 12, 2022
1248df3
Merge branch 'develop/2.2.3' of github.com:MOV-AI/frontend-npm-lib-re…
jebesampaio Apr 12, 2022
9d23573
Merge remote-tracking branch 'origin/develop/2.2.3' into feature/FP-1…
jebesampaio Apr 12, 2022
9044284
ChangePassword body properties renamed
jebesampaio Apr 12, 2022
2a09669
Change password should only be available to internal users
jebesampaio Apr 12, 2022
0bdb61c
Start loading before authenticating user
jebesampaio Apr 12, 2022
6d1f5fb
Fix some issues with login
jebesampaio Apr 13, 2022
60d0e5f
Remove console.log
jebesampaio Apr 13, 2022
926e2e1
Fix loading triggering snackbar with error when token expires
jebesampaio Apr 18, 2022
e41f754
Revert changes
jebesampaio Apr 19, 2022
8d4e994
Change super user property name to be according to the code convention
jebesampaio Apr 20, 2022
a26f4b8
Fix issues with loading and error handling
jebesampaio Apr 20, 2022
43fb7d7
Clear error message when user types something
jebesampaio Apr 20, 2022
d0faf24
Styling fixes for advanced button toggle
jebesampaio Apr 20, 2022
40a8a14
Merge pull request #91 from MOV-AI/feature/FP-1295-Support-new-token
jebesampaio Apr 21, 2022
292dee7
Restore last selected domain if only multiple domains are available
jebesampaio Apr 21, 2022
79dcda7
Merge branch 'dev' of github.com:MOV-AI/frontend-npm-lib-react into d…
jebesampaio Apr 21, 2022
9a8e94e
Merge branch 'develop/2.2.3' of github.com:MOV-AI/frontend-npm-lib-re…
jebesampaio Apr 21, 2022
d128829
Fix bad merge
jebesampaio Apr 21, 2022
359fa2b
Update lib-core version
jebesampaio Apr 22, 2022
550283a
Bump version
jebesampaio Apr 22, 2022
c787339
Merge pull request #97 from MOV-AI/feature/FP-1295-Support-new-token
RianMartins-Movai Apr 22, 2022
029c607
Add possibility to customize None option in select component
jebesampaio Apr 28, 2022
662c965
Fix password modal not sending userId to lib-core
jebesampaio Apr 28, 2022
364431b
Merge pull request #99 from MOV-AI/bugfix/FP-1718-roles-selecting-non…
jebesampaio Apr 28, 2022
3390cca
Remove userId from default props
jebesampaio Apr 29, 2022
0689bc0
Merge pull request #100 from MOV-AI/feature/FP-1720-change-password-r…
jebesampaio Apr 29, 2022
2468daf
Update lib-core
MatheusFernandes-Movai Apr 29, 2022
b53a6cb
Implement home menu and home menu skeleton
MatheusFernandes-Movai Apr 29, 2022
7305b27
Merge branch 'develop/2.2.3' of github.com:MOV-AI/frontend-npm-lib-re…
MatheusFernandes-Movai Apr 29, 2022
5bd9a9c
Use app constants
MatheusFernandes-Movai May 2, 2022
e7ed2a8
Update package-lock
MatheusFernandes-Movai May 2, 2022
f40e855
Update package-lock
MatheusFernandes-Movai May 2, 2022
b5dac0b
FP-873 : Improve HomeMenu after code review
MatheusFernandes-Movai May 5, 2022
38085a4
Add getAllApps subscriber to useEffect
MatheusFernandes-Movai May 5, 2022
bc70066
Add getAllApps subscriber to useEffect
MatheusFernandes-Movai May 5, 2022
75dbaa2
Merge pull request #101 from MOV-AI/feature/FP-873--home-menu-popper
RianMartins-Movai May 6, 2022
94a03c4
When invalidating refresh token refresh and logging in make underlyin…
jebesampaio May 12, 2022
d88883a
Bump to latest lib-core version
jebesampaio May 12, 2022
010df63
Make code clear by removing multiple ternary expressions
jebesampaio May 12, 2022
6bcdd56
Fix wrong code
jebesampaio May 12, 2022
3bd4ea5
Extract loading component to be returned first
jebesampaio May 12, 2022
5786ccc
Merge pull request #108 from MOV-AI/bugfix/FP-1799-fix-login-error-on…
jebesampaio May 12, 2022
c2d7c13
Merge branch 'dev' of github.com:MOV-AI/frontend-npm-lib-react into d…
jebesampaio May 13, 2022
52e0cba
Bump version to 1.1.1
jebesampaio May 13, 2022
fa15d6d
Add colorStyle to HomeMenu
MatheusFernandes-Movai May 12, 2022
9e8ab6b
Add iconColor to styles.js
MatheusFernandes-Movai May 12, 2022
a166070
Merge pull request #112 from MOV-AI/icon-color--to--releases/2.2.3
RianMartins-Movai May 13, 2022
618dff9
Merge branch 'dev' of github.com:MOV-AI/frontend-npm-lib-react into d…
jebesampaio May 16, 2022
24738c2
Use latest lib-core release
jebesampaio May 16, 2022
cabe81f
Merge pull request #110 from MOV-AI/develop/2.2.3
jebesampaio May 16, 2022
d677b66
Merge branch 'main' of github.com:MOV-AI/frontend-npm-lib-react into dev
jebesampaio May 16, 2022
fbc3815
Revert readme change
jebesampaio May 16, 2022
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
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mov-ai/mov-fe-lib-react",
"version": "1.0.46-0",
"version": "1.1.1-0",
"description": "The Mov.AI's frontend library for React.",
"publishConfig": {
"registry": "https://npm.pkg.github.com/mov-ai"
Expand Down Expand Up @@ -83,7 +83,7 @@
"@babel/runtime": "^7.15.4",
"@date-io/date-fns": "^1.3.13",
"@material-ui/pickers": "^3.3.10",
"@mov-ai/mov-fe-lib-core": "^1.0.42-0",
"@mov-ai/mov-fe-lib-core": "^1.1.1-1",
"clsx": "^1.1.1",
"fontsource-open-sans": "^3.0.9",
"fontsource-roboto": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const ContextMenu = props => {
<StyledMenuItem
data-testid="input_menu-item"
onClick={evt => {
item.onClick();
item.onClick(evt);
if (item.onClose || item.onClose === undefined) {
handleClose(evt);
}
Expand Down
128 changes: 81 additions & 47 deletions src/Components/HOCs/withAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,47 @@ export default function withAuthentication(Component, appName) {

const firstRender = useRef(true);
const [state, setState] = useState({
loading: true,
loggedIn: false,
hasPermissions: false
hasPermissions: false,
currentUser: {}
});
const [loading, setLoading] = useState(true);
const [errorMessage, setErrorMessage] = useState("");
const [authenticationProviders, setAuthenticationProviders] = useState([]);

const authenticate = useCallback(() => {
const user = new User();

setLoading(true);
Promise.all([
Authentication.checkLogin(),
new Promise(resolve => setTimeout(resolve, 2000)),
user.getAllowedApps(),
user.isSuperUser()
user.getCurrentUserWithPermissions()
])
.then(values => {
const [loggedIn, _, apps, isSuperUser] = values;

.then(([loggedIn, _, user]) => {
const {
Resources: { Applications: apps = [] },
Superuser: isSuperUser
} = user;
const hasPermissions =
isSuperUser || apps.includes(appName) || !appName;

if (loggedIn) {
firstRender.current = false;
}

setState({ loading: false, loggedIn, hasPermissions });
setState({
loggedIn,
hasPermissions,
currentUser: user
});
})
.catch(e => {
setState({ loggedIn: false, loading: false, hasPermissions: false });
});
setState({
loggedIn: false,
hasPermissions: false
});
})
.finally(_ => setLoading(false));
}, []);

/**
Expand All @@ -49,6 +61,20 @@ export default function withAuthentication(Component, appName) {
authenticate();
}, []);

/**
* Updates the Access Token and the Refresh Token
*/
useEffect(() => {
Authentication.getProviders()
.then(response => setAuthenticationProviders(response.domains))
.catch(e =>
console.log(
"Error while fetching authentication providers: ",
e.error
)
);
}, []);

/**
* Updates the Access Token and the Refresh Token
*/
Expand Down Expand Up @@ -101,23 +127,28 @@ export default function withAuthentication(Component, appName) {
};

/**
* handleFirstRender
* Renders the loading panel while checking the user authentication and permissions
* Renders the login form when the user is not authenticated
* @returns React Component
* handleLoginSubmit - handle the user login credentials submit
* @param {{ username, password, remember, selectedProvider }}
*/
const handleFirstRender = () => {
return state.loading ? (
renderLoading()
) : (
<LoginForm
setLoggedIn={value => {
setState(prevState => ({ ...prevState, loading: true }));
authenticate();
}}
/>
);
};
const handleLoginSubmit = useCallback(
async ({ username, password, remember, selectedProvider }) => {
try {
setLoading(true);
const apiResponse = await Authentication.login(
username,
password,
remember,
selectedProvider
);
if (apiResponse.error) throw new Error(apiResponse.error);
authenticate();
} catch (e) {
setErrorMessage(e.message);
setLoading(false);
}
},
[]
);

/**
* renderLoading - Renders the loading panel
Expand All @@ -127,6 +158,19 @@ export default function withAuthentication(Component, appName) {
return <LoginPanel message={"Preparing the bots"} progress={true} />;
};

/**
* renderLoginForm - Renders the login form
* @returns React Component
*/
const renderLoginForm = () => (
<LoginForm
domains={authenticationProviders}
authErrorMessage={errorMessage}
onLoginSubmit={handleLoginSubmit}
onChanges={setErrorMessage}
/>
);

/**
* renderNotAuthorized - Renders the not authorized panel
* @returns React Component
Expand All @@ -143,28 +187,18 @@ export default function withAuthentication(Component, appName) {
/**
* renders the Login form if the user is not logged in
*/
if (loading) return renderLoading();
if (!state.loggedIn && firstRender.current) return renderLoginForm();
if (!state.hasPermissions) return renderNotAuthorized();
return (
<React.Fragment>
{!state.loggedIn && firstRender.current ? (
handleFirstRender()
) : state.hasPermissions ? (
<React.Fragment>
<Component
handleLogOut={handleLogOut}
loggedIn={state.loggedIn}
{...props}
/>
<Modal open={!state.loggedIn}>
<LoginForm
setLoggedIn={value =>
setState(prevState => ({ ...prevState, loggedIn: value }))
}
/>
</Modal>
</React.Fragment>
) : (
renderNotAuthorized()
)}
<Component
currentUser={state.currentUser}
handleLogOut={handleLogOut}
loggedIn={state.loggedIn}
{...props}
/>
<Modal open={!state.loggedIn}>{renderLoginForm()}</Modal>
</React.Fragment>
);
};
Expand Down
Loading