Skip to content

Commit c92392f

Browse files
gtryusGreg Trihus
andauthored
TT-7510 BOLD members can add prompts and users (#413)
- add item to user menu to enable these admin functions Co-authored-by: Greg Trihus <gtryus@gmail.com>
1 parent bbb3115 commit c92392f

12 files changed

Lines changed: 69 additions & 4 deletions

File tree

localization/TranscriberAdmin-en-1.2.xliff

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,13 @@
49454945
<context context-type="sourcefile">apphead.tsx</context>
49464946
</context-group>
49474947
</trans-unit>
4948+
<trans-unit id="main.addSectionOrPassage">
4949+
<source>Add {0} or Passage</source>
4950+
<target/>
4951+
<context-group>
4952+
<context context-type="sourcefile">UserMenu.tsx</context>
4953+
</context-group>
4954+
</trans-unit>
49484955
<trans-unit id="main.admin">
49494956
<source>Admin</source>
49504957
<target/>

localization/TranscriberAdmin-en.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,12 @@
42404240
<target/>
42414241
</segment>
42424242
</unit>
4243+
<unit id="main.addSectionOrPassage">
4244+
<segment>
4245+
<source>Add {0} or Passage</source>
4246+
<target/>
4247+
</segment>
4248+
</unit>
42434249
<unit id="main.admin">
42444250
<segment>
42454251
<source>Admin</source>

src/renderer/public/localization/stringsb51f6841.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/renderer/public/localization/stringsd868efcb.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/renderer/src/components/PassageDetail/Prompt/PassageDetailPrompt.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useRole } from '../../../crud/useRole';
22
import { useStepPermissions } from '../../../utils/useStepPermission';
3+
import { useGlobal } from '../../../context/useGlobal';
34
import usePassageDetailContext from '../../../context/usePassageDetailContext';
45
import PassageDetailPromptAdmin from './PassageDetailPromptAdmin';
56
import PassageDetailPromptMember from './PassageDetailPromptMember';
@@ -12,9 +13,14 @@ export default function PassageDetailPrompt(props: IProps) {
1213
const { userIsAdmin } = useRole();
1314
const { canDoSectionStep, permissionsOn } = useStepPermissions();
1415
const { section, currentstep } = usePassageDetailContext();
16+
// Bold-workflow members can record the prompt when the session-only
17+
// "Add {Story} or Passage" flag is set (see UserMenu).
18+
const [addStoryOrPassage] = useGlobal('addStoryOrPassage');
1519

1620
const showAdmin =
17-
userIsAdmin || (permissionsOn && canDoSectionStep(currentstep, section));
21+
userIsAdmin ||
22+
addStoryOrPassage ||
23+
(permissionsOn && canDoSectionStep(currentstep, section));
1824

1925
if (showAdmin) {
2026
return <PassageDetailPromptAdmin width={props.width} />;

src/renderer/src/components/UserMenu.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import { useOrbitData } from '../hoc/useOrbitData';
2828
import { shallowEqual, useSelector } from 'react-redux';
2929
import { mainSelector, sharedSelector } from '../selector';
3030
import ProfileDialog from './ProfileDialog';
31+
import { useRole } from '../crud/useRole';
32+
import { useOrganizedBy } from '../crud';
33+
import {
34+
useTeamWorkflowProcess,
35+
BOLD_WORKFLOW_PROCESS,
36+
} from '../crud/useTeamWorkflowProcess';
3137

3238
const TermsItem = styled(StyledMenuItem)<MenuItemProps>(() => ({
3339
textAlign: 'center',
@@ -54,6 +60,13 @@ export function UserMenu(props: IProps) {
5460
const [developer] = useGlobal('developer');
5561
const [user] = useGlobal('user');
5662
const [, setMobileView] = useGlobal('mobileView');
63+
const [org] = useGlobal('organization');
64+
const [addStoryOrPassage, setAddStoryOrPassage] =
65+
useGlobal('addStoryOrPassage');
66+
const { userIsAdmin } = useRole();
67+
const { getOrganizedBy } = useOrganizedBy();
68+
const isBoldWorkflow =
69+
useTeamWorkflowProcess(org) === BOLD_WORKFLOW_PROCESS;
5770
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
5871
const [shift, setShift] = React.useState(false);
5972
const [userRec, setUserRec] = React.useState<UserD | undefined>(undefined);
@@ -94,6 +107,12 @@ export function UserMenu(props: IProps) {
94107
setAnchorEl(null);
95108
};
96109

110+
const handleAddStoryOrPassageToggle = () => {
111+
// session-only flag; intentionally not persisted to localStorage
112+
setAddStoryOrPassage(!addStoryOrPassage);
113+
setAnchorEl(null);
114+
};
115+
97116
return (
98117
<div>
99118
<IconButton
@@ -142,6 +161,23 @@ export function UserMenu(props: IProps) {
142161
<ListItemText primary={t.mobileView} />
143162
</StyledMenuItem>
144163
)}
164+
{isBoldWorkflow && !userIsAdmin && (
165+
<StyledMenuItem
166+
id="addStoryOrPassage"
167+
onClick={handleAddStoryOrPassageToggle}
168+
>
169+
<ListItemIcon>
170+
<Checkbox
171+
checked={addStoryOrPassage}
172+
size="small"
173+
sx={{ padding: 0 }}
174+
/>
175+
</ListItemIcon>
176+
<ListItemText
177+
primary={t.addSectionOrPassage.replace('{0}', getOrganizedBy(true))}
178+
/>
179+
</StyledMenuItem>
180+
)}
145181
{shift && !isElectron && (
146182
<StyledMenuItem id="clearCache" onClick={handleAction('Clear')}>
147183
<ListItemIcon>

src/renderer/src/context/GlobalContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface GlobalState {
4747
snackMessage: React.JSX.Element; //verified //SnackBar
4848
offline: boolean;
4949
mobileView: boolean; //verified //UserMenu - toggle mobile view
50+
addStoryOrPassage: boolean; //UserMenu - session-only, bold member can add sections/passages + record prompt
5051
}
5152

5253
export type GlobalKey = keyof GlobalState;

src/renderer/src/context/PlanContext.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ const PlanProvider = (props: IProps) => {
6767
const [isDeveloper] = useGlobal('developer');
6868
const getPlanType = usePlanType();
6969
const { setProjectDefault, getProjectDefault } = useProjectDefaults();
70-
const { canEditSheet, canPublish } = useProjectPermissions();
70+
const { canEditSheet: canEditSheetPerm, canPublish } =
71+
useProjectPermissions();
72+
const [addStoryOrPassage] = useGlobal('addStoryOrPassage');
73+
// Bold-workflow members can add sections/passages when the session-only
74+
// "Add {Story} or Passage" flag is set (see UserMenu). The flag can only be
75+
// set in a bold context, so no extra workflow guard is needed here.
76+
const canEditSheet = canEditSheetPerm || addStoryOrPassage;
7177
const [state, setState] = useState({
7278
...initState,
7379
mediafiles,

src/renderer/src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const renderApp = (fingerprint: string, projectsLoaded: string[] = []) => {
7272
playingMediaId: '',
7373
mobileView:
7474
localStorage.getItem(localUserKey(LocalKey.mobileView)) === 'true',
75+
addStoryOrPassage: false, //session-only, not persisted (cleared on exit)
7576
};
7677

7778
const root = createRoot(document.getElementById('root') as HTMLElement);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "stringsName": "stringsb51f6841.json" }
1+
{ "stringsName": "stringsd868efcb.json" }

0 commit comments

Comments
 (0)