studiokit-scaffolding-js 5.1.2 → 5.1.3-next.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/HOC/CollectionComponent.d.ts +1 -1
- package/lib/components/HOC/CollectionComponent.js +4 -2
- package/lib/components/HOC/CollectionItemComponent.d.ts +1 -1
- package/lib/components/HOC/CollectionItemComponent.js +4 -2
- package/lib/components/HOC/SearchPersistorComponent.d.ts +8 -4
- package/lib/components/HOC/SearchPersistorComponent.js +12 -8
- package/lib/components/SearchControls.d.ts +2 -0
- package/lib/components/SearchControls.js +2 -2
- package/lib/components/UserRoles/RoleCell.d.ts +1 -1
- package/lib/components/UserRoles/RoleCell.js +2 -7
- package/lib/components/UserRoles/index.d.ts +1 -1
- package/lib/constants/configuration.d.ts +2 -0
- package/lib/constants/configuration.js +10 -1
- package/lib/hooks/useCollection.js +15 -4
- package/lib/hooks/useCollectionItem.js +15 -4
- package/lib/hooks/useCurrentUserId.d.ts +1 -0
- package/lib/hooks/useCurrentUserId.js +13 -0
- package/lib/redux/sagas/sentrySaga.js +10 -4
- package/lib/startup.js +1 -1
- package/lib/types/Analytics.d.ts +10 -0
- package/lib/types/Analytics.js +2 -0
- package/lib/types/Collection.d.ts +3 -1
- package/lib/utils/analytics.d.ts +11 -0
- package/lib/utils/analytics.js +38 -0
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ export declare function configureCollectionComponent<TModel extends Model, TOwnP
|
|
|
46
46
|
};
|
|
47
47
|
contextType?: React.Context<any> | undefined;
|
|
48
48
|
};
|
|
49
|
-
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & Partial<CollectionComponentProps<TModel>>) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
49
|
+
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & Partial<CollectionComponentProps<TModel>>) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
50
50
|
/**
|
|
51
51
|
* HOC that provides "collection" related functionality, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
|
|
52
52
|
*
|
|
@@ -126,10 +126,12 @@ function configureCollectionComponent(WrappedComponent, LoaderComponent) {
|
|
|
126
126
|
};
|
|
127
127
|
CollectionComponent.prototype.componentDidUpdate = function (prevProps) {
|
|
128
128
|
var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
|
|
129
|
-
var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams;
|
|
129
|
+
var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams, disableAutoLoadOnParamsChange = _a.disableAutoLoadOnParamsChange;
|
|
130
130
|
var fetchingId = this.state.fetchingId;
|
|
131
131
|
model_1.handleModelFetchFinish(model, prevModel, fetchingId, this.changeModelStatus);
|
|
132
|
-
|
|
132
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
133
|
+
collection_1.handleCollectionParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
|
|
134
|
+
}
|
|
133
135
|
};
|
|
134
136
|
CollectionComponent.prototype.componentWillUnmount = function () {
|
|
135
137
|
var model = this.props.model;
|
|
@@ -45,7 +45,7 @@ export declare function configureCollectionItemComponent<TModel extends Model, T
|
|
|
45
45
|
};
|
|
46
46
|
contextType?: React.Context<any> | undefined;
|
|
47
47
|
};
|
|
48
|
-
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionItemComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
48
|
+
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionItemComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
49
49
|
/**
|
|
50
50
|
* HOC that provides "collection" related functionality for a single item in a collection, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
|
|
51
51
|
*
|
|
@@ -128,9 +128,11 @@ function configureCollectionItemComponent(WrappedComponent, LoaderComponent) {
|
|
|
128
128
|
};
|
|
129
129
|
CollectionItemComponent.prototype.componentDidUpdate = function (prevProps) {
|
|
130
130
|
var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
|
|
131
|
-
var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
|
|
131
|
+
var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams, disableAutoLoadOnParamsChange = _a.disableAutoLoadOnParamsChange;
|
|
132
132
|
model_1.handleModelFetchFinish(model, prevModel, undefined, this.setModelStatus);
|
|
133
|
-
|
|
133
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
134
|
+
collection_1.handleCollectionItemParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
|
|
135
|
+
}
|
|
134
136
|
};
|
|
135
137
|
CollectionItemComponent.prototype.render = function () {
|
|
136
138
|
var _a = this.props, history = _a.history, match = _a.match, location = _a.location, staticContext = _a.staticContext, otherProps = __rest(_a, ["history", "match", "location", "staticContext"]);
|
|
@@ -22,8 +22,8 @@ export interface SearchPersistorMethods<T extends Search = Search> {
|
|
|
22
22
|
export interface SearchPersistorWrappedProps<T extends Search = Search> extends SearchPersistorProps<T>, SearchPersistorMethods<T> {
|
|
23
23
|
search?: T;
|
|
24
24
|
}
|
|
25
|
-
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps
|
|
26
|
-
export declare function configureSearchPersistorComponent<TOwnProps extends {}, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps<TSearchType
|
|
25
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps>, disableLocalSearch?: boolean): ComponentType<TOwnProps & SearchPersistorProps>;
|
|
26
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps<TSearchType>>, disableLocalSearch?: boolean): ComponentType<TOwnProps & SearchPersistorProps<TSearchType>>;
|
|
27
27
|
export declare const configureMapStateToProps: <TSearchType extends Search>(key: string) => (state: BaseReduxState) => SearchPersistorProps<TSearchType>;
|
|
28
28
|
export declare const configureMapDispatchToProps: <TSearchType extends Search>(key: string) => (dispatch: Dispatch) => SearchPersistorProps<TSearchType>;
|
|
29
29
|
/**
|
|
@@ -44,9 +44,11 @@ export declare const configureMapDispatchToProps: <TSearchType extends Search>(k
|
|
|
44
44
|
*
|
|
45
45
|
* @param WrappedComponent The component to wrap
|
|
46
46
|
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
47
|
+
* @param disableLocalSearch By default, `doSearch` is only called at initialization and when `queryAll` is `true`, and searching happens locally (see ManageTable).
|
|
48
|
+
* If `disableLocalSearch` is `true` then the legacy logic is used, where `doSearch` is always called for all searches.
|
|
47
49
|
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
48
50
|
*/
|
|
49
|
-
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps>>;
|
|
51
|
+
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps>(WrappedComponent: ComponentType<TOwnProps>, key: string, disableLocalSearch?: boolean): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps>>;
|
|
50
52
|
/**
|
|
51
53
|
* HOC to handle persistence and restoration of "Manage" components search parameters.
|
|
52
54
|
* Note: if you store a search date in a child component, make sure it’s called `date`.
|
|
@@ -65,6 +67,8 @@ export default function searchPersistorComponent<TOwnProps extends SearchPersist
|
|
|
65
67
|
*
|
|
66
68
|
* @param WrappedComponent The component to wrap
|
|
67
69
|
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
70
|
+
* @param disableLocalSearch By default, `doSearch` is only called at initialization and when `queryAll` is `true`, and searching happens locally (see ManageTable).
|
|
71
|
+
* If `disableLocalSearch` is `true` then the legacy logic is used, where `doSearch` is always called for all searches.
|
|
68
72
|
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
69
73
|
*/
|
|
70
|
-
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps<TSearchType>, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps<TSearchType>>>;
|
|
74
|
+
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps<TSearchType>, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps>, key: string, disableLocalSearch?: boolean): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps<TSearchType>>>;
|
|
@@ -48,7 +48,7 @@ var lodash_1 = require("lodash");
|
|
|
48
48
|
var react_1 = __importStar(require("react"));
|
|
49
49
|
var react_redux_1 = require("react-redux");
|
|
50
50
|
var actions_1 = require("../../redux/actions");
|
|
51
|
-
function configureSearchPersistorComponent(WrappedComponent) {
|
|
51
|
+
function configureSearchPersistorComponent(WrappedComponent, disableLocalSearch) {
|
|
52
52
|
return /** @class */ (function (_super) {
|
|
53
53
|
__extends(SearchPersistorComponent, _super);
|
|
54
54
|
function SearchPersistorComponent(props) {
|
|
@@ -105,8 +105,8 @@ function configureSearchPersistorComponent(WrappedComponent) {
|
|
|
105
105
|
pageSize: search.pageSize,
|
|
106
106
|
pageByTab: search.pageByTab
|
|
107
107
|
}),
|
|
108
|
-
// do not trigger a re-load unless queryAll is true
|
|
109
|
-
search.queryAll ? _this.doSearch : undefined);
|
|
108
|
+
// do not trigger a re-load unless queryAll is true, or local search is disabled
|
|
109
|
+
disableLocalSearch || search.queryAll ? _this.doSearch : undefined);
|
|
110
110
|
};
|
|
111
111
|
_this.setSelectedTab = function (selectedTab) {
|
|
112
112
|
var _a, _b;
|
|
@@ -126,16 +126,20 @@ function configureSearchPersistorComponent(WrappedComponent) {
|
|
|
126
126
|
};
|
|
127
127
|
_this.handleKeywordsKeyDown = function (event) {
|
|
128
128
|
var _a;
|
|
129
|
-
if (event.key === 'Enter' && ((_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.queryAll)) {
|
|
129
|
+
if (event.key === 'Enter' && (disableLocalSearch || ((_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.queryAll))) {
|
|
130
130
|
_this.handleSearchClick();
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
_this.setQueryAll = function (event) {
|
|
134
|
+
var _a;
|
|
134
135
|
var queryAll = event.target.checked;
|
|
135
136
|
_this.updateAndPersistSearch({
|
|
136
137
|
queryAll: queryAll,
|
|
137
|
-
requiredMessage
|
|
138
|
-
|
|
138
|
+
// clear the `requiredMessage` when turning off `queryAll` and local search is enabled
|
|
139
|
+
requiredMessage: !queryAll && !disableLocalSearch ? null : (_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.requiredMessage
|
|
140
|
+
},
|
|
141
|
+
// only automatically trigger re-load when local search is enabled
|
|
142
|
+
!disableLocalSearch ? _this.doSearch : undefined);
|
|
139
143
|
};
|
|
140
144
|
_this.setSortingRules = function (newSortingRules) {
|
|
141
145
|
_this.updateAndPersistSearch({
|
|
@@ -213,8 +217,8 @@ var configureMapDispatchToProps = function (key) { return function (dispatch) {
|
|
|
213
217
|
};
|
|
214
218
|
}; };
|
|
215
219
|
exports.configureMapDispatchToProps = configureMapDispatchToProps;
|
|
216
|
-
function searchPersistorComponent(WrappedComponent, key) {
|
|
217
|
-
var SearchPersistorComponent = configureSearchPersistorComponent(WrappedComponent);
|
|
220
|
+
function searchPersistorComponent(WrappedComponent, key, disableLocalSearch) {
|
|
221
|
+
var SearchPersistorComponent = configureSearchPersistorComponent(WrappedComponent, disableLocalSearch);
|
|
218
222
|
var mapStateToProps = exports.configureMapStateToProps(key);
|
|
219
223
|
var mapDispatchToProps = exports.configureMapDispatchToProps(key);
|
|
220
224
|
// @ts-ignore: could not match inferred type from the `connect` HOC
|
|
@@ -9,6 +9,8 @@ export interface SearchControlsProps extends Search, SearchControlsMethods {
|
|
|
9
9
|
handleDateChange?: (dateString: string, date?: Date) => void;
|
|
10
10
|
canReadAnyGlobally?: boolean;
|
|
11
11
|
canReadSome?: boolean;
|
|
12
|
+
/** force Search button to be visible. otherwise only shows when `queryAll` is `true`. */
|
|
13
|
+
showSearchButton?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export declare const SearchControls: FunctionComponent<SearchControlsProps>;
|
|
14
16
|
export {};
|
|
@@ -12,7 +12,7 @@ var react_bootstrap_1 = require("react-bootstrap");
|
|
|
12
12
|
var AlertWithIcon_1 = require("./AlertWithIcon");
|
|
13
13
|
var DateField_1 = require("./Forms/DateField");
|
|
14
14
|
var SearchControls = function (_a) {
|
|
15
|
-
var keywords = _a.keywords, invalidKeywords = _a.invalidKeywords, dateString = _a.dateString, queryAll = _a.queryAll, requiredMessage = _a.requiredMessage, setKeywords = _a.setKeywords, handleKeywordsKeyDown = _a.handleKeywordsKeyDown, handleSearchClick = _a.handleSearchClick, resetSearch = _a.resetSearch, setQueryAll = _a.setQueryAll, keywordPlaceholder = _a.keywordPlaceholder, handleDateChange = _a.handleDateChange, queryAllText = _a.queryAllText, canReadAnyGlobally = _a.canReadAnyGlobally, canReadSome = _a.canReadSome;
|
|
15
|
+
var keywords = _a.keywords, invalidKeywords = _a.invalidKeywords, dateString = _a.dateString, queryAll = _a.queryAll, requiredMessage = _a.requiredMessage, setKeywords = _a.setKeywords, handleKeywordsKeyDown = _a.handleKeywordsKeyDown, handleSearchClick = _a.handleSearchClick, resetSearch = _a.resetSearch, setQueryAll = _a.setQueryAll, keywordPlaceholder = _a.keywordPlaceholder, handleDateChange = _a.handleDateChange, queryAllText = _a.queryAllText, canReadAnyGlobally = _a.canReadAnyGlobally, canReadSome = _a.canReadSome, showSearchButton = _a.showSearchButton;
|
|
16
16
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
17
17
|
!!requiredMessage && (react_1.default.createElement(AlertWithIcon_1.AlertWithIcon, { variant: "danger", className: "mb0", id: "requiredMessageAlert" },
|
|
18
18
|
react_1.default.createElement("p", null, requiredMessage))),
|
|
@@ -25,7 +25,7 @@ var SearchControls = function (_a) {
|
|
|
25
25
|
react_1.default.createElement(DateField_1.DateField, { id: "date", onChange: handleDateChange, label: "Date", "aria-label": "Active date", className: "fl-ns mw5-ns mr3-ns mb3 mb0-ns w-100-lt-xs date-align", value: dateString }))),
|
|
26
26
|
react_1.default.createElement("div", { className: "fl-ns mt3-ns pt3-ns w-100-lt-xs" },
|
|
27
27
|
canReadAnyGlobally && !!setQueryAll && (react_1.default.createElement(react_bootstrap_1.FormCheck, { name: "queryAll", id: "queryAll", checked: queryAll, disabled: canReadAnyGlobally && !canReadSome, onChange: setQueryAll, className: "fl-ns f6 mr2-ns mb3 mt2 w-100-lt-xs", label: react_1.default.createElement("span", { className: "b black" }, queryAllText || 'Search All') })),
|
|
28
|
-
canReadAnyGlobally && queryAll && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: (!keywords || keywords.length < 3 || !!invalidKeywords) && !dateString },
|
|
28
|
+
(showSearchButton || (canReadAnyGlobally && queryAll)) && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: (!keywords || keywords.length < 3 || !!invalidKeywords) && !dateString },
|
|
29
29
|
react_1.default.createElement(Search_1.default, null),
|
|
30
30
|
"Search")),
|
|
31
31
|
react_1.default.createElement(Button_1.default, { className: "btn-text color-pink fr-ns mb3 w-100-lt-xs", onClick: resetSearch },
|
|
@@ -27,7 +27,7 @@ var core_1 = require("@material-ui/core");
|
|
|
27
27
|
var Delete_1 = __importDefault(require("@material-ui/icons/Delete"));
|
|
28
28
|
var react_1 = __importStar(require("react"));
|
|
29
29
|
var react_bootstrap_1 = require("react-bootstrap");
|
|
30
|
-
var
|
|
30
|
+
var useCurrentUserId_1 = require("../../hooks/useCurrentUserId");
|
|
31
31
|
var userRole_1 = require("../../utils/userRole");
|
|
32
32
|
var IconExternalUser_1 = require("../Icons/IconExternalUser");
|
|
33
33
|
var Inline_1 = require("../RefreshIndicator/Inline");
|
|
@@ -36,12 +36,7 @@ var Select_1 = require("./Select");
|
|
|
36
36
|
var RoleCell = function (_a) {
|
|
37
37
|
var user = _a.user, requiredRoleCount = _a.requiredRoleCount;
|
|
38
38
|
var _b = react_1.useContext(Context_1.UserRolesContext), isUpdateDisabled = _b.isUpdateDisabled, isDeleteDisabled = _b.isDeleteDisabled, canModify = _b.canModify, canDeleteSelf = _b.canDeleteSelf, allowMultipleRoles = _b.allowMultipleRoles, roles = _b.roles, requiredRole = _b.requiredRole, textForRole = _b.textForRole, userRoleToUpdate = _b.userRoleToUpdate, isUpdating = _b.isUpdating, updateUserRole = _b.updateUserRole, userRoleToRemove = _b.userRoleToRemove, isRemoving = _b.isRemoving, removeUserRole = _b.removeUserRole;
|
|
39
|
-
var currentUserId =
|
|
40
|
-
if (!state.models.user || !state.models.user.userInfo) {
|
|
41
|
-
throw new Error('Current user id is not stored in redux');
|
|
42
|
-
}
|
|
43
|
-
return state.models.user.userInfo.id;
|
|
44
|
-
});
|
|
39
|
+
var currentUserId = useCurrentUserId_1.useCurrentUserId();
|
|
45
40
|
return (react_1.default.createElement("ul", { className: "mb0 list pa0 tr" }, user.roles.sort(userRole_1.sortByRole(roles)).map(function (userRole) {
|
|
46
41
|
var roleText = userRole_1.getRoleText(textForRole)(userRole);
|
|
47
42
|
var isUserRoleExternal = userRole_1.isExternal(userRole);
|
|
@@ -107,5 +107,5 @@ export declare class UserRoles extends Component<UserRolesProps, UserRolesState>
|
|
|
107
107
|
render(): JSX.Element;
|
|
108
108
|
}
|
|
109
109
|
export declare const mapStateToProps: (state: BaseReduxState, ownProps: UserRolesOwnProps) => UserRolesReduxProps;
|
|
110
|
-
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "ref" | "queryParams" | "modelName" | "externalProviders" | "model" | "key" | "readOnly" | "guid" | "entityName" | "load" | "pathParams" | "modelStatus" | "disableAutoLoad" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
110
|
+
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "ref" | "queryParams" | "modelName" | "externalProviders" | "model" | "key" | "readOnly" | "guid" | "entityName" | "load" | "pathParams" | "modelStatus" | "disableAutoLoad" | "disableAutoLoadOnParamsChange" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
111
111
|
export default _default;
|
|
@@ -5,3 +5,5 @@ export declare const setShardConfig: (value: Configuration) => void;
|
|
|
5
5
|
export declare const getShardConfig: () => Configuration;
|
|
6
6
|
export declare const setEndpointMappings: (value: EndpointMappings) => void;
|
|
7
7
|
export declare const getEndpointMappings: () => EndpointMappings;
|
|
8
|
+
export declare const setUserId: (value: string | null) => void;
|
|
9
|
+
export declare const getUserId: () => string | null;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEndpointMappings = exports.setEndpointMappings = exports.getShardConfig = exports.setShardConfig = exports.getAppConfig = exports.setAppConfig = void 0;
|
|
3
|
+
exports.getUserId = exports.setUserId = exports.getEndpointMappings = exports.setEndpointMappings = exports.getShardConfig = exports.setShardConfig = exports.getAppConfig = exports.setAppConfig = void 0;
|
|
4
4
|
var appConfig;
|
|
5
5
|
var shardConfig;
|
|
6
6
|
var endpointMappings;
|
|
7
|
+
var userId;
|
|
7
8
|
var setAppConfig = function (value) {
|
|
8
9
|
appConfig = value;
|
|
9
10
|
};
|
|
@@ -37,3 +38,11 @@ var getEndpointMappings = function () {
|
|
|
37
38
|
return endpointMappings;
|
|
38
39
|
};
|
|
39
40
|
exports.getEndpointMappings = getEndpointMappings;
|
|
41
|
+
var setUserId = function (value) {
|
|
42
|
+
userId = value;
|
|
43
|
+
};
|
|
44
|
+
exports.setUserId = setUserId;
|
|
45
|
+
var getUserId = function () {
|
|
46
|
+
return userId;
|
|
47
|
+
};
|
|
48
|
+
exports.getUserId = getUserId;
|
|
@@ -5,7 +5,7 @@ var react_1 = require("react");
|
|
|
5
5
|
var collection_1 = require("../utils/collection");
|
|
6
6
|
var useCollectionConfiguration_1 = require("./useCollectionConfiguration");
|
|
7
7
|
function useCollection(props) {
|
|
8
|
-
var modelName = props.modelName;
|
|
8
|
+
var modelName = props.modelName, disableAutoLoadOnParamsChange = props.disableAutoLoadOnParamsChange;
|
|
9
9
|
// state, route, and redux
|
|
10
10
|
var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionFromState);
|
|
11
11
|
var previousModelName = config.previousModelName, guid = config.guid, model = config.model, pathParams = config.pathParams, previousPathParams = config.previousPathParams, queryParams = config.queryParams, previousQueryParams = config.previousQueryParams, fetchingId = config.fetchingId, modelStatus = config.modelStatus, previousModelStatus = config.previousModelStatus, isInitialized = config.isInitialized, setIsInitialized = config.setIsInitialized, methodConfig = config.methodConfig, modelArray = config.modelArray;
|
|
@@ -33,10 +33,21 @@ function useCollection(props) {
|
|
|
33
33
|
setIsInitialized(true);
|
|
34
34
|
}
|
|
35
35
|
}, [isInitialized, load, methodConfig, model, setIsInitialized]);
|
|
36
|
-
// re-load if `pathParams` or `queryParams` change
|
|
36
|
+
// re-load if `pathParams` or `queryParams` change, unless `disableAutoLoadOnParamsChange` is true
|
|
37
37
|
react_1.useEffect(function () {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
39
|
+
collection_1.handleCollectionParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
|
|
40
|
+
}
|
|
41
|
+
}, [
|
|
42
|
+
disableAutoLoadOnParamsChange,
|
|
43
|
+
load,
|
|
44
|
+
modelName,
|
|
45
|
+
pathParams,
|
|
46
|
+
previousModelName,
|
|
47
|
+
previousPathParams,
|
|
48
|
+
previousQueryParams,
|
|
49
|
+
queryParams
|
|
50
|
+
]);
|
|
40
51
|
// cleanup on unmount
|
|
41
52
|
react_1.useEffect(function () {
|
|
42
53
|
return function cleanup() {
|
|
@@ -5,7 +5,7 @@ var react_1 = require("react");
|
|
|
5
5
|
var collection_1 = require("../utils/collection");
|
|
6
6
|
var useCollectionConfiguration_1 = require("./useCollectionConfiguration");
|
|
7
7
|
function useCollectionItem(props) {
|
|
8
|
-
var modelName = props.modelName;
|
|
8
|
+
var modelName = props.modelName, disableAutoLoadOnParamsChange = props.disableAutoLoadOnParamsChange;
|
|
9
9
|
// state, route, and redux
|
|
10
10
|
var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionItemFromState);
|
|
11
11
|
var previousModelName = config.previousModelName, guid = config.guid, model = config.model, pathParams = config.pathParams, previousPathParams = config.previousPathParams, queryParams = config.queryParams, previousQueryParams = config.previousQueryParams, modelStatus = config.modelStatus, previousModelStatus = config.previousModelStatus, isInitialized = config.isInitialized, setIsInitialized = config.setIsInitialized, methodConfig = config.methodConfig, modelMinusRelations = config.modelMinusRelations;
|
|
@@ -34,10 +34,21 @@ function useCollectionItem(props) {
|
|
|
34
34
|
setIsInitialized(true);
|
|
35
35
|
}
|
|
36
36
|
}, [isInitialized, load, methodConfig, model, setIsInitialized]);
|
|
37
|
-
// re-load if `pathParams` or `queryParams` change
|
|
37
|
+
// re-load if `pathParams` or `queryParams` change, unless `disableAutoLoadOnParamsChange` is true
|
|
38
38
|
react_1.useEffect(function () {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
40
|
+
collection_1.handleCollectionItemParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
disableAutoLoadOnParamsChange,
|
|
44
|
+
load,
|
|
45
|
+
modelName,
|
|
46
|
+
pathParams,
|
|
47
|
+
previousModelName,
|
|
48
|
+
previousPathParams,
|
|
49
|
+
previousQueryParams,
|
|
50
|
+
queryParams
|
|
51
|
+
]);
|
|
41
52
|
return {
|
|
42
53
|
guid: guid,
|
|
43
54
|
model: model,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCurrentUserId: () => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCurrentUserId = void 0;
|
|
4
|
+
var react_redux_1 = require("react-redux");
|
|
5
|
+
var useCurrentUserId = function () {
|
|
6
|
+
return react_redux_1.useSelector(function (state) {
|
|
7
|
+
if (!state.models.user || !state.models.user.userInfo) {
|
|
8
|
+
throw new Error('Current user id is not stored in redux');
|
|
9
|
+
}
|
|
10
|
+
return state.models.user.userInfo.id;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.useCurrentUserId = useCurrentUserId;
|
|
@@ -48,39 +48,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
var Sentry = __importStar(require("@sentry/react"));
|
|
50
50
|
var effects_1 = require("redux-saga/effects");
|
|
51
|
-
var
|
|
51
|
+
var constants_1 = require("../../constants");
|
|
52
|
+
var analytics_1 = require("../../utils/analytics");
|
|
52
53
|
var actions_1 = require("../actions");
|
|
53
54
|
function sentrySaga() {
|
|
54
55
|
var appConfig, sentryDsn, _loop_1;
|
|
55
56
|
return __generator(this, function (_a) {
|
|
56
57
|
switch (_a.label) {
|
|
57
58
|
case 0:
|
|
58
|
-
appConfig =
|
|
59
|
+
appConfig = constants_1.getAppConfig();
|
|
59
60
|
sentryDsn = appConfig.SENTRY_DSN;
|
|
60
61
|
if (!sentryDsn) {
|
|
61
62
|
return [2 /*return*/];
|
|
62
63
|
}
|
|
63
64
|
_loop_1 = function () {
|
|
64
|
-
var userInfoResponse, userInfo;
|
|
65
|
+
var userInfoResponse, userInfo, userId;
|
|
65
66
|
return __generator(this, function (_a) {
|
|
66
67
|
switch (_a.label) {
|
|
67
68
|
case 0: return [4 /*yield*/, effects_1.take(function (action) { return action.type === actions_1.NET_ACTION.FETCH_RESULT_RECEIVED && action.modelName === 'user.userInfo'; })];
|
|
68
69
|
case 1:
|
|
69
70
|
userInfoResponse = _a.sent();
|
|
70
71
|
userInfo = userInfoResponse.data;
|
|
72
|
+
userId = userInfo.id;
|
|
73
|
+
constants_1.setUserId(userId);
|
|
71
74
|
Sentry.configureScope(function (scope) {
|
|
72
75
|
scope.setUser({
|
|
73
|
-
id:
|
|
76
|
+
id: userId,
|
|
74
77
|
username: userInfo.userName,
|
|
75
78
|
email: userInfo.email
|
|
76
79
|
});
|
|
77
80
|
});
|
|
81
|
+
analytics_1.setGoogleAnalyticsUserId(userId);
|
|
78
82
|
return [4 /*yield*/, effects_1.take(actions_1.AUTH_ACTION.LOG_OUT_REQUESTED)];
|
|
79
83
|
case 2:
|
|
80
84
|
_a.sent();
|
|
85
|
+
constants_1.setUserId(null);
|
|
81
86
|
Sentry.configureScope(function (scope) {
|
|
82
87
|
scope.setUser({});
|
|
83
88
|
});
|
|
89
|
+
analytics_1.setGoogleAnalyticsUserId(null);
|
|
84
90
|
return [4 /*yield*/, effects_1.take(actions_1.AUTH_ACTION.GET_TOKEN_SUCCEEDED)];
|
|
85
91
|
case 3:
|
|
86
92
|
_a.sent();
|
package/lib/startup.js
CHANGED
|
@@ -62,7 +62,7 @@ var startup = function (appConfig, endpointMappings) {
|
|
|
62
62
|
var locationListener = function (location, action) {
|
|
63
63
|
// send pageview to Google Analytics
|
|
64
64
|
if (appConfig.GOOGLE_ANALYTICS_TRACKING_ID) {
|
|
65
|
-
react_ga4_1.default.send({ hitType: 'pageview', page: location.pathname });
|
|
65
|
+
react_ga4_1.default.send({ hitType: 'pageview', page: location.pathname, user_id: configuration_1.getUserId() });
|
|
66
66
|
}
|
|
67
67
|
// send pageview to Application Insights
|
|
68
68
|
if (appInsights) {
|
|
@@ -14,8 +14,10 @@ export interface CollectionCommonProps {
|
|
|
14
14
|
pathParams: string[];
|
|
15
15
|
/** Custom queryParams for use in all requests. */
|
|
16
16
|
queryParams?: Dictionary<string>;
|
|
17
|
-
/** Whether
|
|
17
|
+
/** Whether to disable triggering `load()` after mounting. Default is `false`. */
|
|
18
18
|
disableAutoLoad?: boolean;
|
|
19
|
+
/** Whether to disable triggering `load()` when `pathParams` or `queryParams` change. Default is `false`. */
|
|
20
|
+
disableAutoLoadOnParamsChange?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/** See `CollectionSelectorMethod` */
|
|
21
23
|
export interface CollectionSelectorMethodParams {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GoogleAnalyticsEvent } from '../types/Analytics';
|
|
2
|
+
/**
|
|
3
|
+
* Set the User ID for Google Analytics with a given value
|
|
4
|
+
* @param userId
|
|
5
|
+
*/
|
|
6
|
+
export declare const setGoogleAnalyticsUserId: (userId: string | null) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Send an event to Google Analytics
|
|
9
|
+
* @param event
|
|
10
|
+
*/
|
|
11
|
+
export declare const trackGoogleAnalyticsEvent: (event: GoogleAnalyticsEvent) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.trackGoogleAnalyticsEvent = exports.setGoogleAnalyticsUserId = void 0;
|
|
7
|
+
var react_ga4_1 = __importDefault(require("react-ga4"));
|
|
8
|
+
var constants_1 = require("../constants");
|
|
9
|
+
/**
|
|
10
|
+
* Set the User ID for Google Analytics with a given value
|
|
11
|
+
* @param userId
|
|
12
|
+
*/
|
|
13
|
+
var setGoogleAnalyticsUserId = function (userId) {
|
|
14
|
+
var appConfig = constants_1.getAppConfig();
|
|
15
|
+
if (appConfig.GOOGLE_ANALYTICS_TRACKING_ID === undefined)
|
|
16
|
+
return;
|
|
17
|
+
react_ga4_1.default.gtag('config', appConfig.GOOGLE_ANALYTICS_TRACKING_ID, {
|
|
18
|
+
user_id: userId
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.setGoogleAnalyticsUserId = setGoogleAnalyticsUserId;
|
|
22
|
+
/**
|
|
23
|
+
* Send an event to Google Analytics
|
|
24
|
+
* @param event
|
|
25
|
+
*/
|
|
26
|
+
var trackGoogleAnalyticsEvent = function (event) {
|
|
27
|
+
var userId = event.userId, eventName = event.eventName, category = event.category, action = event.action, label = event.label;
|
|
28
|
+
var appConfig = constants_1.getAppConfig();
|
|
29
|
+
if (appConfig.GOOGLE_ANALYTICS_TRACKING_ID === undefined)
|
|
30
|
+
return;
|
|
31
|
+
react_ga4_1.default.event(eventName, {
|
|
32
|
+
event_category: category,
|
|
33
|
+
action: action,
|
|
34
|
+
event_label: label,
|
|
35
|
+
user_id: userId
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.trackGoogleAnalyticsEvent = trackGoogleAnalyticsEvent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "studiokit-scaffolding-js",
|
|
3
|
-
"version": "5.1.2",
|
|
3
|
+
"version": "5.1.3-next.1.2",
|
|
4
4
|
"description": "Common scaffolding for Studio apps at Purdue",
|
|
5
5
|
"repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
|
|
6
6
|
"license": "MIT",
|