Skip to content

Commit

Permalink
Merge pull request #158 from complexdatacollective/next
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
jthrilly authored Sep 20, 2024
2 parents c0dca1b + d5539be commit 72f4b34
Show file tree
Hide file tree
Showing 16 changed files with 1,852 additions and 2,130 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Checks

on:
pull_request:
Expand Down Expand Up @@ -44,9 +44,6 @@ jobs:
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Run build
run: pnpm lint

- name: Run tests
run: pnpm test

Expand Down
58 changes: 0 additions & 58 deletions .github/workflows/docker.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "pnpm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/next",
"runtimeArgs": [
"--inspect"
],
"skipFiles": [
"<node_internals>/**"
],
"serverReadyAction": {
"action": "debugWithEdge",
"killOnServerStop": true,
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"webRoot": "${workspaceFolder}"
}
}
]
}
12 changes: 8 additions & 4 deletions actions/participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ export async function importParticipants(rawInput: unknown) {
export async function updateParticipant(rawInput: unknown) {
await requireApiAuth();

const { identifier, data } = updateSchema.parse(rawInput);
const { identifier, label } = updateSchema.parse(rawInput);

try {
const updatedParticipant = await prisma.participant.update({
where: { identifier },
data,
data: {
label: label,
},
});

safeRevalidateTag('getParticipants');
Expand All @@ -125,9 +127,11 @@ export async function createParticipant(rawInput: unknown) {
const participants = participantListInputSchema.parse(rawInput);

const participantsWithIdentifiers = participants.map((participant) => {
const { identifier, ...rest } = participant;

return {
identifier: participant.identifier ?? createId(),
...participant,
identifier: identifier ?? createId(),
...rest,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ExportInterviewsDialog = ({
const url = URL.createObjectURL(responseAsBlob);

// Download the zip file
download(url, 'Network Canvas export.zip');
download(url, 'Network Canvas Export.zip');
// clean up the URL object
URL.revokeObjectURL(url);
} catch (error) {
Expand Down
6 changes: 1 addition & 5 deletions app/dashboard/participants/_components/ParticipantModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,10 @@ function ParticipantModal({
setError(null);
setWorking(true);

if (data.label === '') {
data.label = undefined;
}

if (editingParticipant) {
await updateParticipant({
identifier: editingParticipant.identifier,
data,
label: data.label,
});
}

Expand Down
4 changes: 2 additions & 2 deletions components/data-table/data-table-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function DataTableToolbar<TData>({
newRowLink,
deleteRowsAction,
}: DataTableToolbarProps<TData>) {
const isFiltered = table.getState().columnFilters?.length > 0 ?? false;
const isFiltered = table.getState().columnFilters?.length > 0;
const [isPending, startTransition] = React.useTransition();

return (
Expand Down Expand Up @@ -119,4 +119,4 @@ export function DataTableToolbar<TData>({
</div>
</div>
);
}
}
4 changes: 1 addition & 3 deletions lib/interviewer/hooks/useReadyForNextStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const useReadyForNextStage = () => {
[dispatch],
);

const isReady = useSelector(
(state: RootState) => !!state.ui.FORM_IS_READY ?? false,
);
const isReady = useSelector((state: RootState) => !!state.ui.FORM_IS_READY);

useEffect(() => {
updateReady(false);
Expand Down
15 changes: 12 additions & 3 deletions lib/network-exporters/formatters/formatExportableSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ export const formatExportableSessions = (
const sessionProtocol = session.protocol;
const sessionParticipant = session.participant;

const getCaseProperty = () => {
if (sessionParticipant.label && sessionParticipant.label !== '') {
return sessionParticipant.label;
}

return sessionParticipant.identifier;
};

const sessionVariables: SessionVariables = {
// Label is optional, so fallback to identifier because caseProperty is used
// to create the filename during export.
[caseProperty]: sessionParticipant.label ?? sessionParticipant.identifier,
// Label is optional, but defaults to an empty string!
// We **must** fallback to identifier in this case, because caseProperty
// is used to create the filename during export.
[caseProperty]: getCaseProperty(),
[sessionProperty]: session.id,
[protocolProperty]: sessionProtocol.hash,
[protocolName]: sessionProtocol.name,
Expand Down
27 changes: 19 additions & 8 deletions lib/network-exporters/utils/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import {
sessionProperty,
type Codebook,
type NcEntity,
type StageSubject
type StageSubject,
} from '@codaco/shared-consts';
import sanitizeFilename from 'sanitize-filename';
import type { ExportFormat, SessionWithResequencedIDs } from './types';

export const getEntityAttributes = (entity: NcEntity) =>
(entity?.[entityAttributesProperty]) || {};
entity?.[entityAttributesProperty] || {};

const escapeFilePart = (part: string) => part.replace(/\W/g, '');

export const makeFilename = (prefix:string, entityName: string | undefined, exportFormat: string, extension: string) => {
export const makeFilename = (
prefix: string,
entityName: string | undefined,
exportFormat: string,
extension: string,
) => {
let name = prefix;
if (extension !== `.${exportFormat}`) {
name += name ? '_' : '';
Expand Down Expand Up @@ -49,12 +54,14 @@ export const getFileExtension = (formatterType: ExportFormat) => {
}
};


/**
* Generate a filename prefix based on the session in the format:
* `{caseId}_{sessionId}`
* `{caseId}_{sessionId}`
*/
export const getFilePrefix = (session: SessionWithResequencedIDs) => sanitizeFilename(`${session.sessionVariables[caseProperty]}_${session.sessionVariables[sessionProperty]}`);
export const getFilePrefix = (session: SessionWithResequencedIDs) =>
sanitizeFilename(
`${session.sessionVariables[caseProperty]}_${session.sessionVariables[sessionProperty]}`,
);

/**
* Given a codebook, an entity type, an entity, and an attribute key:
Expand All @@ -64,8 +71,12 @@ export const getFilePrefix = (session: SessionWithResequencedIDs) => sanitizeFil
* @param {*} entity
* @param {*} key
*/
const getVariableInfo = (codebook: Codebook, type: 'node' | 'edge', entity: StageSubject, key: string) =>
codebook[type]?.[entity.type]?.variables?.[key];
const getVariableInfo = (
codebook: Codebook,
type: 'node' | 'edge',
entity: StageSubject,
key: string,
) => codebook[type]?.[entity.type]?.variables?.[key];

/**
* Ego version of getVariableInfo
Expand Down
3 changes: 1 addition & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import('./env.js');
import ChildProcess from 'node:child_process';
import pkg from './package.json' with { type: 'json' };


let commitHash = 'Unknown commit hash';

try {
Expand All @@ -11,7 +10,7 @@ try {
.trim()
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error getting commit hash:', error);
console.info('Error getting commit hash:', error.message ?? 'Unknown error');
}

/** @type {import("next").NextConfig} */
Expand Down
Loading

0 comments on commit 72f4b34

Please sign in to comment.