Skip to content

Commit

Permalink
Remove logout reducer logic, routing table reducers
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-alan committed Nov 30, 2023
1 parent 4b87c2f commit 7081abd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 59 deletions.
7 changes: 6 additions & 1 deletion packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Components, models, actions, and utility functions for LabKey applications and pages.

### version 3.0.0
*Released*: ?? November 2023
*Released*: ?? December 2023
* Breaking Changes:
* Upgrade react-router dependency to react-router-dom version 6.x
* If you use react-router you will need to upgrade
Expand All @@ -22,6 +22,11 @@ Components, models, actions, and utility functions for LabKey applications and p
* Don't export UsersGridPanel or PermissionAssignments
* AppRouteResolver: fetch now returns Promise<AppURL> instead of Promise<AppURL | boolean>
* SubNav is no longer exported
* Removed unused constants
* SECURITY_LOGOUT
* SECURITY_SERVER_UNAVAILABLE
* SECURITY_SESSION_TIMEOUT
* Removed RoutingTableState and RoutingTableReducers

### version 2.395.2
*Released*: 29 November 2023
Expand Down
12 changes: 1 addition & 11 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ import { OntologyBrowserPage } from './internal/components/ontology/OntologyBrow
import { OntologyConceptOverviewPanel } from './internal/components/ontology/ConceptOverviewPanel';
import { OntologyBrowserFilterPanel } from './internal/components/ontology/OntologyBrowserFilterPanel';
import { OntologySearchInput } from './internal/components/ontology/OntologyTreeSearchContainer';
import { AppModel, LogoutReason } from './internal/app/models';
import { AppModel } from './internal/app/models';
import { Picklist, PICKLIST_SAMPLES_FILTER } from './internal/components/picklist/models';
import { PicklistCreationMenuItem } from './internal/components/picklist/PicklistCreationMenuItem';
import { PicklistButton } from './internal/components/picklist/PicklistButton';
Expand All @@ -652,7 +652,6 @@ import { ColumnSelectionModal } from './internal/components/ColumnSelectionModal
import {
AppReducers,
ProductMenuReducers,
RoutingTableReducers,
ServerNotificationReducers,
} from './internal/app/reducers';

