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

Release #2898

Merged
merged 8 commits into from
Aug 14, 2024
Merged

Release #2898

Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions .github/CONTRIBUTING.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contributing to Ever Teams Platform

We would love for you to contribute to Ever Teams Platform!

## Submitting Pull Requests

If you're changing the structure of the repository please create an issue first.

By default, when you submitting contributions with Pull Requests, we require electronic submission of individual [Contributor Assignment Agreement (CAA)](https://gist.github.com/evereq/95f74ae09510766ffa9379006715ccfd). In some cases (when contributions are very small, at our discretion) instead of CAA we may accept submission of individual [Contributor License Agreement (CLA)](https://gist.github.com/evereq/53ddec283243481344fb61df1706ec40).

If you submitting contribution on behalf of some legal entity, you need to submit Entity Contributor Assignment Agreement (CAA) or Entity Contributor License Agreement (CLA), which you can request by sending us an email to <[email protected]>.

We are using open-source [CLA assistant](https://github.com/cla-assistant/cla-assistant) project to collect your signatures on CAA.
The templates for our CAA/CLA documents generated by <http://www.harmonyagreements.org>.

## Submitting bug reports

Make sure you are on latest changes.
If you can, please provide more information about your environment such as browser, operating system, node version, and yarn version.

## Feature requests

You are more than welcome to submit future requests here <https://github.com/ever-co/feature-requests/issues>

## Legal

This is an open source project.
Contributions you make to this public Gauzy Platform repository are completely voluntary.
When you submit an issue, bug report, question, enhancement, pull request, etc., you are offering your contribution without expectation of payment, you expressly waive any future pay claims against the Ever Co. LTD related to your contribution, and you acknowledge that this does not create an obligation on the part of the Ever Co. LTD of any kind. Furthermore, your contributing to this project does not create an employer-employee relationship between the Ever Co. LTD and the contributor.

See also "Submitting Pull Requests" section above for more information on CAA/CLA, required for any contributions.
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Description

Please include a summary of the changes and the related issue.

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

## Previous screenshots

Please add here videos or images of previous status

## Current screenshots

Please add here videos or images of previous status
18 changes: 12 additions & 6 deletions apps/web/app/[locale]/auth/passcode/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ function AuthPasscode() {
{form.authScreen.screen === 'workspace' && (
<WorkSpaceScreen form={form} className={clsxm('w-full')} />
)}
</div>
{/* Social logins */}
</div>
<SocialLogins />
</div>
</AuthLayout>
Expand Down Expand Up @@ -325,6 +324,8 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPasscode }
[selectedWorkspace, selectedTeam, form]
);

const lastSelectedTeamFromAPI = form.getLastTeamIdWithRecentLogout();

useEffect(() => {
if (form.workspaces.length === 1) {
setSelectedWorkspace(0);
Expand All @@ -335,7 +336,11 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPasscode }
if (form.workspaces.length === 1 && currentTeams?.length === 1) {
setSelectedTeam(currentTeams[0].team_id);
} else {
const lastSelectedTeam = window.localStorage.getItem(LAST_WORSPACE_AND_TEAM) || currentTeams[0]?.team_id;
const lastSelectedTeam =
window.localStorage.getItem(LAST_WORSPACE_AND_TEAM) ||
lastSelectedTeamFromAPI ||
form.defaultTeamId ||
currentTeams[0]?.team_id;
const lastSelectedWorkspace =
form.workspaces.findIndex((workspace) =>
workspace.current_teams.find((team) => team.team_id === lastSelectedTeam)
Expand All @@ -349,7 +354,7 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPasscode }
document.getElementById('continue-to-workspace')?.click();
}, 100);
}
}, [form.workspaces]);
}, [form.defaultTeamId, form.workspaces, lastSelectedTeamFromAPI]);

