Skip to content
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
6 changes: 3 additions & 3 deletions src/renderer/src/components/AudioTab/AudioTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function AudioTab() {
const { showMessage } = useSnackBar();
const [data, setData] = useState(Array<IRow>());
const [pdata, setPData] = useState(Array<IPRow>());
const { sectionArr, shared, publishingOn, canEditSheet, canPublish } =
const { sectionArr, shared, publishingOn, canEditAudio, canPublish } =
useContext(PlanContext).state;
const sectionMap = new Map<number, string>(sectionArr);
const [attachVisible, setAttachVisible] = useState(false);
Expand Down Expand Up @@ -341,7 +341,7 @@ export function AudioTab() {
<Box width="100%">
<TabAppBar position="fixed" color="default">
<TabActions>
{canEditSheet && (
{canEditAudio && (
<>
<AltButton
id="audUpload"
Expand Down Expand Up @@ -394,7 +394,7 @@ export function AudioTab() {
playItem={playItem}
setPlayItem={setPlayItem}
onAttach={onAttach}
readonly={!canEditSheet}
readonly={!canEditAudio}
sectionArr={sectionArr}
shared={shared}
canSetDestination={!isOffline && canPublish}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/Sheet/PassageCard.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe('PassageCard', () => {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [],
setSectionArr: () => {},
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/Sheet/PassageRef.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('PassageRef', () => {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [],
setSectionArr: () => {},
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/Sheet/PlanBar.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ describe('PlanBar', () => {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [],
setSectionArr: cy.stub(),
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/Sheet/PlanTabSelect.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ describe('PlanTabSelect', () => {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [],
setSectionArr: cy.stub(),
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/Sheet/PlanView.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ describe('PlanView', () => {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [],
setSectionArr: cy.stub(),
Expand Down
19 changes: 16 additions & 3 deletions src/renderer/src/context/PlanContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const initState = {
publishingOn: true,
hidePublishing: true,
canEditSheet: false,
canEditAudio: false,
canPublish: false,
sectionArr: [] as SectionArray,
setSectionArr: (_sectionArr: SectionArray) => {},
Expand Down Expand Up @@ -64,16 +65,27 @@ const PlanProvider = (props: IProps) => {
const [project] = useGlobal('project'); //will be constant here
const [connected] = useGlobal('connected'); //verified this is not used in a function 2/18/25
const [isOffline] = useGlobal('offline'); //verified this is not used in a function 2/18/25
const [offlineOnly] = useGlobal('offlineOnly');
const [isDeveloper] = useGlobal('developer');
const getPlanType = usePlanType();
const { setProjectDefault, getProjectDefault } = useProjectDefaults();
const { canEditSheet: canEditSheetPerm, canPublish } =
useProjectPermissions();
const {
canEditSheet: canEditSheetPerm,
canEditSheetBase,
canPublish,
} = useProjectPermissions();
const [addStoryOrPassage] = useGlobal('addStoryOrPassage');
// Bold-workflow members can add sections/passages when the session-only
// "Add {Story} or Passage" flag is set (see UserMenu). The flag can only be
// set in a bold context, so no extra workflow guard is needed here.
const canEditSheet = canEditSheetPerm || addStoryOrPassage;
// Structural sheet edits (adding/moving sections & passages) still require
// connectivity to the server, same as admins/sheet-editors -- see TT-7521.
// Audio upload/delete is safe to allow offline (it queues for later sync),
// so canEditAudio intentionally does not apply that restriction.
const structuralOffline = isOffline && !offlineOnly;
const canEditSheet =
canEditSheetPerm || (addStoryOrPassage && !structuralOffline);
const canEditAudio = canEditSheetBase || addStoryOrPassage;
const [state, setState] = useState({
...initState,
mediafiles,
Expand Down Expand Up @@ -162,6 +174,7 @@ const PlanProvider = (props: IProps) => {
setSectionArr,
connected,
canEditSheet,
canEditAudio,
canPublish,
togglePublishing,
setCanAddPublishing,
Expand Down
25 changes: 15 additions & 10 deletions src/renderer/src/utils/useProjectPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { useOrbitData } from '../hoc/useOrbitData';
export const useProjectPermissions = (
team?: string,
proj?: string
): { canEditSheet: boolean; canPublish: boolean } => {
): {
canEditSheet: boolean;
canEditSheetBase: boolean;
canPublish: boolean;
} => {
const [canEditSheet, setCanEditSheet] = useState(false);
const [canEditSheetBase, setCanEditSheetBase] = useState(false);
const [canPublish, setCanPublish] = useState(false);
const [isOffline] = useGlobal('offline'); //verified this is not used in a function 2/18/25
const [offlineOnly] = useGlobal('offlineOnly');
Expand Down Expand Up @@ -39,14 +44,14 @@ export const useProjectPermissions = (
const editgroup = related(projectRec, 'editsheetgroup');
const edituser = related(projectRec, 'editsheetuser');

setCanEditSheet(
(!(isOffline && !offlineOnly) &&
(isAdmin ||
(Boolean(editgroup) &&
myGroups.findIndex((g) => g.id === editgroup) > -1) ||
(Boolean(edituser) && edituser === user))) ??
false
);
const editSheetBase =
isAdmin ||
(Boolean(editgroup) &&
myGroups.findIndex((g) => g.id === editgroup) > -1) ||
(Boolean(edituser) && edituser === user);

setCanEditSheetBase(editSheetBase ?? false);
setCanEditSheet((!(isOffline && !offlineOnly) && editSheetBase) ?? false);

const publishgroup = related(projectRec, 'publishgroup');
const publishuser = related(projectRec, 'publishuser');
Expand All @@ -60,5 +65,5 @@ export const useProjectPermissions = (
);
}, [projectRec, myGroups, isAdmin, user, isOffline, offlineOnly]);

return { canEditSheet, canPublish };
return { canEditSheet, canEditSheetBase, canPublish };
};
Loading