Skip to content

Commit

Permalink
ProjectsMonth: separate ValidateProjectMonth : main / Timesheet / Inb…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
Laoujin committed Jan 14, 2025
1 parent 55eff49 commit e994c73
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ type ValidityToggleButtonProps = MinimalInputProps<boolean> & {
outline?: boolean;
/** Button tooltip */
title?: string | {on: string, off: string, disabled: string};
claim: Claim;
};


export const ValidityToggleButton = ({value, onChange, outline, title, disabled, ...props}: ValidityToggleButtonProps) => {
export const ValidityToggleButton = ({value, onChange, outline, title, disabled, claim, ...props}: ValidityToggleButtonProps) => {
const icon = !value ? 'fa fa-check' : 'fas fa-ban';

let variant: BootstrapVariant;
Expand All @@ -36,7 +37,7 @@ export const ValidityToggleButton = ({value, onChange, outline, title, disabled,

return (
<Button
claim={{claim: Claim.ValidateProjectMonth, or: hiddenButton}}
claim={{claim, or: hiddenButton}}
onClick={() => onChange(!value)}
variant={variant}
icon={icon}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/project/EditProjectMonths.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import {useState} from 'react';
import {useDispatch} from 'react-redux';
import {useNavigate} from 'react-router-dom';
import {Container, Row, Form} from 'react-bootstrap';
Expand Down Expand Up @@ -68,7 +68,7 @@ export const EditProjectMonths = () => {
{t('projectMonth.deleteConfirm.content')}
</ConfirmationButton>
<BusyButton
className="tst-validate-project-month"
className="tst-validate-project-month"
onClick={() => dispatch(patchProjectsMonth(projectMonth) as any)}
claim={Claim.ValidateProjectMonth}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ButtonGroup = EnhanceWithClaim(ReactButtonGroup);
const ProjectMonthInboundStatusSelectComponent = ({value, onChange, style}: ProjectMonthInboundStatusSelectProps) => {
const currentStatus = value;
const btnGroup = (
<ButtonGroup claim={Claim.ValidateProjectMonth}>
<ButtonGroup claim={Claim.ValidateProjectMonthInbound}>
<Button
key="new"
variant={currentStatus === 'new' ? 'success' : 'outline-dark'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import {ButtonGroup as ReactButtonGroup} from 'react-bootstrap';
import {ProjectMonthStatus} from '../models/ProjectMonthModel';
import {EnhanceWithClaim} from '../../enhancers/EnhanceWithClaim';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const ProjectMonthTimesheetCell = ({fullProjectMonth}: ProjectMonthTimesh

<div className="timesheet-actions">
<ValidityToggleButton
claim={Claim.ValidateProjectMonthTimesheet}
value={timesheet.validated}
onChange={val => saveTimesheet({...timesheet, validated: val})}
disabled={canToggleValid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {StringInput} from '../../../../controls/form-controls/inputs/StringInput
import {useDebouncedSave} from '../../../../hooks/useDebounce';
import { CreateInvoiceButton } from './CreateInvoiceButton';
import { OutboundInvoice } from './OutboundInvoice';
import { Claim } from '../../../../users/models/UserModel';


interface ProjectMonthOutboundCellProps {
Expand All @@ -33,6 +34,7 @@ export const ProjectMonthOutboundCell = ({fullProjectMonth}: ProjectMonthOutboun

const ValidityToggle = (
<ValidityToggleButton
claim={Claim.ValidateProjectMonth}
value={!!fullProjectMonth.details.verified}
onChange={() => toggleValid(fullProjectMonth.details.verified ? false : 'forced')}
outline
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/users/models/UserModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export enum Claim {
EmailInvoices = 'email-invoices',
ViewProjectMonth = 'view-projectMonth',
ValidateProjectMonth = 'validate-projectMonth',
ValidateProjectMonthTimesheet = 'validate-projectMonthTimesheet',
ValidateProjectMonthInbound = 'validate-projectMonthTimesheetInbound',
CreateProjectMonth = 'create-projectMonth',
EditProjectMonth = 'edit-projectMonth',
DeleteProjectMonth = 'delete-projectMonth',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/users/models/getNewUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export const getAdminRole = (): RoleModel => {
Claim.ViewRoles, Claim.ManageRoles,
Claim.ViewInvoices, Claim.EmailInvoices, Claim.ValidateInvoices, Claim.ManageInvoices,
Claim.ViewProjectMonth, Claim.EditProjectMonth, Claim.CreateProjectMonth, Claim.ValidateProjectMonth, Claim.DeleteProjectMonth,
Claim.ValidateProjectMonthTimesheet, Claim.ValidateProjectMonthInbound,
]);
};

0 comments on commit e994c73

Please sign in to comment.