Skip to content

Commit

Permalink
checkbox to disable popup for large sample tables
Browse files Browse the repository at this point in the history
  • Loading branch information
nleroy917 committed Feb 22, 2024
1 parent ed92f40 commit 3f0cbf3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
27 changes: 21 additions & 6 deletions web/src/components/modals/sample-table-too-large.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { FC } from 'react';
import { Modal } from 'react-bootstrap';
import { FormCheck, Modal } from 'react-bootstrap';

import { useLocalStorage } from '../../hooks/useLocalStorage';

interface Props {
show: boolean;
Expand All @@ -8,6 +10,7 @@ interface Props {
}

export const LargeSampleTableModal: FC<Props> = ({ show, onHide, namespace }) => {
const [_, setHideLargeSampleTableModal] = useLocalStorage('hideLargeSampleTableModal', 'false');
return (
<Modal
centered
Expand All @@ -33,16 +36,28 @@ export const LargeSampleTableModal: FC<Props> = ({ show, onHide, namespace }) =>
Use the dropdown in the top right to select a view, or use the API directly to fetch slices of the sample
table.
</p>
<form>
<input
type="checkbox"
id="dont-show-again"
className="form-check-input"
onChange={(e) => {
if (e.target.checked) {
setHideLargeSampleTableModal('true');
} else {
setHideLargeSampleTableModal('false');
}
}}
/>
<label htmlFor="dont-show-again" className="ms-1 form-check-label">
Don't show this message again
</label>
</form>
</Modal.Body>
<Modal.Footer>
<button onClick={onHide} type="button" className="btn btn-dark">
Dismiss
</button>
<a href={namespace ? `/${namespace}` : '/'}>
<button type="button" className="btn btn-outline-dark" onClick={onHide}>
Back
</button>
</a>
</Modal.Footer>
</Modal>
);
Expand Down
14 changes: 7 additions & 7 deletions web/src/components/tables/sample-table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HotTable } from '@handsontable/react';
import { FC } from 'react';
import Handsontable from 'handsontable';
import { FC } from 'react';

import { Sample } from '../../../types';
import { arraysToSampleList, sampleListToArrays } from '../../utils/sample-table';
Expand Down Expand Up @@ -47,19 +47,19 @@ export const SampleTable: FC<Props> = ({ data, readOnly = false, onChange, heigh
colHeaders={true}
renderer={(instance, td, row, col, prop, value, cellProperties) => {
Handsontable.renderers.TextRenderer.apply(this, [instance, td, row, col, prop, value, cellProperties]);
td.innerHTML = `<div class="truncated">${value || '' }</div>`
td.innerHTML = `<div class="truncated">${value || ''}</div>`;
td.addEventListener('click', function (event) {
const innerDiv = td.querySelector('.truncated');
if (innerDiv && event.target === innerDiv) {
innerDiv.classList.toggle('expanded');
}
const innerDiv = td.querySelector('.truncated');
if (innerDiv && event.target === innerDiv) {
innerDiv.classList.toggle('expanded');
}
});
}}
dropdownMenu={true}
hiddenColumns={{
indicators: true,
}}
minCols={1}
minCols={5}
minRows={minRows || 50}
contextMenu={[
'row_above',
Expand Down
7 changes: 5 additions & 2 deletions web/src/pages/Project.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, Fragment, MouseEvent, forwardRef, useEffect, useRef, useState } from 'react';
import { Breadcrumb, Dropdown } from 'react-bootstrap';
import { set } from 'react-hook-form';
import { useParams, useSearchParams } from 'react-router-dom';
import { useLocalStorage } from 'usehooks-ts';

import { Sample } from '../../types';
import { StatusIcon } from '../components/badges/status-icons';
Expand Down Expand Up @@ -66,6 +66,9 @@ export const ProjectPage: FC = () => {
// user info
const { user, jwt, login } = useSession();

// auto-dismiss popup for large sample tables
const [hideLargeSampleTableModal] = useLocalStorage('hideLargeSampleTableModal', 'false');

// os info
const os = getOS();

Expand Down Expand Up @@ -169,7 +172,7 @@ export const ProjectPage: FC = () => {
}, [fork]);

useEffect(() => {
if (projectInfo !== undefined) {
if (projectInfo !== undefined && hideLargeSampleTableModal === 'false') {
setShowLargeSampleTableModal(!fetchSampleTable);
}
}, [fetchSampleTable, projectInfo]);
Expand Down

0 comments on commit 3f0cbf3

Please sign in to comment.