Skip to content

Commit 89c7337

Browse files
[VET-5328] get designer projects from cloud storage (#68)
* [VET-5328] get designer projects from cloud storage * added rename project * add mutation for project content * add create and delete project mutations
1 parent efeb6eb commit 89c7337

11 files changed

+404
-0
lines changed

src/__tests__/getCurrentConnectionFromPortal.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ describe('getCurrentConnectionFromPortal', () => {
1212
addShare: jest.fn(),
1313
getConnectionByIndex,
1414
getVoiceboxConversation: jest.fn(),
15+
createDesignerProject: jest.fn(),
16+
deleteDesignerProject: jest.fn(),
17+
getDesignerProject: jest.fn(),
18+
getDesignerProjects: jest.fn(),
1519
listConnections: jest.fn(),
1620
listVoiceboxConversations: jest.fn(),
1721
profile: jest.fn(),
22+
renameDesignerProject: jest.fn(),
1823
trackEvent: jest.fn(),
24+
updateDesignerProject: jest.fn(),
1925
});
2026

2127
jest

src/__tests__/getPortalSdk.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ jest.mock('../cookies', () => ({
1616

1717
const addShare = jest.fn(async () => ({ addShare: null }));
1818
const getConnectionByIndex = jest.fn(async () => ({ connection: null }));
19+
const createDesignerProject = jest.fn(async () => ({
20+
createDesignerProject: 'id',
21+
}));
22+
const deleteDesignerProject = jest.fn(async () => ({
23+
deleteDesignerProject: 'id',
24+
}));
25+
const getDesignerProject = jest.fn(async () => {
26+
return {
27+
getDesignerProject: {
28+
id: 'id',
29+
name: 'name',
30+
content: 'content',
31+
created_at: 'created_at',
32+
updated_at: 'updated_at',
33+
owner: { id: 'id', username: 'username' },
34+
roles: [],
35+
},
36+
};
37+
});
38+
const getDesignerProjects = jest.fn(async () => ({ getDesignerProjects: [] }));
1939
const getVoiceboxConversation = jest.fn(async () => ({
2040
getVoiceboxConversation: null,
2141
}));
@@ -25,18 +45,30 @@ const listVoiceboxConversations = jest.fn(async () => ({
2545
voiceboxConversationCount: null,
2646
}));
2747
const profile = jest.fn(async () => ({ profile: null }));
48+
const renameDesignerProject = jest.fn(async () => ({
49+
renameDesignerProject: 'id',
50+
}));
2851
const trackEvent = jest.fn(async () => ({ trackEvent: null }));
52+
const updateDesignerProject = jest.fn(async () => ({
53+
updateDesignerProject: 'id',
54+
}));
2955

3056
describe('getPortalSdk', () => {
3157
beforeEach(() => {
3258
jest.spyOn(portalSdkImport, 'getSdk').mockReturnValue({
3359
addShare,
3460
getConnectionByIndex,
61+
createDesignerProject,
62+
deleteDesignerProject,
63+
getDesignerProject,
64+
getDesignerProjects,
3565
getVoiceboxConversation,
3666
listConnections,
3767
listVoiceboxConversations,
3868
profile,
69+
renameDesignerProject,
3970
trackEvent,
71+
updateDesignerProject,
4072
});
4173
});
4274

src/getPortalSdk.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,36 @@ export const getPortalSdk = () => {
6262
const result = await sdk.getConnectionByIndex({ index });
6363
return result.connection || null;
6464
},
65+
createDesignerProject: async (name: string, content: string) => {
66+
const result = await sdk.createDesignerProject({ name, content });
67+
return result.createDesignerProject || null;
68+
},
69+
deleteDesignerProject: async (projectId: string) => {
70+
const result = await sdk.deleteDesignerProject({ project_id: projectId });
71+
return result.deleteDesignerProject || null;
72+
},
73+
getDesignerProject: async (projectId: string) => {
74+
const result = await sdk.getDesignerProject({ project_id: projectId });
75+
return result.getDesignerProject || null;
76+
},
77+
getDesignerProjects: async () => {
78+
const result = await sdk.getDesignerProjects();
79+
return result.getDesignerProjects || null;
80+
},
81+
renameDesignerProject: async (projectId: string, name: string) => {
82+
const result = await sdk.renameDesignerProject({
83+
project_id: projectId,
84+
name,
85+
});
86+
return result.renameDesignerProject || null;
87+
},
88+
updateDesignerProject: async (projectId: string, content: string) => {
89+
const result = await sdk.updateDesignerProject({
90+
project_id: projectId,
91+
content,
92+
});
93+
return result.updateDesignerProject || null;
94+
},
6595
getVoiceboxConversation: async (conversationId: string) => {
6696
const result = await sdk.getVoiceboxConversation({
6797
conversation_id: conversationId,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation createDesignerProject($name: String!, $content: Base64Bytes!) {
2+
createDesignerProject(name: $name, content: $content)
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation deleteDesignerProject($project_id: ID!) {
2+
deleteDesignerProject(project_id: $project_id)
3+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
query getDesignerProject($project_id: ID!) {
2+
getDesignerProject(project_id: $project_id) {
3+
id
4+
name
5+
content
6+
created_at
7+
updated_at
8+
owner {
9+
id
10+
username
11+
}
12+
roles {
13+
role
14+
user {
15+
id
16+
username
17+
}
18+
}
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
query getDesignerProjects {
2+
getDesignerProjects {
3+
id
4+
name
5+
created_at
6+
updated_at
7+
owner {
8+
id
9+
username
10+
}
11+
roles {
12+
role
13+
user {
14+
id
15+
username
16+
}
17+
}
18+
}
19+
}

src/sdk/documents/profileQuery.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ query profile {
2323
is_staff
2424
is_static_voicebox
2525
is_voicebox_enabled
26+
is_designer_storage_enabled
2627
}
2728
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation renameDesignerProject($project_id: ID!, $name: String!) {
2+
renameDesignerProject(project_id: $project_id, name: $name)
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation updateDesignerProject($project_id: ID!, $content: Base64Bytes!) {
2+
updateDesignerProject(project_id: $project_id, content: $content)
3+
}

0 commit comments

Comments
 (0)