Skip to content

Commit

Permalink
modifying frontend to run on any path passed as env vars during build (
Browse files Browse the repository at this point in the history
…#2983)

* modifying frontend to run on any path passed as env vars during build

Signed-off-by: arkajyotiMukherjee <[email protected]>

* Fixed image paths and routing (#2)

* image paths changed from / to ./

Signed-off-by: arkajyotiMukherjee <[email protected]>

* reloading fix by considering the subPath when routing on project check

Signed-off-by: arkajyotiMukherjee <[email protected]>

* fixed more src from / to ./

Signed-off-by: arkajyotiMukherjee <[email protected]>
  • Loading branch information
arkajyotiMukherjee authored Jul 12, 2021
1 parent e328553 commit 0c3bad3
Show file tree
Hide file tree
Showing 72 changed files with 208 additions and 180 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,27 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push frontend docker image
- name: Push frontend docker image (/)
env:
FRONTEND_IMAGE: ${FRONTEND_IMAGE}
IMG_TAG: ${IMG_TAG}
PLATFORMS: ${{ secrets.PLATFORMS }}
REPONAME: ${{ secrets.REPONAME }}
timestamp: ${timestamp}
PUBLIC_URL: ""
run: |
source env-vars
timestamp=`date "+%s"`
make push-frontend
- name: Push frontend docker image (/litmuschaos)
env:
FRONTEND_IMAGE: ${FRONTEND_IMAGE}-path-litmuschaos
IMG_TAG: ${IMG_TAG}
PLATFORMS: ${{ secrets.PLATFORMS }}
REPONAME: ${{ secrets.REPONAME }}
timestamp: ${timestamp}
PUBLIC_URL: "/litmuschaos"
run: |
source env-vars
timestamp=`date "+%s"`
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ _vendor-*
tmp/
.env
litmus-portal-service
litmus-portal-app
litmus-portal-app

**/client_id
6 changes: 3 additions & 3 deletions litmus-portal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ buildx.push.image:
buildx.push.frontend:
@cd frontend && \
if [ "${IMG_TAG}" = "ci" ]; then \
docker build . -f Dockerfile -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) --build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x" --build-arg TARGETARCH=amd64;\
docker build . -f Dockerfile -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) --build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x" --build-arg PUBLIC_URL="$(PUBLIC_URL)" --build-arg TARGETARCH=amd64;\
docker push $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG);\
else \
docker buildx build . -f Dockerfile --progress plane --push --no-cache --platform $(PLATFORMS) -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) \
docker buildx build . -f Dockerfile --progress plane --push --no-cache --platform $(PLATFORMS) -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) --build-arg PUBLIC_URL="$(PUBLIC_URL)" \
--build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x";\
fi

Expand All @@ -135,6 +135,6 @@ push-frontend-amd64: docker-build-frontend-amd64 docker-push-frontend-amd64
docker-build-frontend-amd64:
@cd frontend && \
docker build . -f Dockerfile -t $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) --build-arg TARGETARCH=amd64 --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) \
--build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x
--build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg PUBLIC_URL="$(PUBLIC_URL)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x
docker-push-frontend-amd64:
@docker push $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG)
1 change: 1 addition & 0 deletions litmus-portal/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG TARGETARCH
ARG REACT_APP_KB_CHAOS_VERSION
ARG REACT_APP_BUILD_TIME
ARG REACT_APP_HUB_BRANCH_NAME
ARG PUBLIC_URL

# Checking environment variables
RUN env
Expand Down
1 change: 0 additions & 1 deletion litmus-portal/frontend/client_id

This file was deleted.

