Skip to content

Commit

Permalink
Merge branch 'main' into update-bundling-workflow-and-add-task-lockin…
Browse files Browse the repository at this point in the history
…g-for-bundles
  • Loading branch information
CollinBeczak committed Feb 18, 2025
2 parents 90b52b3 + ec41187 commit 2109e23
Show file tree
Hide file tree
Showing 142 changed files with 852 additions and 618 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"tailwindcss-transforms": "^2.2.0",
"tailwindcss-transition": "^1.0.5",
"tailwindcss-visuallyhidden": "^1.0.2",
"vite": "^5.4.8",
"vite": "^5.4.12",
"vitest": "^2.1.2"
},
"resolutions": {
Expand Down
3 changes: 1 addition & 2 deletions src/components/AchievementBadge/AchievementBadge.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from "classnames";
import _isFinite from "lodash/isFinite";
import _merge from "lodash/merge";
import _reverse from "lodash/reverse";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -367,7 +366,7 @@ const AchievementBadge = (props) => {

return (
<div className="mr-relative">
{_isFinite(props.stackDepth) && <BadgeStack depth={props.stackDepth} />}
{Number.isFinite(props.stackDepth) && <BadgeStack depth={props.stackDepth} />}
<div className={classNames("mr-flex mr-flex-col mr-items-center", props.className)}>
<div className="mr-relative">
{badgeImage ? (
Expand Down
5 changes: 2 additions & 3 deletions src/components/ActivityListing/ActivityDescription.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from "classnames";
import _isFinite from "lodash/isFinite";
import PropTypes from "prop-types";
import { Fragment } from "react";
import { FormattedMessage } from "react-intl";
Expand Down Expand Up @@ -63,7 +62,7 @@ export const ActivityDescription = (props) => {
</div>
)}
<div>
{_isFinite(props.entry.count) && (
{Number.isFinite(props.entry.count) && (
<span className="mr-badge mr-mr-2 mr-mt-1">{props.entry.count}</span>
)}
<span>
Expand All @@ -73,7 +72,7 @@ export const ActivityDescription = (props) => {
<FormattedMessage {...messagesByType[props.entry.typeId]} />
</Link>{" "}
{props.entry.action === ActivityActionType.taskStatusSet &&
_isFinite(props.entry.status) && (
Number.isFinite(props.entry.status) && (
<Fragment>
<FormattedMessage {...messages.statusTo} />{" "}
<FormattedMessage {...messagesByStatus[props.entry.status]} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parseISO } from "date-fns";
import _compact from "lodash/compact";
import _groupBy from "lodash/groupBy";
import _isFinite from "lodash/isFinite";
import _map from "lodash/map";
import _reverse from "lodash/reverse";
import _sortBy from "lodash/sortBy";
Expand Down Expand Up @@ -69,7 +68,7 @@ export class ChallengeActivityTimeline extends Component {
);

// If a limit on timeline entries has been given, honor it.
if (_isFinite(this.props.maxEntries)) {
if (Number.isFinite(this.props.maxEntries)) {
timelineItems = _take(timelineItems, this.props.maxEntries);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { parseISO } from "date-fns";
import _compact from "lodash/compact";
import _flatten from "lodash/flatten";
import _groupBy from "lodash/groupBy";
import _indexOf from "lodash/indexOf";
import _isArray from "lodash/isArray";
import _isEmpty from "lodash/isEmpty";
import _isEqual from "lodash/isEqual";
import _isFinite from "lodash/isFinite";
import _keys from "lodash/keys";
import _map from "lodash/map";
import _pickBy from "lodash/pickBy";
Expand All @@ -29,7 +26,7 @@ const WithChallengeMetrics = function (WrappedComponent, applyFilters = false) {
};

isFiltering(includesFiltersArray) {
return _indexOf(_values(includesFiltersArray), false) !== -1;
return _values(includesFiltersArray).indexOf(false) !== -1;
}

updateMetrics(props) {
Expand Down Expand Up @@ -132,8 +129,8 @@ const WithChallengeMetrics = function (WrappedComponent, applyFilters = false) {
(taskMetrics?.total ?? 0) > 0
) {
tasksAvailable = _sumBy(this.props.challenges, "actions.available");
if (_isFinite(tasksAvailable)) {
let allActivity = _isArray(this.props.activity)
if (Number.isFinite(tasksAvailable)) {
let allActivity = Array.isArray(this.props.activity)
? this.props.activity
: _compact(_flatten(_map(this.props.challenges, "activity")));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _each from "lodash/each";
import _filter from "lodash/filter";
import _isArray from "lodash/isArray";
import _uniqBy from "lodash/uniqBy";
import { Component } from "react";

Expand All @@ -19,7 +18,7 @@ const WithChallengeResultParents = function (WrappedComponent) {
}

// If there are pre-filtered projects, use those
const allProjects = _isArray(this.props.filteredProjects)
const allProjects = Array.isArray(this.props.filteredProjects)
? this.props.filteredProjects
: this.props.projects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _each from "lodash/each";
import _fromPairs from "lodash/fromPairs";
import _isArray from "lodash/isArray";
import _isEmpty from "lodash/isEmpty";
import _isFinite from "lodash/isFinite";
import _isObject from "lodash/isObject";
import _map from "lodash/map";
import _values from "lodash/values";
Expand All @@ -25,14 +23,16 @@ export default function (WrappedComponent) {
updateTotals = (actions, totalTasks, taskMetrics) => {
_each(actions, (value, label) => {
if (label === "avgTimeSpent") {
taskMetrics.totalTimeSpent = _isFinite(taskMetrics.totalTimeSpent)
taskMetrics.totalTimeSpent = Number.isFinite(taskMetrics.totalTimeSpent)
? taskMetrics.totalTimeSpent + value * actions.tasksWithTime
: value * actions.tasksWithTime;
} else {
taskMetrics[label] = _isFinite(taskMetrics[label]) ? taskMetrics[label] + value : value;
taskMetrics[label] = Number.isFinite(taskMetrics[label])
? taskMetrics[label] + value
: value;

const percentage = ((1.0 * value) / totalTasks) * 100.0;
taskMetrics.percentages[label] = _isFinite(taskMetrics.percentages[label])
taskMetrics.percentages[label] = Number.isFinite(taskMetrics.percentages[label])
? taskMetrics.percentages[label] + percentage
: percentage;
}
Expand All @@ -41,7 +41,7 @@ export default function (WrappedComponent) {

render() {
const challenges =
_isArray(this.props.challenges) && this.props.challenges.length > 0
Array.isArray(this.props.challenges) && this.props.challenges.length > 0
? this.props.challenges
: _isObject(this.props.challenge)
? [this.props.challenge]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _isFinite from "lodash/isFinite";
import _omit from "lodash/omit";
import { denormalize } from "normalizr";
import { Component } from "react";
Expand Down Expand Up @@ -35,7 +34,7 @@ const WithCurrentChallenge = function (WrappedComponent) {
loadChallenge = () => {
const challengeId = this.currentChallengeId();

if (_isFinite(challengeId)) {
if (Number.isFinite(challengeId)) {
this.setState({ loadingChallenge: true });

// Start by fetching the challenge. Then fetch follow-up data.
Expand Down Expand Up @@ -74,7 +73,7 @@ const WithCurrentChallenge = function (WrappedComponent) {
let owner = null;
let clusteredTasks = null;

if (_isFinite(challengeId)) {
if (Number.isFinite(challengeId)) {
challenge = AsManageableChallenge(
denormalize(
this.props.entities?.challenges?.[challengeId],
Expand Down Expand Up @@ -116,7 +115,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
fetchChallenge: (challengeId) => {
return dispatch(fetchChallenge(challengeId)).then((normalizedResults) => {
if (
!_isFinite(normalizedResults.result) ||
!Number.isFinite(normalizedResults.result) ||
normalizedResults?.entities?.challenges?.[normalizedResults.result]?.deleted
) {
dispatch(addError(AppErrors.challenge.doesNotExist));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _each from "lodash/each";
import _filter from "lodash/filter";
import _find from "lodash/find";
import _isFinite from "lodash/isFinite";
import _isObject from "lodash/isObject";
import _map from "lodash/map";
import _omit from "lodash/omit";
Expand Down Expand Up @@ -64,12 +63,12 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
// project and the defaultToOnlyProject option is true, then go ahead and
// use that project.
if (
!_isFinite(projectId) &&
!Number.isFinite(projectId) &&
options.defaultToOnlyProject &&
(props.projects?.length ?? 0) === 1
) {
projectId = props.projects[0].id;
} else if (_isFinite(projectId) && options.restrictToGivenProjects) {
} else if (Number.isFinite(projectId) && options.restrictToGivenProjects) {
if (!_find(props.projects, { id: projectId })) {
projectId = null;
}
Expand Down Expand Up @@ -98,7 +97,7 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
let projectId = this.currentProjectId(props);

if (
_isFinite(this.routedProjectId(props)) &&
Number.isFinite(this.routedProjectId(props)) &&
projectId === null &&
!this.state.loadingProject
) {
Expand All @@ -111,7 +110,7 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
projectId = this.routedProjectId(props);
}

if (_isFinite(projectId)) {
if (Number.isFinite(projectId)) {
this.setState({
loadingProject: true,
loadingChallenges: options.includeChallenges,
Expand All @@ -127,7 +126,7 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
if (!manager.canManage(project)) {
// If we have a challenge id too, route to the browse url for the challenge
const challengeId = this.routedChallengeId(this.props);
if (_isFinite(challengeId)) {
if (Number.isFinite(challengeId)) {
props.history.replace(`/browse/challenges/${challengeId}`);
} else {
this.props.notManagerError();
Expand Down Expand Up @@ -219,17 +218,19 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
}

const nextProjectId = this.currentProjectId(this.props);
if (_isFinite(nextProjectId) && nextProjectId !== this.currentProjectId(prevProps)) {
if (Number.isFinite(nextProjectId) && nextProjectId !== this.currentProjectId(prevProps)) {
this.loadProject(this.props);
}
}

render() {
const projectId = this.currentProjectId(this.props);
const project = !_isFinite(projectId) ? null : this.props.entities?.projects?.[projectId];
const project = !Number.isFinite(projectId)
? null
: this.props.entities?.projects?.[projectId];
let challenges = this.props.challenges; // pass through challenges by default

if (options.includeChallenges && _isFinite(projectId)) {
if (options.includeChallenges && Number.isFinite(projectId)) {
challenges = _map(this.challengeProjects(projectId, this.props), (challenge) =>
denormalize(challenge, challengeDenormalizationSchema(), this.props.entities),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from "classnames";
import _isFinite from "lodash/isFinite";
import _isObject from "lodash/isObject";
import PropTypes from "prop-types";
import { Component, Fragment, createRef } from "react";
Expand Down Expand Up @@ -32,13 +31,13 @@ export class ChallengeCard extends Component {
if (_isObject(this.props.challenge.parent)) {
parent = this.props.challenge.parent;
} else if (
_isFinite(this.props.challenge.parent) &&
Number.isFinite(this.props.challenge.parent) &&
this.props.challenge.parent === this.props.project?.id
) {
parent = this.props.project;
}

const hasActions = _isFinite(this.props.challenge?.actions?.total);
const hasActions = Number.isFinite(this.props.challenge?.actions?.total);

const ChallengeIcon = AsManageableChallenge(this.props.challenge).isComplete()
? CompleteIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from "classnames";
import _isFinite from "lodash/isFinite";
import _isObject from "lodash/isObject";
import _merge from "lodash/merge";
import PropTypes from "prop-types";
Expand Down Expand Up @@ -82,7 +81,7 @@ export default class ChallengeControls extends Component {
if (_isObject(this.props.challenge.parent)) {
parent = this.props.challenge.parent;
} else if (
_isFinite(this.props.challenge.parent) &&
Number.isFinite(this.props.challenge.parent) &&
this.props.challenge.parent === this.props.project?.id
) {
parent = this.props.project;
Expand Down
5 changes: 2 additions & 3 deletions src/components/AdminPane/Manage/EditProject/EditProject.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Form from "@rjsf/core";
import classNames from "classnames";
import _isFinite from "lodash/isFinite";
import _isObject from "lodash/isObject";
import _merge from "lodash/merge";
import _snakeCase from "lodash/snakeCase";
Expand Down Expand Up @@ -42,7 +41,7 @@ export class EditProject extends Component {

// For new projects, generate a project name based on the display name.
// It cannot start with "home_".
if (!_isFinite(formData.id)) {
if (!Number.isFinite(formData.id)) {
formData.name = _snakeCase(formData.displayName).replace(/^home_/, "project_");
}

Expand All @@ -65,7 +64,7 @@ export class EditProject extends Component {
render() {
// If a project id was specified, but there is no project, don't render
// the form.
if (_isFinite(this.props.routedProjectId) && !this.props.project) {
if (Number.isFinite(this.props.routedProjectId) && !this.props.project) {
return (
<h1>
<FormattedMessage {...messages.projectUnavailable} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import _difference from "lodash/difference";
import _filter from "lodash/filter";
import _isEmpty from "lodash/isEmpty";
import _isEqual from "lodash/isEqual";
import _isFinite from "lodash/isFinite";
import _isNumber from "lodash/isNumber";
import _isObject from "lodash/isObject";
import _isString from "lodash/isString";
import _isUndefined from "lodash/isUndefined";
import _map from "lodash/map";
import _merge from "lodash/merge";
import _omit from "lodash/omit";
Expand Down Expand Up @@ -426,11 +424,11 @@ export class EditChallenge extends Component {
// doesn't use the layer index string identifiers, then we convert the
// numeric id to an appropriate string identifier here (assuming it is
// specifying a default layer at all).
if (_isUndefined(this.state.formData.defaultBasemap)) {
if (this.state.formData.defaultBasemap === undefined) {
if (!_isEmpty(challengeData.defaultBasemapId)) {
// layer index string
challengeData.defaultBasemap = challengeData.defaultBasemapId;
} else if (_isFinite(challengeData.defaultBasemap)) {
} else if (Number.isFinite(challengeData.defaultBasemap)) {
// numeric identifier
// Convert to corresponding layer-index string identifier for form if
// possible. Otherwise just go with string representation of numerical
Expand Down Expand Up @@ -461,7 +459,7 @@ export class EditChallenge extends Component {
);
}

if (_isUndefined(this.state.formData.presets)) {
if (this.state.formData.presets === undefined) {
challengeData = preparePresetsForForm(challengeData);
}

Expand Down Expand Up @@ -489,7 +487,7 @@ export class EditChallenge extends Component {
? challengeData.reviewTaskTags
: challengeData.preferredReviewTags;

if (_isUndefined(challengeData.customTaskStyles)) {
if (challengeData.customTaskStyles === undefined) {
challengeData.customTaskStyles = !_isEmpty(challengeData.taskStyles);
}

Expand Down Expand Up @@ -655,9 +653,10 @@ export class EditChallenge extends Component {
};

hasTaskStyleRuleErrors = () => {
const useCustom = !_isUndefined(this.state.formData?.customTaskStyles)
? this.state.formData?.customTaskStyles
: !_isEmpty(this.props.challenge?.taskStyles);
const useCustom =
this.state.formData?.customTaskStyles !== undefined
? this.state.formData?.customTaskStyles
: !_isEmpty(this.props.challenge?.taskStyles);

return useCustom && this.props.hasAnyStyleRuleErrors;
};
Expand Down
Loading

0 comments on commit 2109e23

Please sign in to comment.