Skip to content

Commit 4eaf00c

Browse files
authored
Fix error when adding collaborator on Search, Report and Sigma (#23796)
1 parent c1e855f commit 4eaf00c

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

graylog2-web-interface/src/components/permissions/EntityCreateShareFormGroup.test.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ describe('EntityCreateShareFormGroup', () => {
7373
render(<SUT />);
7474

7575
await waitFor(() => {
76-
expect(EntityShareActions.prepare).toHaveBeenCalledWith(
77-
mockEntity.entityType,
78-
'',
79-
mockEntity.entityId,
80-
undefined,
81-
);
76+
expect(EntityShareActions.prepare).toHaveBeenCalledWith(mockEntity.entityType, '', mockEntity.entityId, {});
8277
});
8378
});
8479

graylog2-web-interface/src/components/permissions/EntityCreateShareFormGroup.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ const EntityCreateShareFormGroup = ({
8181
const defaultShareSelection = { granteeId: null, capabilityId: 'view' };
8282
const [disableSubmit, setDisableSubmit] = useState(entityShareState?.validationResults?.failed);
8383
const [shareSelection, setShareSelection] = useState<SelectionRequest>(defaultShareSelection);
84-
const [entityShare, setEntityShare] = useState<Omit<EntitySharePayload, 'prepare_request'>>(null);
84+
const [entityShare, setEntityShare] = useState<Omit<EntitySharePayload, 'prepare_request'>>(
85+
defaultSharePayload ?? null,
86+
);
8587
const PluggableEntityShareFormGroup = usePluggableEntityShareFormGroup();
8688

8789
useEffect(() => {
88-
EntityShareDomain.prepare(entityType, entityTitle, entityGRN, defaultSharePayload);
90+
const { selected_collections: _, ...rest } = defaultSharePayload ?? {};
91+
92+
EntityShareDomain.prepare(entityType, entityTitle, entityGRN, rest);
8993
}, [entityType, entityTitle, entityGRN, defaultSharePayload]);
9094

9195
const resetSelection = () => {
@@ -108,7 +112,6 @@ const EntityCreateShareFormGroup = ({
108112
return EntityShareDomain.prepare(entityType, entityTitle, entityGRN, payload).then((response) => {
109113
onSetEntityShare({ ...entityShare, selected_grantee_capabilities: newSelectedCapabilities });
110114
resetSelection();
111-
setDisableSubmit(false);
112115

113116
return response;
114117
});
@@ -195,7 +198,11 @@ const EntityCreateShareFormGroup = ({
195198
availableGrantees={entityShareState.availableGrantees}
196199
/>
197200
{PluggableEntityShareFormGroup && (
198-
<PluggableEntityShareFormGroup entityType={entityType} onChange={handleAdditionalFormChange} />
201+
<PluggableEntityShareFormGroup
202+
entityType={entityType}
203+
onChange={handleAdditionalFormChange}
204+
value={defaultSharePayload?.selected_collections || []}
205+
/>
199206
)}
200207
</>
201208
) : (

graylog2-web-interface/src/views/components/searchbar/saved-search/SavedSearchForm.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ const SavedSearchForm = ({
8282
{pluggableSaveViewControls?.map(
8383
({ component: Component, id }) => Component && <Component key={id} disabledViewCreation={disableSaveAs} />,
8484
)}
85-
<EntityCreateShareFormGroup
86-
description="Search for a User or Team to add as collaborator on this search."
87-
entityType="search"
88-
entityTitle=""
89-
entityId={isCreateNew ? null : viewId}
90-
dependenciesGRN={selectedStreamGRN}
91-
onSetEntityShare={(payload) => setSharePayload(payload)}
92-
/>
85+
{!disableSaveAs && (
86+
<EntityCreateShareFormGroup
87+
description="Search for a User or Team to add as collaborator on this search."
88+
entityType="search"
89+
entityTitle=""
90+
entityId={isCreateNew ? null : viewId}
91+
dependenciesGRN={selectedStreamGRN}
92+
onSetEntityShare={(payload) => setSharePayload(payload)}
93+
/>
94+
)}
9395
<ButtonToolbar>
9496
{!isCreateNew && (
9597
<Button

0 commit comments

Comments
 (0)