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

Permissions on shared files #92

Merged
merged 23 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b20511f
feat: starting implement InterPlanetaryCloud config
ZerLock Aug 15, 2022
66f022f
Folders, GitHub deploy and OAuth & UI refactoring
RezaRahemtola Aug 16, 2022
146eb87
feat: added change background color with config and save if we reload…
Alex-Prevot Aug 23, 2022
9fc91db
feat: added dark mod
Alex-Prevot Aug 31, 2022
cb7f5d2
feat: added design dark mode
Alex-Prevot Sep 2, 2022
7ba2fc7
feat: added design dark mode
Alex-Prevot Sep 2, 2022
5f45a05
build(deps): bump jose from 4.8.3 to 4.9.3
dependabot[bot] Sep 16, 2022
1f5c77f
feat: program configs
ZerLock Aug 29, 2022
6f06a43
feat: custom name + custom entrypoint works
ZerLock Aug 29, 2022
b4f9055
feat: refactor duplicate code
ZerLock Sep 8, 2022
8f37776
fix: linter
ZerLock Sep 16, 2022
8f74b4f
feat: Programs configuration
RezaRahemtola Sep 18, 2022
7977e16
feat: Sharing permissions selector
RezaRahemtola Aug 14, 2022
572787b
fix: Imports order
RezaRahemtola Aug 20, 2022
3528777
feat: Notification receiver for sharing updates
RezaRahemtola Aug 20, 2022
b7a2ffa
feat: Searching using ids instead of hashes
RezaRahemtola Aug 20, 2022
de0cba2
fix: account type and useless await removed
RezaRahemtola Aug 29, 2022
b21c648
feat: Edit filename feature
RezaRahemtola Sep 8, 2022
d29ae2c
feat: Permission to update file content
RezaRahemtola Sep 13, 2022
92e6d9b
feat: Delete shared files and tests fixed
RezaRahemtola Sep 16, 2022
1477651
fix: merge conflicts
RezaRahemtola Sep 18, 2022
87fa0f0
Merge branch 'feat/permissions' into dependabot/npm_and_yarn/jose-4.9.3
RezaRahemtola Sep 18, 2022
64f97d7
build(deps): bump jose from 4.8.3 to 4.9.3
RezaRahemtola Sep 18, 2022
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
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