Expand Down Expand Up @@ -775,9 +774,6 @@ import {
SAMPLE_TYPE_KEY,
SAMPLES_KEY,
SEARCH_KEY,
SECURITY_LOGOUT,
SECURITY_SERVER_UNAVAILABLE,
SECURITY_SESSION_TIMEOUT,
SERVER_NOTIFICATION_MAX_ROWS,
SOURCE_TYPE_KEY,
SOURCES_KEY,
Expand Down Expand Up @@ -843,7 +839,6 @@ enablePatches();
const App = {
AppReducers,
ProductMenuReducers,
RoutingTableReducers,
ServerNotificationReducers,
CloseEventCode,
EntityCreationMode,
Expand Down Expand Up @@ -909,9 +904,6 @@ const App = {
userCanEditSharedViews,
userCanDeletePublicPicklists,
getCurrentProductName,
SECURITY_LOGOUT,
SECURITY_SERVER_UNAVAILABLE,
SECURITY_SESSION_TIMEOUT,
UPDATE_USER,
UPDATE_USER_DISPLAY_NAME,
BIOLOGICS: BIOLOGICS_APP_PROPERTIES,
Expand Down Expand Up @@ -1008,7 +1000,6 @@ export {
App,
AppModel,
Hooks,
LogoutReason,
getDefaultAPIWrapper,
// global state functions
initQueryGridState,
Expand Down Expand Up @@ -1759,7 +1750,6 @@ export type { BulkAddData, SharedEditableGridPanelProps } from './internal/compo
export type { IImportData, ISelectRowsResult } from './internal/query/api';
export type { Row, RowValue, SelectRowsOptions, SelectRowsResponse } from './internal/query/selectRows';
export type {
RoutingTableState,
ServerNotificationState,
ProductMenuState,
AppReducerState,
Expand Down
4 changes: 0 additions & 4 deletions packages/components/src/internal/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ export const USER_PERMISSIONS_REQUEST = '/app/USER_PERMISSIONS_REQUEST';
export const USER_PERMISSIONS_SUCCESS = '/app/USER_PERMISSIONS_SUCCESS';
export const UPDATE_USER = '/app/UPDATE_USER';
export const UPDATE_USER_DISPLAY_NAME = '/app/UPDATE_USER_DISPLAY_NAME';
export const SECURITY_LOGOUT = '/app/SECURITY_LOGOUT';
export const SECURITY_SESSION_TIMEOUT = '/app/SECURITY_SESSION_TIMEOUT';
export const SECURITY_SERVER_UNAVAILABLE = '/app/SECURITY_SERVER_UNAVAILABLE';
export const ADD_TABLE_ROUTE = '/app/ADD_TABLE_ROUTE';
export const MENU_LOADING_START = '/app/MENU_LOADING_START';
export const MENU_LOADING_END = '/app/MENU_LOADING_END';
export const MENU_LOADING_ERROR = '/app/MENU_LOADING_ERROR';
Expand Down
12 changes: 1 addition & 11 deletions packages/components/src/internal/app/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,30 @@ import { ComponentType } from 'react';

import { Container } from '../components/base/models/Container';
import { User } from '../components/base/models/User';
import { ProjectConfigurableDataType } from '../components/entities/models';

const user = new User({
...getServerContext().user,
permissionsList: getServerContext().container?.effectivePermissions ?? [],
});

export enum LogoutReason {
SERVER_LOGOUT,
SESSION_EXPIRED,
SERVER_UNAVAILABLE,
}

export class AppModel extends Record({
container: new Container(getServerContext().container),
contextPath: ActionURL.getContextPath(),
initialUserId: user.id,
logoutReason: undefined,
reloadRequired: false,
user,
}) {
declare container: Container;
declare contextPath: string;
declare initialUserId: number;
declare logoutReason: LogoutReason;
declare reloadRequired: boolean;
declare user: User;

hasUserChanged(): boolean {
return this.initialUserId !== this.user.id;
}

shouldReload(): boolean {
return this.reloadRequired || this.hasUserChanged();
return this.hasUserChanged();
}
}

Expand Down
33 changes: 1 addition & 32 deletions packages/components/src/internal/app/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ import { ProductMenuModel } from '../components/navigation/model';

import { ServerNotificationModel } from '../components/notifications/model';

import { AppModel, LogoutReason } from './models';
import { AppModel } from './models';
import {
SECURITY_LOGOUT,
SECURITY_SERVER_UNAVAILABLE,
SECURITY_SESSION_TIMEOUT,
UPDATE_USER,
UPDATE_USER_DISPLAY_NAME,
ADD_TABLE_ROUTE,
MENU_INVALIDATE,
MENU_LOADING_START,
MENU_LOADING_ERROR,
Expand All @@ -37,33 +33,6 @@ export function AppReducers(state = new AppModel(), action): AppReducerState {
return state.merge({ user: new User({ ...state.user, ...action.userProps }) }) as AppModel;
case UPDATE_USER_DISPLAY_NAME:
return state.merge({ user: new User({ ...state.user, displayName: action.displayName }) }) as AppModel;
case SECURITY_LOGOUT:
return state.merge({
logoutReason: LogoutReason.SERVER_LOGOUT,
reloadRequired: true,
}) as AppModel;
// TODO: the following constants appear to never be dispatched, are these handlers needed?
case SECURITY_SESSION_TIMEOUT:
return state.merge({
logoutReason: LogoutReason.SESSION_EXPIRED,
reloadRequired: true,
}) as AppModel;
case SECURITY_SERVER_UNAVAILABLE:
return state.merge({
logoutReason: LogoutReason.SERVER_UNAVAILABLE,
reloadRequired: true,
}) as AppModel;
default:
return state;
}
}

export type RoutingTableState = Map<string, string | boolean>;

export function RoutingTableReducers(state = Map<string, string | boolean>(), action): RoutingTableState {
switch (action.type) {
case ADD_TABLE_ROUTE:
return state.set(action.fromRoute, action.toRoute) as RoutingTableState;
default:
return state;
}
Expand Down

0 comments on commit 7081abd

Please sign in to comment.