Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: Proper handling of empty assets in deleteProtocols #36

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cdc0bd2
add Interviewer to git index
jthrilly Nov 23, 2023
ce856a7
add redux provider to InterviewShell
jthrilly Nov 23, 2023
2e3ad3d
replace uuid imports with new syntax
jthrilly Nov 23, 2023
c168ce6
remove protocol validation, network exporters, and network query from…
jthrilly Nov 23, 2023
33a8c99
update CSS import paths
jthrilly Nov 23, 2023
3adcf4f
remove some index.js files and attempt to add file-loader
jthrilly Nov 23, 2023
c60a08b
remove react-router-dom references, delete router, and delete StartSc…
jthrilly Nov 23, 2023
b1791ea
implement custom webpack config for file-loader to handle wav files
jthrilly Nov 23, 2023
a80b38d
initial refactor of store
jthrilly Nov 23, 2023
c0b69b4
rendering information interface! 🚀
jthrilly Nov 23, 2023
49ba0e9
move interviewer assets to public folder
jthrilly Nov 23, 2023
27c0200
remove redundant files and reimplement ProtocolScreen
jthrilly Nov 24, 2023
6a52b68
initial asset loading
jthrilly Nov 27, 2023
19dab44
fix selectors for name generator to make them correctly memoized
jthrilly Nov 27, 2023
bfcabea
add NoSSRWRapper and fix react portal hook issue
jthrilly Nov 28, 2023
863bbce
correctly hydrate network state based on if it is null or has a value
jthrilly Nov 28, 2023
a3ba946
fix prompt initial animation
jthrilly Nov 28, 2023
76bf5ab
refactor selectors to avoid circular dependencies
jthrilly Nov 28, 2023
721485a
fix broken imports for refactored selectors
jthrilly Nov 28, 2023
02a32bf
partial implementation of name generator roster with remote asset fet…
jthrilly Nov 28, 2023
99bd01f
fixed delete protocol issue
mrkarimoff Nov 29, 2023
35a7342
updated deleteProtocols function
mrkarimoff Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const config = {
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:@typescript-eslint/recommended-type-checked',
],
files: ['*.ts', '*.tsx'],
parserOptions: {
Expand All @@ -20,13 +21,16 @@ const config = {
},
plugins: ['@typescript-eslint', 'eslint-plugin-local-rules'],
extends: [
'next/core-web-vitals',
'eslint:recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:@typescript-eslint/recommended',
'next/core-web-vitals',
'plugin:storybook/recommended',
'prettier',
],
ignorePatterns: ['node_modules', 'lib', '*.stories.*', '*.test.*'],
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*'],
rules: {
"@typescript-eslint/consistent-type-definitions": ['error', 'type'],
'no-process-env': 'error',
'no-console': 'error',
'@typescript-eslint/consistent-type-imports': [
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# fresco-setup-test
# Fresco

## Deploy your own instance of Fresco
The Fresco project aims to bring Network Canvas interviews to the web browser. It is a pilot project that does not
add new features to Network Canvas, but rather provides a new way to conduct interviews.

## Known Limitations

- Custom node label workers are not implemented.
- Videos and audio cannot autoplay on load due to browser limitations. Participants must click the play button to start media.

# Deployment instructions

**1. Set up required servies**
- Create a database with [PlanetScale](https://planetscale.com/docs/tutorials/planetscale-quick-start-guide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ export const ParticipantColumns =
},
cell: ({ row }) => (
<Link
target="_blank"
className="text-blue-500 underline hover:text-blue-300"
href={`/interview/${row.original.id}`}
href={`/participant/${row.original.id}`}
>
interview/{row.original.id}
Participant page
</Link>
),
enableSorting: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ActionError from '~/components/ActionError';
import { api } from '~/trpc/client';
import { participantIdentifierSchema } from '~/shared/schemas';
import type { Participant } from '@prisma/client';
import { clientRevalidateTag } from '~/utils/clientRevalidate';

interface ParticipantModalProps {
open: boolean;
Expand Down Expand Up @@ -59,6 +60,7 @@ function ParticipantModal({
setIsLoading(true);
},
async onSuccess() {
void clientRevalidateTag('participant.get.all');
await utils.participant.get.invalidate();
},
onError(error) {
Expand All @@ -79,6 +81,7 @@ function ParticipantModal({
setError(error.message);
},
onSettled() {
void clientRevalidateTag('participant.get.all');
setIsLoading(false);
},
},
Expand Down
23 changes: 11 additions & 12 deletions app/(interview)/interview/[interviewId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import InterviewNavigation from '~/app/(interview)/interview/_components/Intervi
import type { NcNetwork, Protocol } from '@codaco/shared-consts';
import Link from 'next/link';
import { api } from '~/trpc/server';
import { Button } from '~/components/ui/Button';
import InterviewShell from '../_components/InterviewShell';
import NoSSRWrapper from '~/utils/NoSSRWrapper';
import Test from '../_components/Test';

export const dynamic = 'force-dynamic';

export default async function Page({
params: { interviewId },
params,
}: {
params: { interviewId: string };
}) {
const { interviewId } = params;
// Fetch interview data from the database
if (!interviewId) {
console.log('no interview ID...creating one');
return 'No interview id found';
}

Expand All @@ -31,16 +37,9 @@ export default async function Page({
initialNetwork={initialNetwork}
protocol={interviewProtocol}
>
<div className="flex grow flex-col justify-between p-10">
<h1 className="text-3xl">Interview</h1>
<Link href="/">
<Button>Exit Interview</Button>
</Link>
<Stage />
<aside className="flex items-center justify-center">
<InterviewNavigation />
</aside>
</div>
<NoSSRWrapper>
<InterviewShell />
</NoSSRWrapper>
</InterviewProvider>
);
}
31 changes: 31 additions & 0 deletions app/(interview)/interview/_components/InterviewShell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import { motion } from 'framer-motion';
import { useRef } from 'react';
import { Provider } from 'react-redux';
import DialogManager from '~/lib/interviewer/components/DialogManager';
import { SettingsMenu } from '~/lib/interviewer/components/SettingsMenu';
import ProtocolScreen from '~/lib/interviewer/containers/ProtocolScreen';
import configureAppStore from '~/lib/interviewer/store';
import { useInterview } from '~/providers/InterviewProvider';

const InterviewShell = () => {
const { protocol, network, currentStageIndex } = useInterview();

// I'm not sure this needs to be in a ref?
const store = useRef(
configureAppStore({ protocol, network, currentStageIndex }),
);

return (
<motion.div className="grid h-[100vh] grid-cols-2">
<Provider store={store.current}>
<ProtocolScreen />
<SettingsMenu />
<DialogManager />
</Provider>
</motion.div>
);
};

export default InterviewShell;
12 changes: 0 additions & 12 deletions app/(interview)/interview/error.tsx

This file was deleted.

6 changes: 5 additions & 1 deletion app/(interview)/interview/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export const metadata = {
};

function RootLayout({ children }: { children: React.ReactNode }) {
return <main className="min-h-screen bg-violet-200">{children}</main>;
return (
<main className="min-h-screen " style={{ background: 'var(--background)' }}>
{children}
</main>
);
}

export default RootLayout;
10 changes: 4 additions & 6 deletions app/(interview)/interview/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/**
* The interview/new route should create a new interview item in the database,
* and then redirect to the interview/[id]/1 route.
*/

import { redirect } from 'next/navigation';
import { api } from '~/trpc/server';
import { faker } from '@faker-js/faker';
import { participantIdentifierSchema } from '~/shared/schemas';
import { ErrorMessage } from '~/app/(interview)/interview/_components/ErrorMessage';

export const dynamic = 'force-dynamic';

export default async function Page({
Expand Down Expand Up @@ -59,13 +55,15 @@ export default async function Page({
}

// Create the interview
const { createdInterview, error } =
const { error, createdInterview } =
await api.interview.create.mutate(identifier);

if (error || !createdInterview) {
throw new Error(error || 'An error occurred while creating the interview');
}

// TODO: check if the identifier already exists.

// Redirect to the interview/[id] route
redirect(`/interview/${createdInterview.id}`);
}
17 changes: 17 additions & 0 deletions app/(interview)/participant/[participantId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Link from 'next/link';
import { Button } from '~/components/ui/Button';

export default function Page({
params,
}: {
params: { participantId: string };
}) {
return (
<div>
<h1>Page for {params.participantId}</h1>
<Link href={`/interview/new?identifier=${params.participantId}`}>
<Button>Start Interview</Button>
</Link>
</div>
);
}
4 changes: 2 additions & 2 deletions app/(onboard)/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ function Page() {
}

if (!session && currentStep !== 1) {
setCurrentStep(1).catch(() => {});
void setCurrentStep(1);
return;
}

if (session && currentStep === 1) {
setCurrentStep(2).catch(() => {});
void setCurrentStep(2);
return;
}
}, [isLoading, session, currentStep, setCurrentStep]);
Expand Down
13 changes: 13 additions & 0 deletions lib/interviewer/__mocks__/electron-log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env jest */

module.exports = {
transports: {
console: {
},
file: {
},
},
debug: jest.fn(),
error: jest.fn(),
info: jest.fn(),
};
9 changes: 9 additions & 0 deletions lib/interviewer/__mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-env jest */

const rfs = jest.requireActual('fs');

const fs = jest.genMockFromModule('fs');

fs.readFileSync = rfs.readFileSync;

module.exports = fs;
5 changes: 5 additions & 0 deletions lib/interviewer/__mocks__/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = {
join: (...args) => args.join('/'),
};

module.exports = path;
3 changes: 3 additions & 0 deletions lib/interviewer/__mocks__/request-promise-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const request = ({ uri }) => Promise.resolve(`DUMMY DATA//${uri}`);

module.exports = request;
18 changes: 18 additions & 0 deletions lib/interviewer/behaviours/AssetMetaProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useSelector } from 'react-redux';
import { getAssetManifest } from '../selectors/protocol';

const AssetMetaProvider = ({ children, assetId }) => {
const codebookAssets = useSelector((state) => getAssetManifest(state));

const asset = codebookAssets[assetId];

if (!codebookAssets) {
// eslint-disable-next-line no-console
console.log('error loading asset!', assetId);
return null;
}

return children(asset);
}

export default AssetMetaProvider;
Loading
Loading