Skip to content

Commit

Permalink
Visuelt løft på dialog for endring av fase (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi749 authored Oct 30, 2023
1 parent c90aba0 commit 2103d92
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DefaultButton, DialogFooter, PrimaryButton } from '@fluentui/react'
import * as strings from 'ProjectWebPartsStrings'
import React, { FC, useContext } from 'react'
import { DISMISS_CHANGE_PHASE_DIALOG } from '../../..//ProjectPhases/reducer'
import { ProjectPhasesContext } from '../../../ProjectPhases/context'
import { DISMISS_CHANGE_PHASE_DIALOG } from '../../reducer'
import { ProjectPhasesContext } from '../../context'
import { useChangePhase } from '../../useChangePhase'
import { View } from '../Views'
import { ChangePhaseDialogContext } from '../context'
import { SET_VIEW } from '../reducer'
import { Button, DialogActions } from '@fluentui/react-components'

export const Footer: FC = () => {
export const Actions: FC = () => {
const context = useContext(ProjectPhasesContext)
const { state, dispatch } = useContext(ChangePhaseDialogContext)
const onChangePhase = useChangePhase()
Expand Down Expand Up @@ -47,14 +47,18 @@ export const Footer: FC = () => {
}

return (
<DialogFooter>
<DefaultButton
text={strings.CancelText}
<DialogActions>
<Button
title={strings.CancelText}
onClick={() => context.dispatch(DISMISS_CHANGE_PHASE_DIALOG())}
/>
>
{strings.CancelText}
</Button>
{actions.map((buttonProps, index) => (
<PrimaryButton key={index} {...buttonProps} />
<Button appearance='primary' key={index} {...buttonProps}>
{buttonProps.text}
</Button>
))}
</DialogFooter>
</DialogActions>
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.root {
.changePhaseDialog {
width: 550px;
max-width: 550px;
font-weight: 300;

.dialogContent {
display: flex;
flex-direction: column;
gap: 12px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const VIEW_MAP: Record<View, JSX.Element> = {
[View.Confirm]: null
}

export const Body: FC = () => {
export const Content: FC = () => {
const { state } = useContext(ChangePhaseDialogContext)
return VIEW_MAP[state.view] ?? null
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ import { UserMessage } from 'pp365-shared-library/lib/components/UserMessage'
import * as strings from 'ProjectWebPartsStrings'
import React, { FC, useContext } from 'react'
import _ from 'underscore'
import styles from './DynamicHomepageContent.module.scss'

export const DynamicHomepageContent: FC = () => {
const context = useContext(ProjectPhasesContext)
const phaseSitePages = context.state.data.phaseSitePages ?? []
const phaseSitePage = _.find(phaseSitePages, (p) => p.title === context.state.confirmPhase.name)
return (
<div className={styles.root}>
<UserMessage
text={
phaseSitePage
? format(strings.PhaseSitePageFoundDescription, phaseSitePage?.fileLeafRef)
: format(strings.PhaseSitePageNotFoundDescription, context.state.confirmPhase.name)
}
intent={phaseSitePage ? 'info' : 'warning'}
/>
</div>
<UserMessage
title={strings.PhaseSitePageTitle}
text={
phaseSitePage
? format(strings.PhaseSitePageFoundDescription, phaseSitePage?.fileLeafRef)
: format(strings.PhaseSitePageNotFoundDescription, context.state.confirmPhase.name)
}
intent={phaseSitePage ? 'info' : 'warning'}
/>
)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { format, ProgressIndicator } from '@fluentui/react'
import { format } from '@fluentui/react'
import { ProjectPhasesContext } from '../../../../ProjectPhases/context'
import * as strings from 'ProjectWebPartsStrings'
import React, { FC, useContext } from 'react'
import { Field, ProgressBar } from '@fluentui/react-components'

export const ChangingPhaseView: FC = () => {
const context = useContext(ProjectPhasesContext)
return (
<ProgressIndicator
<Field
label={strings.PleaseWaitText}
description={format(strings.ChangingPhaseDescription, context.state.confirmPhase.name)}
/>
hint={format(strings.ChangingPhaseDescription, context.state.confirmPhase.name)}
validationState='none'
>
<ProgressBar />
</Field>
)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
@import '~@fluentui/react/dist/sass/References.scss';
@import "~@fluentui/react/dist/sass/References.scss";

.root {
.header {
@include ms-fontSize-14;
}
.commentField {
margin: 10px 0 0 0;
display: flex;
flex-direction: column;
gap: 12px;

.tabList {
display: flex;
justify-content: space-between;

textarea {
height: 100px;
.tabItem {
cursor: default;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.root {
margin: 12px 0;

.button {
font-weight: var(--fontWeightRegular);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { FC } from 'react'
import { IStatusActionsProps } from './types'
import styles from './StatusActions.module.scss'
import { Button } from '@fluentui/react-components'

export const StatusActions: FC<IStatusActionsProps> = ({ actions }) => {
return (
<div className={styles.root}>
{actions.map((action, index) => (
<Button
className={styles.button}
appearance='subtle'
title={action.text}
key={index}
{...action}
>
{action.text}
</Button>
))}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IStatusActionsProps {
actions: any[]
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import { TextField } from '@fluentui/react/lib/TextField'
import * as strings from 'ProjectWebPartsStrings'
import React, { FC } from 'react'
import styles from './InitialView.module.scss'
import { StatusOptions } from './StatusOptions'
import { useInitialView } from './useInitialView'
import { Field, Label, Tab, TabList, Textarea } from '@fluentui/react-components'
import { StatusActions } from './StatusActions'
import { format } from '@fluentui/react'

export const InitialView: FC = () => {
const { checklistItem, setComment, comment, actions } = useInitialView()
const { checklistItem, checklistItems, setComment, comment, actions } = useInitialView()
if (!checklistItem) return null

return (
<div className={styles.root}>
<div className={styles.header}>
{checklistItem.id}. {checklistItem.title}
</div>
<TextField
className={styles.commentField}
onChange={(_, newValue: string) => setComment(newValue)}
placeholder={strings.ChecklistCommentPlaceholder}
description={strings.ChecklistCommentDescription}
multiline
value={comment}
resizable={false}
/>
<StatusOptions actions={actions} />
<TabList className={styles.tabList} selectedValue={checklistItem.id}>
{checklistItems.map((item) => (
<Tab
className={styles.tabItem}
key={item.id}
title={format(strings.PhaseCheckListItem, item.id)}
value={item.id}
>
{item.id}
</Tab>
))}
</TabList>
<Label weight='semibold'>{checklistItem.title}</Label>
<Field hint={strings.ChecklistCommentDescription}>
<Textarea
rows={4}
value={comment}
placeholder={strings.ChecklistCommentPlaceholder}
onChange={(_, data) => setComment(data.value)}
/>
</Field>
<StatusActions actions={actions} />
</div>
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IButtonProps } from '@fluentui/react/lib/Button'
import { ProjectPhasesContext } from 'components/ProjectPhases/context'
import { getFluentIcon } from 'pp365-shared-library'
import * as strings from 'ProjectWebPartsStrings'
import { useContext } from 'react'

Expand All @@ -12,15 +12,15 @@ import { useContext } from 'react'
export function useActions(comment: string, onNextChecklistItem: (statusValue: string) => void) {
const context = useContext(ProjectPhasesContext)
const isCommentValid = comment?.length >= context.props.commentMinLength
const actions: IButtonProps[] = [
const actions = [
{
text: strings.StatusNotRelevant,
disabled: !isCommentValid,
title: isCommentValid
? strings.CheckpointNotRelevantTooltip
: strings.CheckpointNotRelevantTooltipCommentEmpty,
onClick: () => onNextChecklistItem(strings.StatusNotRelevant),
iconProps: { iconName: 'Blocked' }
icon: getFluentIcon('DismissCircle')
},
{
text: strings.StatusStillOpen,
Expand All @@ -29,13 +29,13 @@ export function useActions(comment: string, onNextChecklistItem: (statusValue: s
? strings.CheckpointStillOpenTooltip
: strings.CheckpointStillOpenTooltipCommentEmpty,
onClick: () => onNextChecklistItem(strings.StatusOpen),
iconProps: { iconName: 'CircleRing' }
icon: getFluentIcon('Circle')
},
{
text: strings.StatusClosed,
title: strings.CheckpointDoneTooltip,
onClick: () => onNextChecklistItem(strings.StatusClosed),
iconProps: { iconName: 'CheckMark' }
icon: getFluentIcon('CheckmarkCircle')
}
]
return actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useActions } from './useActions'
export function useInitialView() {
const { state } = useContext(ChangePhaseDialogContext)
const checklistItem = state.checklistItems[state.currentIdx]
const checklistItems = state.checklistItems
const { nextChecklistItem } = useContext(ChangePhaseDialogContext)
const [comment, setComment] = useState(checklistItem.comment || '')

Expand All @@ -26,5 +27,5 @@ export function useInitialView() {

const actions = useActions(comment, onNextChecklistItem)

return { checklistItem, setComment, comment, actions } as const
return { checklistItem, checklistItems, setComment, comment, actions } as const
}
Loading

0 comments on commit 2103d92

Please sign in to comment.