1 change: 0 additions & 1 deletion litmus-portal/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "litmus-portal",
"version": "0.1.0",
"homepage": "https://litmus-portal.com",
"scripts": {
"start": "react-scripts start",
"build": "cross-env NODE_PATH=src react-scripts build",
Expand Down
2 changes: 1 addition & 1 deletion litmus-portal/frontend/public/browserconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<square150x150logo src="./mstile-150x150.png"/>
<TileColor>#ffc40d</TileColor>
</tile>
</msapplication>
Expand Down
2 changes: 1 addition & 1 deletion litmus-portal/frontend/public/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.root {
background: #f5f6f8;
font-family: 'Ubuntu', sans-serif;
font-family: 'Inter', 'Ubuntu', sans-serif;
}

.loaderContainer {
Expand Down
6 changes: 3 additions & 3 deletions litmus-portal/frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<base href="%PUBLIC_URL%/" />
<meta
name="viewport"
content="user-scalable=0, initial-scale=1, minimum-scale=1, width=device-width, height=device-height"
Expand All @@ -14,7 +15,7 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="React App" />
<link rel="apple-touch-icon" href="./favicon.ico" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.ico" />
<!-- End of: Add to home screen for Safari on iOS -->
<!-- Start of: Add to home screen on Windows -->
<meta name="msapplication-TileImage" content="./favicon.ico" />
Expand All @@ -26,7 +27,7 @@
<link
rel="apple-touch-icon"
sizes="152x152"
href="./apple-touch-icon.png"
href="%PUBLIC_URL%/apple-touch-icon.png"
/>

<link rel="manifest" href="%PUBLIC_URL%/site.webmanifest" />
Expand All @@ -38,7 +39,6 @@
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap" rel="stylesheet">
<title>Litmus Portal</title>
</head>

Expand Down
6 changes: 3 additions & 3 deletions litmus-portal/frontend/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"short_name": "Litmus Portal",
"icons": [
{
"src": "/favicon-16x16.png",
"src": "./favicon-16x16.png",
"sizes": "16x16",
"type": "image/png"
},
{
"src": "/favicon-32x32.png",
"src": "./favicon-32x32.png",
"sizes": "16x16",
"type": "image/png"
},
{
"src": "/android-chrome-144x144.png",
"src": "./android-chrome-144x144.png",
"sizes": "144x144",
"type": "image/png"
}
Expand Down
4 changes: 2 additions & 2 deletions litmus-portal/frontend/src/ReduxRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import createApolloClient from './utils/createApolloClient';
const { persistor, store } = configureStore();

const client = createApolloClient(
`${config.grahqlEndpoint}/query`,
`${config.grahqlEndpointSubscription}/query`
config.grahqlEndpoint,
config.grahqlEndpointSubscription
);

const ReduxRoot = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AdjustedWeights: React.FC<AdjustedWeightsProps> = ({
{icon ? (
<div style={{ display: 'flex' }}>
<img
src="/icons/experimentDetails.svg"
src="./icons/experimentDetails.svg"
alt="experiment details icon"
className={classes.experimentIcon}
/>
Expand All @@ -51,7 +51,7 @@ const AdjustedWeights: React.FC<AdjustedWeightsProps> = ({
{icon ? (
<span>
<img
src="/icons/experimentDetails.svg"
src="./icons/experimentDetails.svg"
alt="experiment details icon"
className={classes.experimentIcon}
/>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BackButton: React.FC<IconButtonProps> = ({ onClick }) => {
className={classes.btn}
onClick={onClick ?? (() => history.goBack())}
>
<img src="/icons/back.svg" alt="back" />
<img src="./icons/back.svg" alt="back" />
<Typography className={classes.text}>{t('button.backButton')}</Typography>
</IconButton>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Typography, IconButton } from '@material-ui/core';
import * as React from 'react';
import { IconButton, Typography } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import * as React from 'react';
import useStyles from './styles';

interface DeveloperGuideProps {
Expand Down Expand Up @@ -34,7 +34,7 @@ const DeveloperGuide: React.FC<DeveloperGuideProps> = ({
</Typography>
{expAvailable ? (
<div className={classes.imgDiv}>
<img src="/icons/guide.svg" alt="dev_guide" />
<img src="./icons/guide.svg" alt="dev_guide" />
<a href={docs} className={classes.guideLink} target="_">
Developer&#39;s guide
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { getProjectID } from '../../utils/getSearchParams';
import Loader from '../Loader';
import useStyles from './styles';

interface otherProjectsType {
type OtherProjectsType = {
projectDetails: Project;
currentUserProjectRole: string;
}
};

interface CustomisedListItemProps {
handleClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
Expand Down Expand Up @@ -66,9 +66,9 @@ const CustomisedListItem: React.FC<CustomisedListItemProps> = ({
>
<ListItemIcon>
{selected ? (
<img src="/icons/selectedProject.svg" alt="Selected Project" />
<img src="./icons/selectedProject.svg" alt="Selected Project" />
) : (
<img src="/icons/nonSelectedproject.svg" alt="Un-selected Project" />
<img src="./icons/nonSelectedproject.svg" alt="Un-selected Project" />
)}
</ListItemIcon>
<ListItemText
Expand All @@ -82,7 +82,7 @@ const CustomisedListItem: React.FC<CustomisedListItemProps> = ({
aria-label="copyProject"
>
{!copying ? (
<img src="/icons/copyProjectID.svg" alt="Copy project ID" />
<img src="./icons/copyProjectID.svg" alt="Copy project ID" />
) : (
<DoneIcon />
)}
Expand All @@ -98,17 +98,19 @@ const ProjectDropdownItems: React.FC = () => {
const { data, loading } = useQuery<Projects>(LIST_PROJECTS);
const projects = data?.listProjects ?? [];

const baseRoute = window.location.pathname.split('/')[1];
const baseRoute = window.location.pathname
.replace(process.env.PUBLIC_URL, '')
.split('/')[1];

const userID = getUserId();
const projectID = getProjectID();

const [myProjects, setMyProjects] = useState<Project[]>([]);
const [otherProjects, setOtherProjects] = useState<otherProjectsType[]>([]);
const [otherProjects, setOtherProjects] = useState<OtherProjectsType[]>([]);

useEffect(() => {
const projectOwner: Project[] = [];
const projectOther: otherProjectsType[] = [];
const projectOther: OtherProjectsType[] = [];

projects.map((project) => {
return project.members.forEach((member: Member) => {
Expand Down
2 changes: 1 addition & 1 deletion litmus-portal/frontend/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Header: React.FC = () => {
>
<div className={classes.litmusDiv}>
<img
src="/icons/litmusPurple.svg"
src="./icons/litmusPurple.svg"
alt="litmus logo"
className={classes.logo}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const InfoTooltip: React.FC<InfoTooltipProps> = ({ value, className }) => {
onClick={handleTooltipOpen}
>
<img
src="/icons/info.svg"
src="./icons/info.svg"
className={classes.infoImg}
alt="info tooltip"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from 'react';
import { OutlinedInputProps, TextField } from '@material-ui/core';
import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment';
import AccountCircle from '@material-ui/icons/AccountCircle';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import React, { useState } from 'react';
import { useStyles, useStylesLitmus } from './styles';

interface InputFieldOutlineProps {
Expand Down Expand Up @@ -246,7 +246,7 @@ const InputFieldOutline: React.FC<InputFieldOutlineProps> = ({
disableUnderline: true,
endAdornment: (
<InputAdornment position="end">
<img src="/icons/closeFilled.svg" alt="Error" />
<img src="./icons/closeFilled.svg" alt="Error" />
</InputAdornment>
),
} as Partial<OutlinedInputProps>
Expand Down Expand Up @@ -309,7 +309,7 @@ const InputFieldOutline: React.FC<InputFieldOutlineProps> = ({
),
endAdornment: (
<InputAdornment position="end">
<img src="/icons/closeFilled.svg" alt="Error" />
<img src="./icons/closeFilled.svg" alt="Error" />
</InputAdornment>
),
} as Partial<OutlinedInputProps>
Expand Down
4 changes: 2 additions & 2 deletions litmus-portal/frontend/src/components/InstallChaos/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Typography } from '@material-ui/core';
import Done from '@material-ui/icons/DoneAllTwoTone';
import { ButtonOutlined } from 'litmus-ui';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ButtonOutlined } from 'litmus-ui';
import useStyles from './styles';

interface InstallProps {
Expand Down Expand Up @@ -50,7 +50,7 @@ const InstallChaos: React.FC<InstallProps> = ({
{!copying ? (
<div className={classes.rowDiv}>
<img
src="/icons/copy.svg"
src="./icons/copy.svg"
className={classes.copyBtnImg}
alt="copy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const LocalQuickActionCard: React.FC<LocalQuickActionCardProps> = ({
: emptyData,
returningHome
? {
src: '/icons/calendarWorkflowIcon.svg',
src: './icons/calendarWorkflowIcon.svg',
alt: 'workflow',
onClick: () =>
history.push({
Expand All @@ -60,7 +60,7 @@ const LocalQuickActionCard: React.FC<LocalQuickActionCardProps> = ({
: emptyData,
homePage || returningHome || analytics
? {
src: '/icons/target.svg',
src: './icons/target.svg',
alt: 'agent',
onClick: () =>
history.push({
Expand All @@ -75,7 +75,7 @@ const LocalQuickActionCard: React.FC<LocalQuickActionCardProps> = ({
(homePage || returningHome || community || analytics) &&
getProjectRole() === Role.owner
? {
src: '/icons/teamMember.svg',
src: './icons/teamMember.svg',
alt: 'team',
onClick: () => {
tabs.changeSettingsTabs(1);
Expand All @@ -89,15 +89,15 @@ const LocalQuickActionCard: React.FC<LocalQuickActionCardProps> = ({
: emptyData,
homePage || community
? {
src: '/icons/survey.svg',
src: './icons/survey.svg',
alt: 'survey',
onClick: () => window.open(constants.FeedbackForm),
text: t('quickActionCard.quickSurvey'),
}
: emptyData,
homePage || community || analytics
? {
src: '/icons/docs.svg',
src: './icons/docs.svg',
alt: 'docs',
onClick: () =>
window.open('https://docs.litmuschaos.io/docs/getstarted'),
Expand Down
Loading

0 comments on commit 0c3bad3

Please sign in to comment.