Skip to content

Commit

Permalink
Fix namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Nov 4, 2022
1 parent a9f8098 commit 2458b2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('EmailNotificationService', () => {
relatedObjects: [
{
id: 'mock-id-1',
spaceIds: [],
namespace: undefined,
type: 'cases',
},
],
Expand All @@ -73,7 +73,7 @@ describe('EmailNotificationService', () => {
relatedObjects: [
{
id: 'mock-id-1',
spaceIds: [],
namespace: undefined,
type: 'cases',
},
],
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('EmailNotificationService', () => {
relatedObjects: [
{
id: 'mock-id-1',
spaceIds: [],
namespace: undefined,
type: 'cases',
},
],
Expand All @@ -113,7 +113,7 @@ describe('EmailNotificationService', () => {
});
});

it('converts the namespace correctly', async () => {
it('passes the namespace correctly', async () => {
await emailNotificationService.notifyAssignees({
assignees,
theCase: { ...caseSO, namespaces: ['space1'] },
Expand All @@ -124,7 +124,7 @@ describe('EmailNotificationService', () => {
relatedObjects: [
{
id: 'mock-id-1',
spaceIds: ['space1'],
namespace: 'space1',
type: 'cases',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import type { IBasePath, Logger } from '@kbn/core/server';
import type { NotificationsPluginStart } from '@kbn/notifications-plugin/server';
import type { SecurityPluginStart } from '@kbn/security-plugin/server';
import { namespaceToSpaceId } from '@kbn/spaces-plugin/server/lib/utils/namespace';
import type { UserProfileUserInfo } from '@kbn/user-profile-components';
import { CASE_SAVED_OBJECT } from '../../../common/constants';
import type { CaseSavedObject } from '../../common/types';
Expand Down Expand Up @@ -90,8 +89,14 @@ export class EmailNotificationService implements NotificationService {
{
id: theCase.id,
type: CASE_SAVED_OBJECT,
// FIX: Should the spaceId be ["default"] if namespaces are undefined?
spaceIds: theCase.namespaces?.map(namespaceToSpaceId) ?? [],
/**
* Cases are not shareable at the moment from the UI
* The namespaces should be either undefined or contain
* only one item, the space the case got created. If we decide
* in the future to share cases in multiple spaces we need
* to change the logic.
*/
namespace: theCase.namespaces?.[0],
},
],
},
Expand Down

0 comments on commit 2458b2f

Please sign in to comment.