useEffect(() => {
if (form.authScreen.screen === 'workspace') {
Expand Down Expand Up @@ -423,8 +428,9 @@ export function WorkSpaceComponent(props: IWorkSpace) {
{props.workspaces?.map((worksace, index) => (
<div
key={index}
className={`w-full flex flex-col border border-[#0000001A] dark:border-[#34353D] ${props.selectedWorkspace === index ? 'bg-[#FCFCFC] dark:bg-[#1F2024]' : ''
} hover:bg-[#FCFCFC] dark:hover:bg-[#1F2024] rounded-xl`}
className={`w-full flex flex-col border border-[#0000001A] dark:border-[#34353D] ${
props.selectedWorkspace === index ? 'bg-[#FCFCFC] dark:bg-[#1F2024]' : ''
} hover:bg-[#FCFCFC] dark:hover:bg-[#1F2024] rounded-xl`}
>
<div className="text-base font-medium py-[1.25rem] px-4 flex flex-col gap-[1.0625rem]">
<div className="flex justify-between">
Expand Down
5 changes: 4 additions & 1 deletion apps/web/app/[locale]/auth/password/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPassword }
[selectedWorkspace, selectedTeam, form]
);

const lastSelectedTeamFromAPI = form.getLastTeamIdWithRecentLogout();

const hasMultipleTeams = useMemo(
() => form.workspaces.some((workspace) => workspace.current_teams.length > 1),
[form.workspaces]
Expand All @@ -129,7 +131,8 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPassword }
}

const currentTeams = form.workspaces.find((el) => el.current_teams && el.current_teams.length)?.current_teams;
const lastSelectedTeamId = window.localStorage.getItem(LAST_WORSPACE_AND_TEAM);
const lastSelectedTeamId =
window.localStorage.getItem(LAST_WORSPACE_AND_TEAM) || lastSelectedTeamFromAPI || form.defaultTeamId;

if (currentTeams) {
setSelectedWorkspace(
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/[locale]/integration/github/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const GitHub = () => {
const searchParams = useSearchParams();
const installation_id = searchParams?.get('installation_id');
const setup_action = searchParams?.get('setup_action');
const initialLoad = useRef<boolean>(false);

const t = useTranslations();

Expand Down Expand Up @@ -49,15 +50,17 @@ const GitHub = () => {
}, [integrationTenantLoading, integrationTenant, getRepositories]);

useEffect(() => {
if (!loadingIntegrationTypes && integrationTypes.length === 0) {
if (!loadingIntegrationTypes && integrationTypes.length === 0 && !initialLoad.current) {
initialLoad.current = true;

getIntegrationTypes().then((types) => {
const allIntegrations = types.find((item: any) => item.name === 'All Integrations');
if (allIntegrations && allIntegrations?.id) {
getIntegrationTenant('Github');
}
});
}
}, [loadingIntegrationTypes, integrationTypes, getIntegrationTypes, getIntegrationTenant]);
}, [loadingIntegrationTypes, integrationTypes, getIntegrationTypes, getIntegrationTenant, initialLoad]);

return (
<div className="flex flex-col p-3">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[locale]/page-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function MainPage() {
React.useEffect(() => {
window && window?.localStorage.getItem('conf-fullWidth-mode');
setFullWidth(JSON.parse(window?.localStorage.getItem('conf-fullWidth-mode') || 'true'));
}, [fullWidth, setFullWidth]);
}, [setFullWidth]);

if (!online) {
return <Offline />;
Expand Down
8 changes: 5 additions & 3 deletions apps/web/app/api/auth/_signin-workspace/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
verifyInviteCodeRequest
} from '@app/services/server/requests';
import { generateToken, setAuthCookies, setNoTeamPopupShowCookie } from '@app/helpers';
import { ILoginResponse } from '@app/interfaces';
import { ILoginResponse, IOrganizationTeam } from '@app/interfaces';
import { NextResponse } from 'next/server';

export async function POST(req: Request) {
Expand All @@ -19,6 +19,8 @@ export async function POST(req: Request) {
token: string;
teamId: string;
code: string;
defaultTeamId?: IOrganizationTeam['id'];
lastTeamId?: IOrganizationTeam['id'];
};
let loginResponse: ILoginResponse | null = null;

Expand Down Expand Up @@ -134,8 +136,8 @@ export async function POST(req: Request) {
return NextResponse.json({ team, loginResponse });
}
// Accept Invite Flow End

const { data } = await signInWorkspaceRequest(body.email, body.token);
const { email, token, defaultTeamId, lastTeamId } = body;
const { data } = await signInWorkspaceRequest({ email, token, defaultTeamId, lastTeamId });

/**
* Get the first team from first organization
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/api/auth/signin-workspace/signin-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
verifyInviteCodeRequest
} from '@app/services/server/requests';
import { generateToken, setAuthCookies, setNoTeamPopupShowCookie } from '@app/helpers';
import { ILoginResponse } from '@app/interfaces';
import { ILoginResponse, IOrganizationTeam } from '@app/interfaces';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== 'POST') {
Expand All @@ -20,6 +20,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
token: string;
teamId: string;
code: string;
defaultTeamId?: IOrganizationTeam['id'];
lastTeamId?: IOrganizationTeam['id'];
};

const { errors, valid: formValid } = authFormValidate(['email'], body as any);
Expand Down Expand Up @@ -143,7 +145,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}

// Accept Invite Flow End
const { data } = await signInWorkspaceRequest(body.email, body.token);
const { email, token, defaultTeamId, lastTeamId } = body;
const { data } = await signInWorkspaceRequest({ email, token, defaultTeamId, lastTeamId });

/**
* Get the first team from first organization
Expand Down
39 changes: 35 additions & 4 deletions apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function useAuthenticationPasscode() {
const inputCodeRef = useRef<AuthCodeRef | null>(null);
const [screen, setScreen] = useState<'email' | 'passcode' | 'workspace'>('email');
const [workspaces, setWorkspaces] = useState<ISigninEmailConfirmWorkspaces[]>([]);
const [defaultTeamId, setDefaultTeamId] = useState<string | undefined>(undefined);
const [authenticated, setAuthenticated] = useState(false);

const [formValues, setFormValues] = useState({
Expand Down Expand Up @@ -74,7 +75,15 @@ export function useAuthenticationPasscode() {
/**
* Verify auth request
*/
const verifySignInEmailConfirmRequest = async ({ email, code }: { email: string; code: string }) => {
const verifySignInEmailConfirmRequest = async ({
email,
code,
lastTeamId
}: {
email: string;
code: string;
lastTeamId?: string;
}) => {
signInEmailConfirmQueryCall(email, code)
.then((res) => {
if ('team' in res.data) {
Expand Down Expand Up @@ -103,6 +112,7 @@ export function useAuthenticationPasscode() {

if (data && Array.isArray(data.workspaces) && data.workspaces.length > 0) {
setWorkspaces(data.workspaces);
setDefaultTeamId(data.defaultTeamId);

setScreen('workspace');
}
Expand All @@ -119,7 +129,8 @@ export function useAuthenticationPasscode() {
email: email,
code: code,
token: currentWorkspace?.token as string,
selectedTeam: queryTeamId as string
selectedTeam: queryTeamId as string,
lastTeamId
});
}
}
Expand Down Expand Up @@ -169,6 +180,8 @@ export function useAuthenticationPasscode() {
token: string;
selectedTeam: string;
code?: string;
defaultTeamId?: string;
lastTeamId?: string;
}) => {
signInWorkspaceQueryCall(params)
.then(() => {
Expand Down Expand Up @@ -234,7 +247,9 @@ export function useAuthenticationPasscode() {
email: formValues.email,
code: formValues.code,
token,
selectedTeam
selectedTeam,
defaultTeamId: selectedTeam,
lastTeamId: selectedTeam
});
};

Expand Down Expand Up @@ -270,6 +285,20 @@ export function useAuthenticationPasscode() {
return promise;
}, [formValues, signInEmailQueryCall]);

const getLastTeamIdWithRecentLogout = useCallback(() => {
if (workspaces.length === 0) {
throw new Error('No workspaces found');
}

const mostRecentWorkspace = workspaces.reduce((prev, current) => {
const prevDate = new Date(prev.user.lastLoginAt ?? '');
const currentDate = new Date(current.user.lastLoginAt ?? '');
return currentDate > prevDate ? current : prev;
});

return mostRecentWorkspace.user.lastTeamId;
}, [workspaces]);

return {
sendAuthCodeHandler,
errors,
Expand All @@ -290,9 +319,11 @@ export function useAuthenticationPasscode() {
signInEmailConfirmQueryCall,
signInEmailConfirmLoading,
workspaces,
defaultTeamId,
sendCodeQueryCall,
signInWorkspaceLoading,
handleWorkspaceSubmit
handleWorkspaceSubmit,
getLastTeamIdWithRecentLogout
};
}

Expand Down
Loading
Loading