Skip to content

Commit

Permalink
Merge pull request #26 from firecamp-io/feat/platform
Browse files Browse the repository at this point in the history
Feat/platform
  • Loading branch information
Nishchit14 committed Oct 7, 2022
2 parents 72fe2cd + 3cc6e24 commit 6959a4c
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 165 deletions.
12 changes: 12 additions & 0 deletions .env.vault
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#################################################################################
# #
# This file uniquely identifies your project in dotenv-vault. #
# You SHOULD commit this file to source control. #
# #
# Generated with 'npx dotenv-vault new' #
# #
# Learn more at https://dotenv.org/env-vault #
# #
#################################################################################

DOTENV_VAULT=vlt_a7698f74e5365a7834b9f3a62cc555169343e436f2cde5d317afa8c4adfa4eda
19 changes: 10 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ node_modules
npm-debug.log
.DS_Store

packages/indexed-db/build
build/
stageBuild/
dev/
cypress/screenshots
cypress/videos

Expand Down Expand Up @@ -91,11 +88,6 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env*

# parcel-bundler cache (https://parceljs.org/)
.cache

Expand Down Expand Up @@ -133,4 +125,13 @@ dist
!.yarn/releases/*

# Declaration files
*.d.ts
*.d.ts

# dotenv environment variables file
.env
.env.test
.env.production
.env*
.flaskenv*
!.env.project
!.env.vault
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
"scripts": {
"build:monorepo": "lerna run build --scope=@firecamp/js-executor --scope=@firecamp/rest-executor",
"start": "npx webpack serve --config ./webpack.dev.js",
"dev": "APP_VERSION=$npm_package_version RELEASE_SERVER=dev APP_FORMAT=extension && node scripts/build && npm run build:monorepo && yarn start",
"dev": "APP_VERSION=$npm_package_version AppFormat=webapp && node scripts/build && npm run build:monorepo && yarn start",
"electron": "npx electron .",
"release:web-app": "export APP_FORMAT=webapp && node scripts/release production",
"release:web-app:staging": "export APP_FORMAT=webapp && node scripts/release staging",
"release:extension": "export APP_FORMAT=extension && node scripts/release production",
"release:prod:mac-dmg": "export APP_FORMAT=dmg && node scripts/release production p",
"release:prod:linux-appImage": "export APP_FORMAT=appImage && node scripts/release production",
"release:prod:linux-snap": "export APP_FORMAT=snap && node scripts/release production p",
"release:prod:win32-nsis": "export APP_FORMAT=nsis && node scripts/release production p",
"release:canary:mac-dmg": "export APP_FORMAT=dmg && node scripts/release canary p",
"release:canary:linux-appImage": "export APP_FORMAT=appImage && node scripts/release canary p",
"release:canary:win32-nsis": "export APP_FORMAT=nsis && node scripts/release canary p",
"clean": "rimraf build/ dev/ *.zip* .crx",
"release:web-app": "AppFormat=webapp && node scripts/release production",
"release:web-app:staging": "AppFormat=webapp && node scripts/release staging",
"release:extension": "export AppFormat=extension && node scripts/release production",
"release:prod:mac-dmg": "export AppFormat=dmg && node scripts/release production p",
"release:prod:linux-appImage": "export AppFormat=appImage && node scripts/release production",
"release:prod:linux-snap": "export AppFormatode scripts/release production p",
"release:prod:win32-nsis": "export AppFormat=nsis && node scripts/release production p",
"release:canary:mac-dmg": "export AppFormatdmg && node scripts/release canary p",
"release:canary:linux-appImage": "export AppFormatappImage && node scripts/release canary p",
"release:canary:win32-nsis": "export AppFormat=nsis && node scripts/release canary p",
"clean": "rimraf build/ development/ *.zip* .crx",
"lint": "eslint packages/firecamp-rest/src/**/*.{ts|tsx} packages/*.js packages-clients/*.js scripts webpack/*.js",
"test-e2e": "cross-env NODE_ENV=test mocha -r ./test/setup-app test/e2e",
"_test": "cross-env NODE_ENV=test mocha -r ./test/setup-app test/app",
Expand Down
2 changes: 1 addition & 1 deletion packages/firecamp-core/public/views/identity.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- let publicPath = process.env.NODE_ENV === 'development' ? '/' : '/js/'
- publicPath = process.env.APP_FORMAT === 'webapp' ? './js/' : publicPath
- publicPath = process.env.AppFormat === 'webapp' ? './js/' : publicPath


doctype html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- let publicPath = process.env.NODE_ENV === 'development' ? '/' : '/js/'
- publicPath = process.env.APP_FORMAT === 'webapp' ? './js/' : publicPath
- publicPath = process.env.AppFormat === 'webapp' ? './js/' : publicPath


doctype html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import {
TextArea,
TabHeader,
Button,


Modal,
IModal,
ProgressBar,
} from '@firecamp/ui-kit';
import { _misc } from '@firecamp/utils';
import { TId } from '@firecamp/types';

import { useWorkspaceStore } from '../../../../store/workspace';
import { useRequestStore } from '../../../../store/request';
import { useModalStore } from '../../../../store/modal';
import { TId } from '@firecamp/types';
import { useWorkspaceStore } from '../../../../store/workspace'
import AppService from '../../../../services/app'

type TModalMeta = { name: string, description: string, request_id: TId, collection_id: TId };
type TModalMeta = { name: string, description: string, request_id: TId, collection_id: TId, folder_id?: TId };

const EditRequest: FC<IModal> = ({
isOpen = false,
Expand All @@ -26,7 +24,7 @@ const EditRequest: FC<IModal> = ({
width = '500px',
}) => {

const { name, description, request_id, collection_id } = useModalStore.getState().meta as TModalMeta;
const { name, description, request_id, collection_id, folder_id } = useModalStore.getState().meta as TModalMeta;
const [request, setRequest] = useState({
name,
description
Expand All @@ -40,37 +38,34 @@ const EditRequest: FC<IModal> = ({
setRequest((r) => ({ ...r, [name]: value }));
};

const onCreate = () => {
const onUpdate = () => {
if (isRequesting) return;
const name = request.name.trim();
if (!name || name.length < 3) {
setError({ name: 'The request name must have minimun 3 characters' });
setError({ name: 'The request name must have minimum 3 characters' });
return;
}
const _request = {
...request,
name,
description: request?.description?.trim(),
meta: {
name,
description: request?.description?.trim(),
},
_meta: {
id: request_id,
collection_id,
folder_id
}
};

setIsRequesting(true);
// console.log({ _request });

useRequestStore.getState().onEditRequest(_request);

// createRequest(_request)
// .then((r)=> {

// console.log(r, "r......")
// AppService.modals.close();
// })
// .catch((e)=> {
// console.log(e.response, e.response?.data)
// AppService.notify.alert(e?.response?.data?.message || e.message )
// })
// .finally(()=> {
// setIsRequesting(false);
// });
const { updateRequest } = useWorkspaceStore.getState()
updateRequest(request_id, _request)
.then((res)=> {
AppService.modals.close();
})
.finally(()=> {
setIsRequesting(false);
});
};

return (
Expand Down Expand Up @@ -134,7 +129,7 @@ const EditRequest: FC<IModal> = ({
text={isRequesting ? 'Updating...' : 'Update'}
primary
sm
onClick={onCreate}
onClick={onUpdate}
disabled={isRequesting}
/>
</TabHeader.Right>
Expand Down
18 changes: 0 additions & 18 deletions packages/firecamp-core/src/services/auth/helper.ts

This file was deleted.

36 changes: 9 additions & 27 deletions packages/firecamp-core/src/services/auth/sign-in.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Rest } from '@firecamp/cloud-apis';
import { EProvider, IAuthResponse } from './types';
import { validateAuthResponse } from './helper';
import { githubAuth, googleAuth } from './oauth2';

/**
* credentials require while sign-in using Firecamp domain
*/
/** credentials require while sign-in using Firecamp domain */
export interface ICredentials {
username: string;
password: string;
Expand All @@ -22,25 +19,16 @@ export default async (
try {
const { username = '', password = '' } = credentials;

// TODO:
// if (F.userMeta.isLoggedIn) return Promise.resolve();

switch (provider) {
case EProvider.LOCAL: {
// Request to sign-in via Firecamp domain
try {
const response = await Rest.auth.signIn(username, password);

// validate auth response
if (validateAuthResponse(response?.data)) {
return Promise.resolve({
response: response.data,
provider: EProvider.LOCAL,
});
} else
return Promise.reject({
message: 'failed to sign in into your account',
});
return Promise.resolve({
response: response.data,
provider: EProvider.LOCAL,
});
} catch (e) {
console.log(e, 'e...');
if (e.message == 'Network Error')
Expand All @@ -55,17 +43,11 @@ export default async (

// Send token to authenticate
const response = await Rest.auth.viaGoogle(token);
debugger;

if (validateAuthResponse(response?.data)) {
return Promise.resolve({
response: response.data,
provider: EProvider.GOOGLE,
});
} else
return Promise.reject({
message: 'Failed to sign-in into your account',
});
return Promise.resolve({
response: response.data,
provider: EProvider.GOOGLE,
});
}
case EProvider.GITHUB:
// Fetch auth code
Expand Down
14 changes: 4 additions & 10 deletions packages/firecamp-core/src/services/auth/sign-up.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Rest } from '@firecamp/cloud-apis';
import { EProvider, IAuthResponse } from './types';
import { validateAuthResponse } from './helper';

/**
* credentials require for sign-up using Firecamp domain
Expand All @@ -24,15 +23,10 @@ export default async ({
const response = await Rest.auth.signUp(username, email, password);

// validate auth response
if (validateAuthResponse(response?.data)) {
return Promise.resolve({
response: response.data,
provider: EProvider.LOCAL,
});
} else
return Promise.reject({
message: 'Failed to sign-up for your account',
});
return Promise.resolve({
response: response.data,
provider: EProvider.LOCAL,
});
} catch (error) {
return Promise.reject({
message: error?.data?.message
Expand Down
4 changes: 2 additions & 2 deletions packages/firecamp-core/src/store/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface IWorkspaceStore {
// request
onNewRequestCreate: (request: any) => void;
createRequest: (payload: { [k: string]: any }) => void;
updateRequest: (rId: string, payload: { [k: string]: any }) => void;
updateRequest: (rId: string, payload: { [k: string]: any }) => Promise<any>;
deleteRequest: (rId: TId) => void;

// change orders
Expand Down Expand Up @@ -568,7 +568,7 @@ export const useWorkspaceStore = create<IWorkspaceStore>(
s.explorer.tdpInstance?.updateRequestItem(request);
const requests = s.explorer.requests.map((r) => {
if (r._meta.id == request._meta.id)
r = { ...r, meta: { ...r.meta, name: request.meta.name } }; //note: this condition is used considering only renaming usecase
r = { ...r, meta: { ...r.meta, name: request.meta.name } }; //note: this condition is used considering only renaming use case
return r;
});
return { explorer: { ...s.explorer, requests } };
Expand Down
Loading

0 comments on commit 6959a4c

Please sign in to comment.