Skip to content

Commit 913fd46

Browse files
authored
Merge pull request #1404 from VEuPathDB/main
patch various fixes in 68f
2 parents b4b5126 + 6b45a76 commit 913fd46

File tree

17 files changed

+385
-315
lines changed

17 files changed

+385
-315
lines changed

packages/libs/coreui/src/components/buttons/FilledButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default function FilledButton({
9999

100100
const finalStyle = useMemo(
101101
() => merge({}, defaultStyle, themeStyle, styleOverrides),
102-
[themeStyle]
102+
[defaultStyle, themeStyle, styleOverrides]
103103
);
104104

105105
return (

packages/libs/coreui/src/components/buttons/FloatingButton/index.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { merge } from 'lodash';
22
import { useMemo } from 'react';
33

44
import useUITheme from '../../theming/useUITheme';
5-
import { blue, gray } from '../../../definitions/colors';
5+
import { blue, gray, mutedBlue } from '../../../definitions/colors';
66
import SwissArmyButton from '../SwissArmyButton';
77
import {
88
ButtonStyleSpec,
@@ -81,7 +81,7 @@ export default function FloatingButton({
8181

8282
const finalStyle = useMemo(
8383
() => merge({}, defaultStyle, themeStyle, styleOverrides),
84-
[themeStyle]
84+
[defaultStyle, themeStyle, styleOverrides]
8585
);
8686

8787
return (
@@ -100,3 +100,26 @@ export default function FloatingButton({
100100
/>
101101
);
102102
}
103+
104+
export const FloatingButtonWDKStyle: ButtonStyleSpec = {
105+
default: {
106+
color: 'transparent',
107+
textColor: '#069',
108+
fontWeight: 600,
109+
},
110+
hover: {
111+
color: mutedBlue[100],
112+
textColor: '#069',
113+
fontWeight: 600,
114+
},
115+
pressed: {
116+
color: mutedBlue[200],
117+
textColor: '#069',
118+
fontWeight: 600,
119+
},
120+
disabled: {
121+
color: 'transparent',
122+
textColor: gray[500],
123+
fontWeight: 600,
124+
},
125+
};

packages/libs/coreui/src/components/buttons/MesaButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default function MesaButton({
144144

145145
const finalStyle = useMemo(
146146
() => merge({}, defaultStyle, themeStyle, styleOverrides),
147-
[themeStyle]
147+
[defaultStyle, themeStyle, styleOverrides]
148148
);
149149

150150
return (

packages/libs/coreui/src/components/buttons/OutlinedButton/index.tsx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { merge } from 'lodash';
22
import { useMemo } from 'react';
33

44
import useUITheme from '../../theming/useUITheme';
5-
import { blue, gray } from '../../../definitions/colors';
5+
import { blue, gray, mutedBlue } from '../../../definitions/colors';
66
import SwissArmyButton from '../SwissArmyButton';
77
import {
88
ButtonStyleSpec,
@@ -115,7 +115,7 @@ export default function OutlinedButton({
115115

116116
const finalStyle = useMemo(
117117
() => merge({}, defaultStyle, themeStyle, styleOverrides),
118-
[themeStyle]
118+
[defaultStyle, themeStyle, styleOverrides]
119119
);
120120

121121
return (
@@ -133,3 +133,51 @@ export default function OutlinedButton({
133133
/>
134134
);
135135
}
136+
137+
// Styled for use in the wdk
138+
export const OutlinedButtonWDKStyle = {
139+
default: {
140+
textColor: '#0F86C1',
141+
fontWeight: 600,
142+
color: 'transparent',
143+
border: {
144+
radius: 5,
145+
color: '#0F86C1',
146+
style: 'solid',
147+
width: 2,
148+
},
149+
},
150+
hover: {
151+
textColor: mutedBlue[600],
152+
fontWeight: 600,
153+
color: 'transparent',
154+
border: {
155+
radius: 5,
156+
color: mutedBlue[600],
157+
style: 'solid',
158+
width: 2,
159+
},
160+
},
161+
pressed: {
162+
textColor: mutedBlue[700],
163+
fontWeight: 600,
164+
color: 'transparent',
165+
border: {
166+
radius: 5,
167+
color: mutedBlue[700],
168+
style: 'solid',
169+
width: 2,
170+
},
171+
},
172+
disabled: {
173+
textColor: gray[500],
174+
fontWeight: 600,
175+
color: 'transparent',
176+
border: {
177+
radius: 5,
178+
color: gray[500],
179+
style: 'solid',
180+
width: 2,
181+
},
182+
},
183+
};

packages/libs/eda/src/lib/core/components/filter/TableFilter.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,13 @@ export function TableFilter({
232232
analysisState.setVariableUISettings((currentState) => ({
233233
...currentState,
234234
[uiStateKey]: {
235-
...uiState,
235+
...currentState[uiStateKey],
236236
sort,
237237
currentPage: 1,
238238
},
239239
}));
240240
},
241-
[analysisState, uiStateKey, uiState]
241+
[analysisState, uiStateKey]
242242
);
243243

244244
const handleSearch = useCallback(
@@ -254,39 +254,39 @@ export function TableFilter({
254254
analysisState.setVariableUISettings((currentState) => ({
255255
...currentState,
256256
[uiStateKey]: {
257-
...uiState,
257+
...currentState[uiStateKey],
258258
searchTerm,
259259
...(shouldResetPaging ? { currentPage: 1 } : {}),
260260
},
261261
}));
262262
},
263-
[analysisState, uiStateKey, uiState]
263+
[analysisState, uiStateKey]
264264
);
265265

266266
const handlePagination = useCallback(
267267
(_: unknown, currentPage: number) => {
268268
analysisState.setVariableUISettings((currentState) => ({
269269
...currentState,
270270
[uiStateKey]: {
271-
...uiState,
271+
...currentState[uiStateKey],
272272
currentPage,
273273
},
274274
}));
275275
},
276-
[analysisState, uiStateKey, uiState]
276+
[analysisState, uiStateKey]
277277
);
278278

279279
const handleRowsPerPage = useCallback(
280280
(_: unknown, rowsPerPage: number) => {
281281
analysisState.setVariableUISettings((currentState) => ({
282282
...currentState,
283283
[uiStateKey]: {
284-
...uiState,
284+
...currentState[uiStateKey],
285285
rowsPerPage,
286286
},
287287
}));
288288
},
289-
[analysisState, uiStateKey, uiState]
289+
[analysisState, uiStateKey]
290290
);
291291

292292
const allValues = useMemo(() => {

packages/libs/eda/src/lib/core/utils/default-axis-range.ts

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Variable } from '../types/study';
1+
import { NumberDistributionDefaults, Variable } from '../types/study';
22
import { NumberOrDateRange } from '@veupathdb/components/lib/types/general';
33
// type of computedVariableMetadata for computation apps such as alphadiv and abundance
44
import { VariableMapping } from '../api/DataClient/types';
@@ -24,23 +24,12 @@ export function numberDateDefaultAxisRange(
2424
min:
2525
logScale &&
2626
observedMin != null &&
27-
(observedMin <= 0 ||
27+
((observedMin as number) <= 0 ||
2828
(defaults.displayRangeMin != null &&
2929
defaults.displayRangeMin <= 0) ||
3030
defaults.rangeMin <= 0)
3131
? (observedMinPos as number)
32-
: // For the min, we want to start at one of the following, in order of precedence:
33-
//
34-
// - `displayRangeMin`, if it is defined and smaller than `rangeMin`
35-
// - `rangeMin`, if it is smaller than `0`
36-
// - `0`, otherwise.
37-
//
38-
// This can be expressed as a `min` function.
39-
(min([
40-
defaults.displayRangeMin ?? 0,
41-
defaults.rangeMin,
42-
observedMin,
43-
]) as number),
32+
: getSafeLowerBound(defaults, observedMin as number),
4433
max: max([
4534
defaults.displayRangeMax,
4635
defaults.rangeMax,
@@ -148,3 +137,37 @@ export function numberDateDefaultAxisRange(
148137
};
149138
} else return undefined;
150139
}
140+
141+
const MAX_EDGE_CASE_BINS = 2000;
142+
143+
/**
144+
* The basic functionality is to return `min([ displayRangeMin ?? 0, rangeMin, observedMin ])`
145+
* The zero is targeted at histograms which should start at zero even if rangeMin > 0.
146+
*
147+
* However, there is an edge case when rangeMin === rangeMax. (When the default binWidth defaults to 1.)
148+
* If we are making a `distribution` histogram request in this scenario, we do NOT want
149+
* to request `{ min: 0, max: rangeMax, binWidth: 1 }`
150+
* because this will cause an OOM error on the backend if `rangeMax` is large.
151+
*
152+
* The solution is to check for the edge case and return
153+
* `rangeMin - binWidth` for the lower bound if the number of bins would be excessive.
154+
*/
155+
function getSafeLowerBound(
156+
{ displayRangeMin, rangeMin, rangeMax, binWidth }: NumberDistributionDefaults,
157+
observedMin?: number
158+
): number {
159+
let lowerBound = 0; // for "full" ranges for non-edge-case positive variables
160+
161+
// If there's a human-supplied minimum, trust it
162+
if (displayRangeMin != null) {
163+
lowerBound = displayRangeMin;
164+
} else if (
165+
// check for the edge-case
166+
rangeMin === rangeMax &&
167+
rangeMax / (binWidth ?? 1) > MAX_EDGE_CASE_BINS
168+
) {
169+
lowerBound = rangeMin - (binWidth ?? 1);
170+
}
171+
172+
return min([lowerBound, rangeMin, observedMin]) as number;
173+
}

packages/libs/user-datasets/src/lib/Components/List/UserDatasetList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,13 @@ class UserDatasetList extends React.Component<Props, State> {
256256
return (
257257
<div style={{ display: 'block', maxWidth: '100%' }}>
258258
<SaveableTextEditor
259-
rows={Math.max(2, Math.floor(dataset.meta.summary.length / 22))}
259+
rows={Math.max(
260+
2,
261+
Math.floor((dataset.meta.summary?.length ?? 0) / 22)
262+
)}
260263
multiLine={true}
261264
onSave={saveSummary}
262-
value={dataset.meta.summary}
265+
value={dataset.meta.summary ?? ''}
263266
readOnly={!isOwner(dataset.ownerUserId)}
264267
/>
265268
</div>

packages/libs/user-datasets/src/lib/Components/UploadForm.scss

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
display: flex;
3939
flex-direction: column;
4040
gap: 0.5em;
41-
padding-left: 1em;
42-
padding-right: 1em;
4341

4442
> label {
4543
font-size: medium;
@@ -87,9 +85,9 @@
8785
}
8886
}
8987
& &--NestedInputContainer {
90-
border-style: solid;
91-
border-width: 0.5px;
92-
border-color: lightgray;
88+
background: #f7f8fb;
89+
padding-bottom: 5px;
90+
border-radius: 2px;
9391
}
9492
& &--NestedInputContainer &--NestedInputTitle {
9593
display: flex;

0 commit comments

Comments
 (0)