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

Feature/lazy-loading #31

Merged
merged 18 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

- Vertical spacing unification across seacat admin screens app. (INDIGO Sprint 230414, [!26](https://github.com/TeskaLabs/seacat-admin-webui/pull/26))

- Lazy loading enabled in auth and home modules. (INDIGO Sprint 230428, [!31](https://github.com/TeskaLabs/seacat-admin-webui/pull/31))

## v23.16-beta

### Compatibility
Expand Down
38 changes: 20 additions & 18 deletions src/modules/auth/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { lazy } from 'react';
import { componentLoader } from 'asab-webui';
import Module from 'asab-webui/abc/Module';

import CredentialsListContainer from './credentials/CredentialsListContainer';
import CredentialsDetailContainer from './credentials/CredentialsDetailContainer';
import CredentialsCreateContainer from './credentials/CredentialsCreateContainer';
import ResetPasswordContainer from './credentials/ResetPasswordContainer';
const CredentialsListContainer = lazy(() => componentLoader(() => import('./credentials/CredentialsListContainer')));
const CredentialsDetailContainer = lazy(() => componentLoader(() => import('./credentials/CredentialsDetailContainer')));
const CredentialsCreateContainer = lazy(() => componentLoader(() => import('./credentials/CredentialsCreateContainer')));
const ResetPasswordContainer = lazy(() => componentLoader(() => import('./credentials/ResetPasswordContainer')));

import SessionListContainer from './session/SessionListContainer';
import SessionDetailContainer from './session/SessionDetailContainer';
const SessionListContainer = lazy(() => componentLoader(() => import('./session/SessionListContainer')));
const SessionDetailContainer = lazy(() => componentLoader(() => import('./session/SessionDetailContainer')));

import TenantListContainer from './tenant/TenantListContainer';
import TenantCreateContainer from './tenant/TenantCreateContainer';
import TenantDetailContainer from './tenant/TenantDetailContainer';
const TenantListContainer = lazy(() => componentLoader(() => import('./tenant/TenantListContainer')));
const TenantCreateContainer = lazy(() => componentLoader(() => import('./tenant/TenantCreateContainer')));
const TenantDetailContainer = lazy(() => componentLoader(() => import('./tenant/TenantDetailContainer')));

import RolesCreateContainer from './roles/RolesCreateContainer';
import RolesListContainer from './roles/RolesListContainer';
import RolesDetailContainer from './roles/RolesDetailContainer';
const RolesCreateContainer = lazy(() => componentLoader(() => import('./roles/RolesCreateContainer')));
const RolesListContainer = lazy(() => componentLoader(() => import('./roles/RolesListContainer')));
const RolesDetailContainer = lazy(() => componentLoader(() => import('./roles/RolesDetailContainer')));

import ResourcesListContainer from './resources/ResourcesListContainer';
import ResourcesDetailContainer from './resources/ResourcesDetailContainer';
import ResourcesCreateContainer from './resources/ResourcesCreateContainer';
const ResourcesListContainer =lazy(() => componentLoader(() => import('./resources/ResourcesListContainer')));
const ResourcesDetailContainer =lazy(() => componentLoader(() => import('./resources/ResourcesDetailContainer')));
const ResourcesCreateContainer =lazy(() => componentLoader(() => import('./resources/ResourcesCreateContainer')));

import ClientListContainer from './clients/ClientListContainer';
import ClientCreateContainer from './clients/ClientCreateContainer';
import ClientDetailContainer from './clients/ClientDetailContainer';
const ClientListContainer = lazy(() => componentLoader(() => import('./clients/ClientListContainer')));
const ClientCreateContainer = lazy(() => componentLoader(() => import('./clients/ClientCreateContainer')));
const ClientDetailContainer = lazy(() => componentLoader(() => import('./clients/ClientDetailContainer')));

// SCSS
import './tenant/tenant.scss';
Expand Down
19 changes: 0 additions & 19 deletions src/modules/auth/tenant/TenantDetailContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ function TenantDetailContainer(props) {
const [page, setPage] = useState(1);
const [filter, setFilter] = useState("");
const limit = 10;
const [username, setUsername] = useState();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petrKavulok Ok, why were those items removed and why it is not in changelog or at least in the description of this PR then? Its very hard to distinguish from reviewers point of view, why this change has been made without any context .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because I noticed that this functionality was already taken care of by the <Credentials /> component. I should have made a separate PR for that. Sorry, next time I'll separate it to two PRs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petrKavulok PLease add the information about what has been removed and why to the changelog please :)

const [edit, setEdit] = useState(false);
const [loading, setLoading] = useState(true);
const [loadingCustomData, setLoadingCustomData] = useState(true);
const [show, setShow] = useState(false);
Expand Down Expand Up @@ -124,10 +122,6 @@ function TenantDetailContainer(props) {
retrieveData();
}, []);

useEffect(() => {
data.created_by && retrieveUserName();
}, [data.created_by]);

const retrieveData = async () => {
try {
let response = await SeaCatAuthAPI.get(`/tenant/${tenant_id}`);
Expand All @@ -141,19 +135,6 @@ function TenantDetailContainer(props) {
}
};

const retrieveUserName = async () => {
try {
let response = await SeaCatAuthAPI.put(`usernames`, [data.created_by]);
if (response.data.result !== "OK") {
throw new Error(t("TenantDetailContainer|Something went wrong, failed to fetch assigned credentials"));
}
setUsername(response.data.data[data.created_by]);
} catch (e) {
console.error(e);
props.app.addAlert("warning", `${t("TenantDetailContainer|Something went wrong, failed to fetch assigned credentials")}. ${e?.response?.data?.message}`, 30);
}
}

const retrieveAssignedCredentials = async () => {
try {
let response = await SeaCatAuthAPI.get(`/credentials?m=tenant&f=${tenant_id}`, {params: {p:page, i: limit}});
Expand Down
6 changes: 5 additions & 1 deletion src/modules/home/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import HomeContainer from './containers/HomeContainer'
import { lazy } from 'react';
import { componentLoader } from 'asab-webui';
import Module from 'asab-webui/abc/Module';

const HomeContainer = lazy(() => componentLoader(() => import('./containers/HomeContainer')));

import "./containers/home.scss";

export default class HomeModule extends Module {
Expand Down