Skip to content

Commit

Permalink
- visual improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Mar 31, 2021
1 parent 6ba6045 commit 7cbfd28
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 98 deletions.
79 changes: 42 additions & 37 deletions js/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
Avatar,
Box,
ButtonGroup,
LinearProgress
LinearProgress,
Tooltip
} from '@material-ui/core';
import {
PowerSettingsNew,
Expand Down Expand Up @@ -236,44 +237,48 @@ export default memo(
{discourseAvailable && (
<ButtonGroup variant="text" size="small">
{targetDiscourseVisible && (
<Button
startIcon={<Chat />}
variant="text"
size="small"
onClick={() => {
generateDiscourseTargetURL(targetName)
.then(response => {
const url = response.data['Post url'];
if (url) {
openDiscourseLink(url);
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
></Button>
<Tooltip title="Go to target category on Discourse">
<Button
startIcon={<Chat />}
variant="text"
size="small"
onClick={() => {
generateDiscourseTargetURL(targetName)
.then(response => {
const url = response.data['Post url'];
if (url) {
openDiscourseLink(url);
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
></Button>
</Tooltip>
)}
{projectDiscourseVisible && (
<Button
startIcon={<QuestionAnswer />}
variant="text"
size="small"
onClick={() => {
getExistingPost(currentProject.title)
.then(response => {
const url = response.data['Post url'];
if (url) {
openDiscourseLink(url);
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
></Button>
<Tooltip title="Go to project topic on Discourse">
<Button
startIcon={<QuestionAnswer />}
variant="text"
size="small"
onClick={() => {
getExistingPost(currentProject.title)
.then(response => {
const url = response.data['Post url'];
if (url) {
openDiscourseLink(url);
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
></Button>
</Tooltip>
)}
</ButtonGroup>
)}
Expand Down
86 changes: 43 additions & 43 deletions js/components/projects/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, useEffect, useCallback } from 'react';
import React, { memo, useEffect } from 'react';
import { Panel } from '../common/Surfaces/Panel';
import {
Table,
Expand Down Expand Up @@ -56,7 +56,6 @@ export const Projects = memo(({}) => {
const [rowsPerPage, setRowsPerPage] = React.useState(10);
const isLoadingListOfProjects = useSelector(state => state.projectReducers.isLoadingListOfProjects);
const dispatch = useDispatch();
const projectDiscourseLinks = useSelector(state => state.projectReducers.projectDiscourseLinks);

const listOfProjects = useSelector(state => state.projectReducers.listOfProjects).map(project => {
return {
Expand Down Expand Up @@ -87,6 +86,8 @@ export const Projects = memo(({}) => {

let debouncedFn;

const discourseAvailable = isDiscourseAvailable();

const handleSearch = event => {
/* signal to React not to nullify the event object */
event.persist();
Expand Down Expand Up @@ -145,29 +146,25 @@ export const Projects = memo(({}) => {
</TableHead>
<TableBody>
{listOfProjects.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(project => (
<Tooltip
title={project.description}
key={project.id}
placement="bottom-start"
TransitionProps={{ timeout: 600 }}
TransitionComponent={Zoom}
>
<TableRow hover>
<TableRow hover>
<Tooltip title={`${project.description}`}>
<TableCell component="th" scope="row">
<Link to={`${URLS.projects}${project.id}`}>{project.name}</Link>
</TableCell>
<TableCell align="left">
<Link to={`${URLS.target}${project.target}`}>{project.target}</Link>
</TableCell>
<TableCell align="left">
{project.tags &&
project.tags.map((tag, index) => (
<Chip key={index} label={tag} size="small" className={classes.chip} />
))}
</TableCell>
<TableCell align="left">{project.author}</TableCell>
<TableCell align="left">{moment(project.createdAt).format('LLL')}</TableCell>
<TableCell align="right">
</Tooltip>
<TableCell align="left">
<Link to={`${URLS.target}${project.target}`}>{project.target}</Link>
</TableCell>
<TableCell align="left">
{project.tags &&
project.tags.map((tag, index) => (
<Chip key={index} label={tag} size="small" className={classes.chip} />
))}
</TableCell>
<TableCell align="left">{project.author}</TableCell>
<TableCell align="left">{moment(project.createdAt).format('LLL')}</TableCell>
<TableCell align="right">
<Tooltip title="Delete project">
<IconButton
disabled={DJANGO_CONTEXT['username'] === 'NOT_LOGGED_IN'}
onClick={() =>
Expand All @@ -178,27 +175,30 @@ export const Projects = memo(({}) => {
>
<Delete />
</IconButton>
<IconButton
disabled={!isDiscourseAvailable() && !projectDiscourseLinks?.hasOwnProperty(project.id)}
onClick={() => {
getExistingPost(project.name)
.then(response => {
if (response.data['Post url']) {
const link = response.data['Post url'];
window.open(link, '_blank');
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
>
<QuestionAnswer />
</IconButton>
</TableCell>
</TableRow>
</Tooltip>
</Tooltip>
{discourseAvailable && (
<Tooltip title="Go to Discourse">
<IconButton
onClick={() => {
getExistingPost(project.name)
.then(response => {
if (response.data['Post url']) {
const link = response.data['Post url'];
window.open(link, '_blank');
}
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
>
<QuestionAnswer />
</IconButton>
</Tooltip>
)}
</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
Expand Down
38 changes: 20 additions & 18 deletions js/components/target/targetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React, { memo } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { ListItemText, ListItemSecondaryAction, Grid, IconButton } from '@material-ui/core';
import { ListItemText, ListItemSecondaryAction, Grid, IconButton, Tooltip } from '@material-ui/core';
import { List, ListItem, Panel } from '../common';
import { Link } from 'react-router-dom';
import { URLS } from '../routes/constants';
Expand All @@ -30,29 +30,31 @@ export const TargetList = memo(() => {
<ListItemText primary={data.title} />
</Link>
<ListItemSecondaryAction>
<Grid container direction="row" justify="center" alignItems="flex-start">
<Grid container direction="row" justify="center" alignItems="center">
{sgcUploaded.includes(data.title) && (
<a href={sgcUrl} target="new">
Open SGC summary
</a>
)}
{discourseAvailable && (
<IconButton
disabled={!isDiscourseAvailable()}
onClick={() => {
generateDiscourseTargetURL(data.title)
.then(response => {
const link = response.data['Post url'];
window.open(link, '_blank');
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
>
<Chat />
</IconButton>
<Tooltip title="Go to Discourse">
<IconButton
disabled={!isDiscourseAvailable()}
onClick={() => {
generateDiscourseTargetURL(data.title)
.then(response => {
const link = response.data['Post url'];
window.open(link, '_blank');
})
.catch(err => {
console.log(err);
dispatch(setOpenDiscourseErrorModal(true));
});
}}
>
<Chat />
</IconButton>
</Tooltip>
)}
</Grid>
</ListItemSecondaryAction>
Expand Down

0 comments on commit 7cbfd28

Please sign in to comment.