Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Add Tasks button only appears in my tasks dashboard #6402

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/client/components/ContentWithHeading.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import PropTypes from 'prop-types'
import React from 'react'
import { Button, H3, Link } from 'govuk-react'
import { H3 } from 'govuk-react'
import styled from 'styled-components'

import SpacedSectionBreak from './SpacedSectionBreak'
import { BLUE } from '../utils/colours'
import urls from '../../lib/urls'

const StyledHeading = styled(H3)({
flexGrow: 1,
Expand All @@ -21,14 +19,6 @@ const ContentWithHeading = ({ heading, children, headingActions }) => (
<StyledHeader>
<StyledHeading size={24}>{heading}</StyledHeading>
{headingActions}
<Button
buttonColour={BLUE}
href={urls.tasks.create()}
as={Link}
data-test="add-task"
>
Add task
</Button>
</StyledHeader>
<SpacedSectionBreak />
{children}
Expand Down
14 changes: 13 additions & 1 deletion src/client/components/Dashboard/my-tasks/MyTasks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from 'react-redux'
import styled from 'styled-components'
import { SITE_WIDTH, SPACING } from '@govuk-react/constants'

import { HintText } from 'govuk-react'
import { HintText, Button, Link } from 'govuk-react'

import { ID as GET_MY_TASKS_ID, TASK_GET_MY_TASKS, state2props } from './state'
import { MY_TASKS_LOADED } from '../../../actions'
Expand All @@ -12,6 +12,8 @@ import ContentWithHeading from '../../ContentWithHeading'
import MyTasksTable from './MyTasksTable'
import TaskListSelect from './TaskListSelect'
import SpacedSectionBreak from '../../SpacedSectionBreak'
import { BLUE } from '../../../utils/colours'
import urls from '../../../../lib/urls'

const SELECT_WIDTH = `16%`

Expand Down Expand Up @@ -58,6 +60,16 @@ export const MyTasksContent = ({ myTasks, filters }) => (
<SpacedSectionBreak />
<ContentWithHeading
heading={`${myTasks?.count} ${myTasks?.count == 1 ? 'task' : 'tasks'}`}
headingActions={
<Button
buttonColour={BLUE}
href={urls.tasks.create()}
as={Link}
data-test="add-task"
>
Add task
</Button>
}
data-test="my-tasks-heading"
>
{myTasks?.count ? (
Expand Down