Skip to content

Commit

Permalink
Sharing permissions and custom configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola authored Sep 18, 2022
2 parents 66f022f + 6243a85 commit b2e0fcb
Show file tree
Hide file tree
Showing 56 changed files with 2,162 additions and 1,822 deletions.
13 changes: 4 additions & 9 deletions cypress/e2e/features/files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@ describe('Upload a file modal in Dashboard', () => {
it('Good number of buttons after upload', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(fixtureFile);
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 13);
});

it('Good number of buttons after closing modal', () => {
cy.get('#ipc-modal-close-button').click();
cy.get('button').should('have.length', 18);
cy.wait(20000);
cy.get('button').should('have.length', 19);
});

it('Good number of buttons after failed upload', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(emptyFixtureFile, { allowEmpty: true });
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 20);
cy.wait(20000);
cy.get('button').should('have.length', 21);
});
});

Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/features/programs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('Deploy a program modal for Dashboard', () => {
it('Good number of buttons after deployment', () => {
cy.get('#ipc-dashboard-deploy-program').attachFile(fixtureFile);
cy.get('#ipc-dashboard-deploy-program-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 12);
cy.wait(20000);
cy.get('button').should('have.length', 14);
});

it('Good number of buttons after closing modal', () => {
cy.get('#ipc-modal-close-button').click();
cy.get('button').should('have.length', 11);
cy.get('button').should('have.length', 12);
});
});
6 changes: 3 additions & 3 deletions cypress/e2e/front/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Good Upload file modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('Good Deploy program modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Good Create folder modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"aleph-sdk-ts": "^2.2.2",
"archiver": "^5.3.1",
"axios": "^0.27.2",
"crypto-js": "^4.1.1",
"eth-crypto": "^2.3.0",
Expand All @@ -28,6 +27,7 @@
"react-dom": "^17.0.2",
"react-icons": "^4.4.0",
"typescript": "^4.7.4",
"uuid": "^8.3.2",
"web3": "^1.7.5"
},
"scripts": {
Expand Down Expand Up @@ -58,6 +58,7 @@
"@types/node": "^12.20.15",
"@types/react": "^17.0.11",
"@types/react-dom": "^17.0.8",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"cypress": "^10.4.0",
Expand Down
52 changes: 29 additions & 23 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { useEffect, useState } from 'react';
import Head from 'next/head';
import { AppProps } from 'next/app';
import { SessionProvider } from 'next-auth/react';
import { AppProps } from 'next/app';
import Head from 'next/head';
import { useEffect, useState } from 'react';

import { ChakraProvider, Center, Spinner, useToast } from '@chakra-ui/react';
import { Center, ChakraProvider, ColorModeScript, Spinner, useToast } from '@chakra-ui/react';

import theme from 'theme';
import 'theme/index.css';

import User from 'lib/user';
import Auth from 'lib/auth';
import type { IPCFile, IPCFolder, IPCContact } from 'types/types';
import User from 'lib/user';

import { IPCConfig, IPCContact, IPCFile, IPCFolder } from 'types/types';

import UserContext from 'contexts/user';
import AuthContext from 'contexts/auth';
import ConfigContext from 'contexts/config';
import DriveContext from 'contexts/drive';
import UserContext from 'contexts/user';

const App = ({ Component, pageProps: { session, ...pageProps } }: AppProps) => {
const [auth, setAuth] = useState<Auth | undefined>(undefined);
const [user, setUser] = useState<User | undefined>(undefined);
const [config, setConfig] = useState<IPCConfig | undefined>(undefined);
const [error, setError] = useState<Error | unknown>(undefined);
const [files, setFiles] = useState<IPCFile[]>([]);
const [folders, setFolders] = useState<IPCFolder[]>([]);
Expand Down Expand Up @@ -66,24 +69,27 @@ const App = ({ Component, pageProps: { session, ...pageProps } }: AppProps) => {
<link rel="icon" href="/ipc-logo.svg" />
</Head>
<ChakraProvider theme={theme} resetCSS>
<ColorModeScript initialColorMode={theme.config.initialColorMode} />
<AuthContext.Provider value={auth}>
<UserContext.Provider value={{ user: user as User, setUser }}>
<DriveContext.Provider
value={{
files,
setFiles,
folders,
setFolders,
contacts,
setContacts,
path,
setPath,
}}
>
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
</DriveContext.Provider>
<ConfigContext.Provider value={{ config: config as IPCConfig, setConfig }}>
<DriveContext.Provider
value={{
files,
setFiles,
folders,
setFolders,
contacts,
setContacts,
path,
setPath,
}}
>
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
</DriveContext.Provider>
</ConfigContext.Provider>
</UserContext.Provider>
</AuthContext.Provider>
</ChakraProvider>
Expand Down
1 change: 1 addition & 0 deletions pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import NextAuth from 'next-auth';
import GithubProvider from 'next-auth/providers/github';

import { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } from 'config/constants';

export default NextAuth({
Expand Down
2 changes: 1 addition & 1 deletion pages/api/computing/github/repositories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import axios from 'axios';

export default async (req: NextApiRequest, res: NextApiResponse): Promise<void> => {
const session = await getSession({ req });
Expand Down
13 changes: 7 additions & 6 deletions pages/api/program/create.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import Joi from 'joi';
import type { NextApiRequest, NextApiResponse } from 'next';
import { createRouter } from 'next-connect';
import Joi from 'joi';

import validate from 'lib/middlewares/validation';
// import { clone, cleanup, getProgramName } from 'lib/services/git'; for future use
import { clone, getProgramName } from 'lib/services/git';
import { compress, programPublish } from 'lib/services/deploy';
import { clone, getProgramName } from 'lib/services/git';

const router = createRouter<NextApiRequest, NextApiResponse>();

const postSchema = Joi.object({
// eslint-disable-next-line no-useless-escape
repository: Joi.string().pattern(/((git|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:\/\-~]+)(\.git)(\/)?/),
entrypoint: Joi.string(),
});

router.post(validate({ body: postSchema }), async (req, res) => {
const { repository } = req.body;
const { repository, entrypoint } = req.body;
let itemHash = '';
await clone(repository).then(async (path: string) => {
const fileName: string = await compress(path);
itemHash = await programPublish(fileName);
itemHash = await programPublish(fileName, entrypoint);
// await cleanup(GITCLONE_DIR);
});
return res.status(200).json({ name: getProgramName(repository), item_hash: itemHash });
return res.status(200).json({ name: getProgramName(repository), item_hash: itemHash, entrypoint });
});

export default router.handler();
Loading

0 comments on commit b2e0fcb

Please sign in to comment.