Skip to content

Commit

Permalink
Merge pull request #18 from fescobar/beta
Browse files Browse the repository at this point in the history
New Feature & Improvements
  • Loading branch information
fescobar authored Jan 18, 2021
2 parents f158af2 + b5f744b commit ce037d0
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 40 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Allure Docker UI Workflow
name: Allure Docker Service UI Workflow

on:
push:
Expand All @@ -14,7 +14,7 @@ env:
DOCKER_IMAGE: frankescobar/allure-docker-service-ui

jobs:
push:
build-release:
runs-on: ubuntu-latest
if: github.event_name == 'push'

Expand Down Expand Up @@ -46,23 +46,22 @@ jobs:
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file docker/Dockerfile .
- name: Setting up QEMU
uses: docker/setup-qemu-action@v1

- name: Setting up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v3
uses: docker/setup-buildx-action@v1
with:
buildx-version: latest
qemu-version: latest

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
version: latest

- name: Docker Building
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: DockerHub Login
if: success() && startsWith(github.ref, 'refs/tags/v')
uses: crazy-max/ghaction-docker-login@v1
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}
Expand Down
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
SECURITY_VIEWER_USER: "view_user"
SECURITY_VIEWER_PASS: "view_pass"
SECURITY_ENABLED: 1
MAKE_VIEWER_ENDPOINTS_PUBLIC: 0
#URL_PREFIX: /my-prefix
#ACCESS_TOKEN_EXPIRES_IN_SECONDS: 10
#REFRESH_TOKEN_EXPIRES_IN_SECONDS: 10
Expand Down
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ package-lock.json

