Skip to content

Commit

Permalink
feat: redirects to account for profile (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia authored Nov 9, 2023
1 parent dd4ac5b commit 06887c7
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
VITE_VERSION: ${{ github.sha }}
VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }}
VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }}
VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }}
VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }}
VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }}
VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }}
VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
VITE_VERSION: ${{ github.event.client_payload.tag }}
VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }}
VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }}
VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }}
VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }}
VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }}
VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }}
VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
VITE_VERSION: ${{ github.event.client_payload.tag }}
VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }}
VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }}
VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }}
VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }}
VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }}
VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }}
VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }}
VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }}
VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }}
Expand Down
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default defineConfig({
API_HOST: process.env.VITE_GRAASP_API_HOST || 'http://localhost:3000',
AUTHENTICATION_HOST:
process.env.VITE_GRAASP_AUTH_HOST || 'http://localhost:3001',
ACCOUNT_HOST:
process.env.VITE_GRAASP_ACCOUNT_HOST || 'http://localhost:3114',
},
e2e: {
baseUrl: `http://localhost:${process.env.VITE_PORT || 3112}`,
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
HEADER_MEMBER_MENU_SEE_PROFILE_BUTTON_ID,
HEADER_MEMBER_MENU_SIGN_OUT_BUTTON_ID,
} from '../../src/config/selectors';
import { MEMBER_PROFILE_PATH, SIGN_IN_PATH } from '../support/constants';
import { SIGN_IN_PATH } from '../support/constants';

// catch hook warning from react
Cypress.on('uncaught:exception', (err) => {
Expand All @@ -25,7 +25,7 @@ describe('Header', () => {
cy.get(`#${HEADER_MEMBER_MENU_BUTTON_ID}`).click();
cy.get(`#${HEADER_MEMBER_MENU_SEE_PROFILE_BUTTON_ID}`).click();
cy.wait('@goToMemberProfile');
cy.url().should('equal', MEMBER_PROFILE_PATH);
cy.url().should('contain', Cypress.env('ACCOUNT_HOST'));
});

// todo: not available currently because cookie is httpOnly
Expand Down
4 changes: 0 additions & 4 deletions cypress/support/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { buildSignInPath } from '@graasp/sdk';
// eslint-disable-next-line import/prefer-default-export
export const LOAD_FOLDER_CONTENT_PAUSE = 2000;

export const MEMBER_PROFILE_PATH = `${Cypress.env(
'GRAASP_COMPOSE_HOST',
)}/profile`;

export const SIGN_IN_PATH = buildSignInPath({
host: Cypress.env('AUTHENTICATION_HOST'),
});
6 changes: 1 addition & 5 deletions cypress/support/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ import {
parseStringToRegExp,
} from './utils';

export const MEMBER_PROFILE_PATH = `${Cypress.env(
'GRAASP_COMPOSE_HOST',
)}/profile`;

const {
buildDownloadFilesRoute,
buildGetItemChatRoute,
Expand Down Expand Up @@ -577,7 +573,7 @@ export const mockProfilePage = (): void => {
cy.intercept(
{
method: DEFAULT_GET.method,
url: MEMBER_PROFILE_PATH,
url: Cypress.env('ACCOUNT_HOST'),
},
({ reply }) => {
reply(redirectionReply);
Expand Down
2 changes: 0 additions & 2 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const DESCRIPTION_MAX_LENGTH = 130;
// TODO: SIGN_IN_PATH should be clearly typed as an URL object to avoid confusion with routes
export const SIGN_IN_PATH = buildSignInPath({ host: AUTHENTICATION_HOST });

export const MEMBER_PROFILE_PATH = `${GRAASP_BUILDER_HOST}/profile`;

export const HOST_MAP = {
[Context.Builder]: GRAASP_BUILDER_HOST,
[Context.Library]: GRAASP_LIBRARY_HOST,
Expand Down
3 changes: 3 additions & 0 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const GRAASP_BUILDER_HOST =
export const GRAASP_LIBRARY_HOST =
import.meta.env.VITE_GRAASP_LIBRARY_HOST || 'http://localhost:3005';

export const GRAASP_ACCOUNT_HOST =
import.meta.env.VITE_GRAASP_ACCOUNT_HOST || 'http://localhost:3114';

export const GRAASP_ANALYTICS_HOST =
import.meta.env.VITE_GRAASP_ANALYTICS_HOST || 'http://localhost:3012';

Expand Down
4 changes: 4 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ interface ImportMetaEnv {
readonly VITE_PORT: number;
readonly VITE_SHOW_NOTIFICATIONS: string;
readonly VITE_GRAASP_AUTH_HOST: string;
readonly VITE_GRAASP_BUILDER_HOST: string;
readonly VITE_GRAASP_LIBRARY_HOST: string;
readonly VITE_GRAASP_ACCOUNT_HOST: string;
readonly VITE_GRAASP_AUTH_HOST: string;
readonly VITE_GRAASP_H5P_INTEGRATION_URL: string;
readonly VITE_SENTRY_ENV: string;
readonly VITE_SENTRY_DSN: string;
Expand Down
5 changes: 3 additions & 2 deletions src/modules/userSwitch/UserSwitchWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { CompleteMember } from '@graasp/sdk';
import { UserSwitchWrapper as GraaspUserSwitch } from '@graasp/ui';

import { MEMBER_PROFILE_PATH, SIGN_IN_PATH } from '@/config/constants';
import { SIGN_IN_PATH } from '@/config/constants';
import { GRAASP_ACCOUNT_HOST } from '@/config/env';
import { mutations } from '@/config/queryClient';
import {
HEADER_MEMBER_MENU_BUTTON_ID,
Expand Down Expand Up @@ -44,7 +45,7 @@ const UserSwitchWrapper = ({
currentMember={member}
userMenuItems={[]}
isCurrentMemberLoading={isLoading}
profilePath={MEMBER_PROFILE_PATH}
profilePath={GRAASP_ACCOUNT_HOST}
redirectPath={redirectUrl.toString()}
buttonId={HEADER_MEMBER_MENU_BUTTON_ID}
signInMenuItemId={HEADER_MEMBER_MENU_SIGN_IN_BUTTON_ID}
Expand Down

0 comments on commit 06887c7

Please sign in to comment.