Skip to content
Merged

Next #256

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
385193b
Bump usehooks-ts from 2.16.0 to 3.1.0
dependabot[bot] Dec 9, 2024
d47467c
Bump motion from 11.12.0 to 11.13.1
dependabot[bot] Dec 9, 2024
3ff3e9b
Bump prisma from 5.22.0 to 6.0.1
dependabot[bot] Dec 9, 2024
f2cc133
Bump class-variance-authority from 0.7.0 to 0.7.1
dependabot[bot] Dec 9, 2024
bb3018f
Merge pull request #241 from complexdatacollective/dependabot/npm_and…
jthrilly Dec 10, 2024
c4eb018
Merge pull request #240 from complexdatacollective/dependabot/npm_and…
jthrilly Dec 10, 2024
83e5d3c
Bump typescript from 5.6.3 to 5.7.2
dependabot[bot] Dec 10, 2024
0717aaa
Merge pull request #238 from complexdatacollective/dependabot/npm_and…
jthrilly Dec 10, 2024
912e55b
Merge pull request #237 from complexdatacollective/dependabot/npm_and…
jthrilly Dec 10, 2024
d6c702c
Merge pull request #239 from complexdatacollective/dependabot/npm_and…
jthrilly Dec 10, 2024
ed576a4
Bump @vitejs/plugin-react from 4.3.3 to 4.3.4
dependabot[bot] Dec 16, 2024
8611a42
Bump dotenv from 16.4.5 to 16.4.7
dependabot[bot] Dec 16, 2024
3098640
Bump @radix-ui/react-dropdown-menu from 2.1.2 to 2.1.4
dependabot[bot] Dec 23, 2024
920c8fc
Bump uuid from 11.0.2 to 11.0.5
dependabot[bot] Jan 13, 2025
c6144de
Merge pull request #252 from complexdatacollective/dependabot/npm_and…
jthrilly Jan 14, 2025
98b6df7
Merge pull request #249 from complexdatacollective/dependabot/npm_and…
jthrilly Jan 14, 2025
2565b75
Merge pull request #244 from complexdatacollective/dependabot/npm_and…
jthrilly Jan 14, 2025
7c60dac
Merge pull request #242 from complexdatacollective/dependabot/npm_and…
jthrilly Jan 14, 2025
45ab13b
Bump @radix-ui/react-select from 2.1.2 to 2.1.4
dependabot[bot] Jan 14, 2025
34deb65
Merge pull request #248 from complexdatacollective/dependabot/npm_and…
jthrilly Jan 14, 2025
383ff45
merge changes from main
jthrilly Jan 14, 2025
0b6c765
linting
jthrilly Jan 14, 2025
a96e0f1
further linting
jthrilly Jan 14, 2025
20d386b
knip
jthrilly Jan 14, 2025
76bb471
allow text selection on information interface
jthrilly Jan 14, 2025
5cc7946
allow links on information interface
jthrilly Jan 14, 2025
ce1ed32
Merge pull request #257 from complexdatacollective/small-barf
jthrilly Jan 14, 2025
9f9aff2
bump version
jthrilly Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ const config = {
'next/core-web-vitals',
'prettier',
],
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*', 'public', '.eslintrc.cjs',],
ignorePatterns: [
'node_modules',
'*.stories.*',
'*.test.*',
'public',
'.eslintrc.cjs',
],
rules: {
"@next/next/no-img-element": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/consistent-type-definitions": ['error', 'type'],
'@next/next/no-img-element': 'off',
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'no-process-env': 'error',
'no-console': 'error',
'@typescript-eslint/consistent-type-imports': [
Expand All @@ -43,14 +49,15 @@ const config = {
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
argsIgnorePattern: '^_',
},
],
"@typescript-eslint/no-misused-promises": [
"error",
'@typescript-eslint/no-misused-promises': [
'error',
{
"checksVoidReturn": false
}
checksVoidReturn: false,
},
],
'no-unreachable': 'error',
},
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"WillLuke.nextjs.addTypesOnSave": true,
"WillLuke.nextjs.hasPrompted": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
"source.organizeImports": "always",
"source.fixAll": "always",
}
}
2 changes: 1 addition & 1 deletion actions/activityFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function addEvent(
safeRevalidateTag('activityFeed');

return { success: true, error: null };
} catch (error) {
} catch (_error) {
return { success: false, error: 'Failed to add event' };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Interview } from '@prisma/client';
import type { Row } from '@tanstack/react-table';
import { MoreHorizontal } from 'lucide-react';
import Link from 'next/link';
import { objectHash } from 'ohash';
import { useState } from 'react';
import { DeleteInterviewsDialog } from '~/app/dashboard/interviews/_components/DeleteInterviewsDialog';
import { ExportInterviewsDialog } from '~/app/dashboard/interviews/_components/ExportInterviewsDialog';
Expand Down Expand Up @@ -39,7 +40,7 @@ export const ActionsDropdown = ({ row }: { row: Row<Interview> }) => {
return (
<>
<ExportInterviewsDialog
key={selectedInterviews?.toString()}
key={objectHash(selectedInterviews)}
open={showExportModal}
handleCancel={handleResetExport}
interviewsToExport={selectedInterviews!}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { HardDriveUpload } from 'lucide-react';
import { objectHash } from 'ohash';
import { use, useMemo, useState } from 'react';
import { ActionsDropdown } from '~/app/dashboard/_components/InterviewsTable/ActionsDropdown';
import { InterviewColumns } from '~/app/dashboard/_components/InterviewsTable/Columns';
Expand Down Expand Up @@ -60,7 +61,7 @@ export const InterviewsTable = ({
return (
<>
<ExportInterviewsDialog
key={selectedInterviews?.toString()}
key={objectHash(selectedInterviews)}
open={showExportModal}
handleCancel={handleResetExport}
interviewsToExport={selectedInterviews!}
Expand Down
17 changes: 7 additions & 10 deletions components/ProtocolImport/JobReducer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import trackEvent from '~/lib/analytics';

const importStatuses = [
'Queued',
'Extracting protocol',
'Validating protocol',
'Uploading assets',
'Writing to database',
'Complete',
] as const;

type ImportStatus = (typeof importStatuses)[number];
type ImportStatus =
| 'Queued'
| 'Extracting protocol'
| 'Validating protocol'
| 'Uploading assets'
| 'Writing to database'
| 'Complete';

type ErrorState = {
title: string;
Expand Down
16 changes: 7 additions & 9 deletions components/ui/use-toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ type ToasterToast = ToastProps & {
icon?: React.ReactNode;
};

const actionTypes = {
ADD_TOAST: 'ADD_TOAST',
UPDATE_TOAST: 'UPDATE_TOAST',
DISMISS_TOAST: 'DISMISS_TOAST',
REMOVE_TOAST: 'REMOVE_TOAST',
} as const;

let count = 0;

function genId() {
count = (count + 1) % Number.MAX_VALUE;
return count.toString();
}

type ActionType = typeof actionTypes;
type ActionType = {
ADD_TOAST: 'ADD_TOAST';
UPDATE_TOAST: 'UPDATE_TOAST';
DISMISS_TOAST: 'DISMISS_TOAST';
REMOVE_TOAST: 'REMOVE_TOAST';
};

type Action =
| {
Expand Down Expand Up @@ -187,4 +185,4 @@ function useToast() {
};
}

export { useToast, };
export { useToast };
4 changes: 2 additions & 2 deletions fresco.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const PROTOCOL_EXTENSION = '.netcanvas' as const;
export const PROTOCOL_EXTENSION = '.netcanvas';
export const APP_SUPPORTED_SCHEMA_VERSIONS = [7];
// If unconfigured, the app will shut down after 2 hours (7200000 ms)
export const UNCONFIGURED_TIMEOUT = 7200000 as const;
export const UNCONFIGURED_TIMEOUT = 7200000;

// Display options for dates: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options
export const dateOptions: Intl.DateTimeFormatOptions = {
Expand Down
30 changes: 14 additions & 16 deletions lib/cache.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { revalidateTag, unstable_cache } from 'next/cache';

const CACHE_TAGS = [
'activityFeed',
'appSettings',
'getInterviews',
'summaryStatistics',
'getParticipants',
'getInterviewById',
'getProtocols',
'getInterviewsForExport',
'getProtocolsByHash',
'getExistingAssetIds',
'interviewCount',
'protocolCount',
'participantCount',
] as const;
type StaticTag =
| 'activityFeed'
| 'appSettings'
| 'getInterviews'
| 'summaryStatistics'
| 'getParticipants'
| 'getInterviewById'
| 'getProtocols'
| 'getInterviewsForExport'
| 'getProtocolsByHash'
| 'getExistingAssetIds'
| 'interviewCount'
| 'protocolCount'
| 'participantCount';

type StaticTag = (typeof CACHE_TAGS)[number];
type DynamicTag = `${StaticTag}-${string}`;

type CacheTag = StaticTag | DynamicTag;
Expand Down
17 changes: 7 additions & 10 deletions lib/data-table/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type Prisma } from '@prisma/client';
import * as z from 'zod';
import { numberEnum } from '~/schemas/participant';

export type Option = {
label: string;
Expand Down Expand Up @@ -68,12 +67,10 @@ export const FilterParam = z.object({
});
export type FilterParam = z.infer<typeof FilterParam>;

const SearchParamsSchema = z.object({
page: z.number(),
perPage: numberEnum(pageSizes),
sort: z.enum(sortOrder),
sortField: z.enum(sortableFields),
filterParams: z.array(FilterParam).nullable(),
});

export type SearchParams = z.infer<typeof SearchParamsSchema>;
export type SearchParams = {
page: number;
perPage: number;
sort: (typeof sortOrder)[number];
sortField: (typeof sortableFields)[number];
filterParams: FilterParam[] | null;
};
19 changes: 12 additions & 7 deletions lib/interviewer/containers/Interfaces/Information.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import PropTypes from 'prop-types';
import Markdown from '~/lib/ui/components/Fields/Markdown';
import Scroller from '~/lib/ui/components/Scroller';
import { ALLOWED_MARKDOWN_TAGS } from '~/lib/ui/utils/config';
import AssetMetaProvider from '../../behaviours/AssetMetaProvider';
import Audio from '../../components/Audio';
import BackgroundImage from '../../components/BackgroundImage';
import Video from '../../components/Video';
import { InformationContentType, AssetType } from '../../protocol-consts';
import AssetMetaProvider from '../../behaviours/AssetMetaProvider';
import Scroller from '~/lib/ui/components/Scroller';
import { AssetType, InformationContentType } from '../../protocol-consts';

const getAssetComponent = (asset) => {
switch (asset.type) {
Expand All @@ -30,7 +30,12 @@ const getAssetComponent = (asset) => {
const getItemComponent = (item) => {
switch (item.type) {
case InformationContentType.text:
return <Markdown label={item.content} />;
return (
<Markdown
label={item.content}
allowedElements={[...ALLOWED_MARKDOWN_TAGS, 'a']} // Allow anchor tags only for the information interface
/>
);
case InformationContentType.asset:
return (
<AssetMetaProvider assetId={item.content}>
Expand Down Expand Up @@ -64,7 +69,7 @@ const renderItems = (items) => (items ? items.map(renderItem) : null);
*/
const Information = ({ stage: { title, items } }) => {
return (
<div className="interface">
<div className="interface allow-text-selection">
<Scroller className="information-interface__information-container-scroller">
<div className="information-interface">
<div className="information-interface__frame">
Expand Down
8 changes: 4 additions & 4 deletions lib/interviewer/ducks/modules/deviceSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const SET_DESCRIPTION = 'SETTINGS/SET_DESCRIPTION' as const;
const SET_INTERFACE_SCALE = 'SETTINGS/SET_INTERFACE_SCALE' as const;
const TOGGLE_SETTING = 'SETTINGS/TOGGLE_SETTING' as const;
const SET_SETTING = 'SETTINGS/SET_SETTING' as const;
const SET_DESCRIPTION = 'SETTINGS/SET_DESCRIPTION';
const SET_INTERFACE_SCALE = 'SETTINGS/SET_INTERFACE_SCALE';
const TOGGLE_SETTING = 'SETTINGS/TOGGLE_SETTING';
const SET_SETTING = 'SETTINGS/SET_SETTING';

// Static defaults should be distinguishable from user choices (e.g., undefined instead of false).
type DeviceSettings = {
Expand Down
2 changes: 1 addition & 1 deletion lib/network-exporters/formatters/csv/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const sanitizedCellValue = (value) => {
let serialized;
try {
serialized = JSON.stringify(value);
} catch (err) {
} catch (_err) {
serialized = value.toString(); // value will never be null here
}
return quoteValue(serialized);
Expand Down
12 changes: 6 additions & 6 deletions lib/network-exporters/formatters/formatExportableSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export const formatExportableSessions = (
[protocolProperty]: sessionProtocol.hash,
[protocolName]: sessionProtocol.name,
[codebookHashProperty]: hash(sessionProtocol.codebook),
...(session.startTime && {
[sessionStartTimeProperty]: new Date(session.startTime).toISOString(),
}),
...(session.finishTime && {
[sessionFinishTimeProperty]: new Date(session.finishTime).toISOString(),
}),
[sessionStartTimeProperty]: session.startTime
? new Date(session.startTime).toISOString()
: undefined,
[sessionFinishTimeProperty]: session.finishTime
? new Date(session.finishTime).toISOString()
: undefined,
[sessionExportTimeProperty]: new Date().toISOString(),
COMMIT_HASH: env.COMMIT_HASH!,
APP_VERSION: env.APP_VERSION!,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env jest */

import { ncUUIDProperty } from '@codaco/shared-consts';
import { DOMParser } from '@xmldom/xmldom';
import { DOMParser, MIME_TYPE } from '@xmldom/xmldom';
import { beforeEach, describe, expect, it } from 'vitest';
import {
mockCodebook,
Expand All @@ -23,7 +23,7 @@ const buildXML = (...args) => {
}

const parser = new DOMParser();
const result = parser.parseFromString(xmlString);
const result = parser.parseFromString(xmlString, MIME_TYPE.XML_APPLICATION);
return result;
};

Expand Down Expand Up @@ -100,7 +100,10 @@ describe('buildGraphML', () => {
});

it('omits networkCanvasUUID data element when network.codebook.ego is empty', () => {
const processedNetworks = processMockNetworks([mockNetwork, mockNetwork2]);
const processedNetworks = processMockNetworks([
mockNetwork,
mockNetwork2,
]);
const protocolNetwork = processedNetworks['protocol-uid-1'][0];
const { ego, ...egolessCodebook } = codebook;
const egolessNetwork = { ...protocolNetwork, ego: {} };
Expand Down
4 changes: 2 additions & 2 deletions lib/network-exporters/formatters/graphml/createGraphML.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
sessionProperty,
sessionStartTimeProperty,
} from '@codaco/shared-consts';
import dom from '@xmldom/xmldom';
import dom, { MIME_TYPE } from '@xmldom/xmldom';
import {
getAttributePropertyFromCodebook,
getEntityAttributes,
Expand Down Expand Up @@ -110,7 +110,7 @@ const setUpXml = (exportOptions, sessionVariables) => {
)}${xmlFooter}`;
return new globalContext.DOMParser().parseFromString(
graphMLOutline,
'text/xml',
MIME_TYPE.XML_APPLICATION,
);
};

Expand Down
1 change: 1 addition & 0 deletions lib/network-exporters/formatters/session/exportFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const exportFile = ({
});
});
writeStream.on('error', (error) => {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject({
success: false,
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
*/

import { egoProperty, entityPrimaryKeyProperty } from '@codaco/shared-consts';
import type {
FormattedSession,
SessionWithNetworkEgo,
} from '../../utils/types';
import type { FormattedSession } from '../../utils/types';

const insertNetworkEgo = (
session: FormattedSession,
): SessionWithNetworkEgo => ({
const insertNetworkEgo = (session: FormattedSession) => ({
...session,
nodes: session.nodes
? session.nodes.map((node) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const partitionByType = (
return [session];
}

const partitionedNodeMap = session?.nodes?.reduce(
const partitionedNodeMap = session.nodes.reduce(
(nodeMap, node) => {
nodeMap[node.type] = nodeMap[node.type] ?? [];
nodeMap[node.type]!.push(node);
Expand Down
Loading
Loading