diff --git a/client/src/components/App.jsx b/client/src/components/App.jsx index f44c550..dc15da6 100644 --- a/client/src/components/App.jsx +++ b/client/src/components/App.jsx @@ -5,6 +5,7 @@ import { ConnectedBoardPage as BoardPage } from './BoardPage/BoardPage'; import { ConnectedEditBoardPage as EditBoardPage } from './BoardPage/EditBoardPage'; import { store } from '../store/store'; import { Provider } from 'react-redux'; +import { logout } from '../store/actions/logout'; export class App extends React.Component { render() { @@ -16,10 +17,9 @@ export class App extends React.Component { - { - window.location = "/logout"; - return null; + this.logout(); + return ; }} /> } /> @@ -27,4 +27,8 @@ export class App extends React.Component { ); } + + logout() { + store.dispatch(logout()); + } } \ No newline at end of file diff --git a/client/src/components/BoardPage/BoardPage.jsx b/client/src/components/BoardPage/BoardPage.jsx index 66ab9b8..cec2bbd 100644 --- a/client/src/components/BoardPage/BoardPage.jsx +++ b/client/src/components/BoardPage/BoardPage.jsx @@ -66,7 +66,7 @@ export class BoardPage extends React.Component { renderNewCardModal() { const { newCardModalActive, newCardLaneID } = this.state; const { board } = this.props; - if (!board) return null; + if (!board || !newCardLaneID) return null; return (
diff --git a/client/src/components/BoardPage/EditBoardPage.jsx b/client/src/components/BoardPage/EditBoardPage.jsx index cac4547..89ecc6f 100644 --- a/client/src/components/BoardPage/EditBoardPage.jsx +++ b/client/src/components/BoardPage/EditBoardPage.jsx @@ -2,16 +2,17 @@ import React from 'react'; import { Page } from '../Page'; import { connect } from 'react-redux'; import { selectFlagsIsLoading } from '../../store/selectors/flags'; -import { fetchBoards, saveBoard } from '../../store/actions/boards'; +import { fetchBoards, saveBoard, deleteBoard } from '../../store/actions/boards'; import { fetchProjects } from '../../store/actions/projects'; import uuidv4 from 'uuid/v4'; +import { Loader } from '../Loader'; export class EditBoardPage extends React.Component { state = { edited: false, board: { - id: uuidv4(), + id: "", title: "", description: "", projects: [], @@ -42,6 +43,7 @@ export class EditBoardPage extends React.Component { this.onBoardDescriptionChange = this.onBoardAttrChange.bind(this, 'description'); this.onBoardLaneTitleChange = this.onBoardLaneAttrChange.bind(this, 'title'); this.onBoardLaneIssueLabelChange = this.onBoardLaneAttrChange.bind(this, 'issueLabel'); + this.onDeleteBoardClick = this.onDeleteBoardClick.bind(this); } render() { @@ -50,20 +52,38 @@ export class EditBoardPage extends React.Component { if (isLoading) { return ( -

Loading...

+ + + ) }; return ( -
+
- { - board.id ? -

Éditer le tableau

: -

Nouveau tableau

- } +
+
+ { + board.id ? +

Éditer le tableau

: +

Nouveau tableau

+ } +
+
+ { + board.id ? + : + null + } +
+
@@ -366,8 +386,16 @@ export class EditBoardPage extends React.Component { } onSaveBoardClick() { + let { board } = this.state; + board = { ...board }; + if (!board.id) board.id = uuidv4(); + this.props.dispatch(saveBoard({...board})); + this.props.history.push('/'); + } + + onDeleteBoardClick() { const { board } = this.state; - this.props.dispatch(saveBoard(board)); + this.props.dispatch(deleteBoard(board.id)); this.props.history.push('/'); } diff --git a/client/src/components/BoardPage/IssueCard.jsx b/client/src/components/BoardPage/IssueCard.jsx index 3a2a09d..a193ed8 100644 --- a/client/src/components/BoardPage/IssueCard.jsx +++ b/client/src/components/BoardPage/IssueCard.jsx @@ -1,8 +1,13 @@ import React from 'react'; +const issueURLPattern = /(^https?:\/\/([^\/]))$/i; + export class IssueCard extends React.PureComponent { render() { const { card } = this.props; + const issueURLInfo = extractInfoFromIssueURL(card.issue.url); + const projectURL = `${issueURLInfo.baseURL}/${issueURLInfo.owner}/${issueURLInfo.projectName}`; + const issueURL = `${projectURL}/issues/${card.issue.number}`; return (
@@ -30,18 +35,28 @@ export class IssueCard extends React.PureComponent {
); } +} + +function extractInfoFromIssueURL(issueURL) { + const pattern = /^(https?:\/\/[^\/]+)\/api\/v1\/repos\/([^\/]+)\/([^\/]+)\/.*$/; + const matches = pattern.exec(issueURL); + return { + baseURL: matches[1], + owner: matches[2], + projectName: matches[3], + }; } \ No newline at end of file diff --git a/client/src/components/HomePage/BoardCard.jsx b/client/src/components/HomePage/BoardCard.jsx index 24b016d..461a1bb 100644 --- a/client/src/components/HomePage/BoardCard.jsx +++ b/client/src/components/HomePage/BoardCard.jsx @@ -26,11 +26,6 @@ export class BoardCard extends React.PureComponent { - - - - -
diff --git a/client/src/components/Navbar.jsx b/client/src/components/Navbar.jsx index 49f7e76..44ac82c 100644 --- a/client/src/components/Navbar.jsx +++ b/client/src/components/Navbar.jsx @@ -7,7 +7,7 @@ export class Navbar extends React.PureComponent {
- +

GenGitKan