/public/env-config.js
/public/config.json
.eslintcache
4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@material-ui/lab": "4.0.0-alpha.56",
"axios": "0.19.2",
"axios": "0.21.1",
"react": "16.13.1",
"react-cookie": "4.0.3",
"react-dom": "16.13.1",
"react-router-dom": "5.2.0",
"react-scripts": "3.4.3"
"react-scripts": "4.0.1"
},
"devDependencies": {},
"scripts": {
Expand Down
45 changes: 42 additions & 3 deletions ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "./App.css";
import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles";
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";

import { setViewerRole } from "./utility/user-actions";
import AllureDockerSigIn from "./components/AllureDockerSigIn/AllureDockerSigIn";
import AllureDockerMainContainer from "./containers/AllureDockerMainContainer/AllureDockerMainContainer";
import AllureDockerReportFullView from "./components/AllureDockerReportFullView/AllureDockerReportFullView";
Expand All @@ -14,6 +15,7 @@ class App extends Component {
state = {
darkState: false,
isLogoutNeeded: false,
isSignInAnOption: false,
isLoginRequired: null,
error: null,
};
Expand All @@ -23,22 +25,41 @@ class App extends Component {
this.recoverTheme();
}

isAdminEndpointAccessible = () => {
return axios
.post("/send-results")
.then((response) => {
return response.status !== 401;
})
.catch((error) => {
return error.status !== 401;
});
}

isLoginRequired = () => {
this.setState({ error: null });
axios
.get("/config")
.then((response) => {
.then(async (response) => {
const isSecurityEnabled = response.data.data.security_enabled;
let isLogoutNeeded = false;
let isSignInAnOption = false;
if (isSecurityEnabled === 1) {
isLogoutNeeded = true;
const isMakeViewerEndpointsPublic = response.data.data.make_viewer_endpoints_public;
if (isMakeViewerEndpointsPublic === 1 && !await this.isAdminEndpointAccessible()) {
setViewerRole();
isLogoutNeeded = false;
isSignInAnOption = true;
}
} else {
localStorage.removeItem("expirationDate");
localStorage.removeItem("roles");
}
this.setState({
isLoginRequired: false,
isLogoutNeeded: isLogoutNeeded,
isSignInAnOption: isSignInAnOption
});
})
.catch((error) => {
Expand Down Expand Up @@ -90,13 +111,29 @@ class App extends Component {
<Route
path="/signin"
render={() => (
<AllureDockerSigIn isLoginRequired={this.isLoginRequired} />
<AllureDockerSigIn isLoginRequired={this.isLoginRequired}/>
)}
/>
<Route render={() => <Redirect to="/signin" />} />
</Switch>
);
} else {
let signInAnOption;
if (this.state.isSignInAnOption) {
signInAnOption = (
<React.Fragment>
<Route
path="/signin"
render={() => (
<AllureDockerSigIn isLoginRequired={this.isLoginRequired} isHomeAnOption={!this.isSignInAnOption}/>
)}
/>
</React.Fragment>
)
} else {
signInAnOption = (<Route path="/signin" exact render={() => <Redirect to="/" />} />)
}

switchRouter = (
<Switch>
<Route
Expand All @@ -107,6 +144,7 @@ class App extends Component {
darkState={this.state.darkState}
handleThemeChange={this.handleThemeChange}
isLogoutNeeded={this.state.isLogoutNeeded}
isSignInAnOption={this.state.isSignInAnOption}
/>
)}
/>
Expand All @@ -118,6 +156,7 @@ class App extends Component {
darkState={this.state.darkState}
handleThemeChange={this.handleThemeChange}
isLogoutNeeded={this.state.isLogoutNeeded}
isSignInAnOption={this.state.isSignInAnOption}
/>
)}
/>
Expand All @@ -126,7 +165,7 @@ class App extends Component {
exact
render={() => <AllureDockerReportFullView />}
/>
<Route path="/signin" exact render={() => <Redirect to="/" />} />
{signInAnOption}
<Route component={AllureDockerNotFound} />
</Switch>
);
Expand Down
112 changes: 93 additions & 19 deletions ui/src/components/AllureDockerInfoDialog/AllureDockerInfoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@ import DialogTitle from "@material-ui/core/DialogTitle";
import Link from "@material-ui/core/Link";
import Typography from "@material-ui/core/Typography";

import localAxios from "axios";

class AllureDockerInfoDialog extends Component {
state = {
version: null,
};

getConfig = () => {
const axios = localAxios.create();
axios
.get(`${process.env.PUBLIC_URL}/config.json`)
.then((response) => {
this.setState({ version: response.data.version });
})
.catch((error) => {
this.setState({ version: 'NOT_FOUND' });
});
};

handleCloseDialog = () => {
this.props.handleCloseDialog();
};

componentDidUpdate() {
if (!this.state.version) {
this.getConfig();
}
}

render() {
return (
<Dialog
Expand All @@ -25,47 +49,58 @@ class AllureDockerInfoDialog extends Component {
<DialogContentText>
<Typography
component="span"
variant="body1"
variant="h6"
color="textSecondary"
align="left"
>
{"Frank Escobar --> "}
<Link
color="inherit"
href="http://ar.linkedin.com/in/fescobarsystems"
rel="noopener noreferrer"
target="_blank"
>
LinkedIn
</Link>
Allure UI Version
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
{this.state.version}
</Typography>
</DialogContentText>
<DialogContentText>
<Typography
component="span"
variant="body1"
variant="h6"
color="textSecondary"
align="left"
>
{"Support --> "}
Support
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
<Link
color="inherit"
href="https://gitter.im/allure-docker-service/community"
rel="noopener noreferrer"
target="_blank"
>
Gitter
https://gitter.im/allure-docker-service/community
</Link>
</Typography>
</DialogContentText>
<DialogContentText>
<Typography
component="span"
variant="body1"
variant="h6"
color="textSecondary"
align="left"
>
{"UI --> "}
UI
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
<Link
color="inherit"
href="https://github.com/fescobar/allure-docker-service-ui"
Expand All @@ -79,11 +114,17 @@ class AllureDockerInfoDialog extends Component {
<DialogContentText>
<Typography
component="span"
variant="body1"
variant="h6"
color="textSecondary"
align="left"
>
{"API --> "}
API
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
<Link
color="inherit"
href="https://github.com/fescobar/allure-docker-service"
Expand All @@ -97,11 +138,17 @@ class AllureDockerInfoDialog extends Component {
<DialogContentText>
<Typography
component="span"
variant="body1"
variant="h6"
color="textSecondary"
align="left"
>
{"Examples --> "}
Examples
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
<Link
color="inherit"
href="https://github.com/fescobar/allure-docker-service-examples"
Expand All @@ -113,6 +160,33 @@ class AllureDockerInfoDialog extends Component {
</Typography>
</DialogContentText>
</DialogContent>
<DialogTitle id="form-dialog-title">AUTHOR</DialogTitle>
<DialogContent>
<DialogContentText>
<Typography
component="span"
variant="body1"
color="textSecondary"
align="left"
>
{"Frank Escobar"}
</Typography>
<Typography
variant="subtitle2"
color="secondary"
align="center"
>
<Link
color="inherit"
href="https://www.linkedin.com/in/fescobarsystems/"
rel="noopener noreferrer"
target="_blank"
>
LinkedIn
</Link>
</Typography>
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.handleCloseDialog} color="secondary">
Close
Expand Down
Loading

0 comments on commit ce037d0

Please sign in to comment.