Skip to content

Commit 434d606

Browse files
committed
tests
1 parent f363497 commit 434d606

File tree

7 files changed

+202
-22
lines changed

7 files changed

+202
-22
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
"@pnp/spfx-controls-react": "3.15.0",
2222
"react": "17.0.1",
2323
"react-dom": "17.0.1",
24-
"tslib": "2.3.1"
24+
"tslib": "2.3.1",
25+
"@fluidframework/azure-client": "^2.50.0",
26+
"@fluidframework/odsp-client": "^2.50.0",
27+
"@fluidframework/telemetry-utils": "^2.50.0",
28+
"@fluidframework/test-runtime-utils": "^2.50.0",
29+
"fluid-framework": "^2.50.0"
2530
},
2631
"devDependencies": {
2732
"@microsoft/eslint-config-spfx": "1.18.2",

src/components/addSectionButton/AddSectionButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export const AddSectionButton: React.FC<IAddSectionButtonProps> = (props) => {
126126
section.JSONTemplate
127127
);
128128

129-
location.reload();
129+
//window.location.reload();
130+
//const url = new URL(window.location.href);
131+
//url.searchParams.set('Mode', 'View'); // Replace 'newParam' and 'value' with your desired parameter and value
132+
//window.location.href = url.toString();
130133
} catch (error) {
131134
console.error(strings.AddSectionFunctionError, error.message || error);
132135
throw error

src/components/copySectionButton/CopySectionsButton.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
display: inline;
3737
padding: 7px;
3838
font-size: 18px;
39-
font-weight: 600;
39+
font-weight: 500;
4040
cursor: pointer;
41+
color: #616161;
4142
}
4243
.footerButtons {
4344
margin: 20px 0;
@@ -51,5 +52,5 @@
5152
}
5253

5354
:global(#copyOptionsContainer) {
54-
margin-top: 6px;
55+
margin-top: 8px;
5556
}

src/services/SectionService.ts

Lines changed: 152 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,160 @@ export class SectionService implements ISectionService {
109109
column.position.zoneIndex = newSectionIndex;
110110
column.position.zoneId = newZoneId;
111111
}
112-
112+
113113
canvasContent = canvasContent.concat(newSection);
114114

115-
await this.spHttpClient.post(
116-
`${currentWeb}/_api/sitepages/pages(${currentPageId})/savepage`,
117-
SPHttpClient.configurations.v1,
118-
{
119-
headers: {
120-
'accept': 'application/json;odata=nometadata',
121-
'content-type': 'application/json;odata=nometadata',
122-
'If-Match': '*'
123-
},
124-
body: JSON.stringify({
125-
CanvasContent1: JSON.stringify(canvasContent)
126-
})
127-
}
128-
);
115+
if (true) {
116+
117+
118+
/*if (!pageContentJson.IsPageCheckedOutToCurrentUser) {
119+
120+
await this.spHttpClient.post(
121+
`${currentWeb}/_api/web/GetFileByServerRelativePath(DecodedUrl=@a1)/CheckOut?@a1=%27%2Fsites%2FMediaPark%2FSitePages%2Ftest%281%29%2Easpx%27`,
122+
SPHttpClient.configurations.v1,
123+
{
124+
125+
126+
}
127+
);
128+
129+
}*/
130+
131+
132+
/*await this.spHttpClient.post(
133+
`https://mknetpl.sharepoint.com/_api/v2.1/drives/b!Z-jDRnmYHkOW-wMtAMqXjf801B2I88lLjnyxyQ7wiQc6VZAxUHixRo-E_ABgbWlu/items/4566ae2c-c701-4aab-9565-decf2e01853a/opStream/joinSession?ump=1`,
134+
SPHttpClient.configurations.v1,
135+
{
136+
headers: {
137+
'If-Match': '*'
138+
},
139+
body: JSON.stringify({
140+
"authoringMetadata":
141+
{
142+
"SessionId": pageContentJson.AuthoringMetadata.SessionId,
143+
"SequenceId": pageContentJson.AuthoringMetadata.SequenceId,
144+
"FluidContainerCustomId": pageContentJson.AuthoringMetadata.FluidContainerCustomId,
145+
"IsSingleUserSession": true,
146+
"ClientOperation": 2
147+
},
148+
"connectivityUpdateReason": 1
149+
})
150+
151+
}
152+
);*/
153+
154+
155+
/*await this.spHttpClient.post(
156+
`${currentWeb}/_api/sitepages/pages(${currentPageId})/ExtendSessionCoAuth`,
157+
SPHttpClient.configurations.v1,
158+
{
159+
headers: {
160+
'If-Match': '*'
161+
},
162+
body: JSON.stringify({
163+
"authoringMetadata":
164+
{
165+
"SessionId": pageContentJson.AuthoringMetadata.SessionId,
166+
"SequenceId": pageContentJson.AuthoringMetadata.SequenceId,
167+
"FluidContainerCustomId": pageContentJson.AuthoringMetadata.FluidContainerCustomId,
168+
"IsSingleUserSession": true,
169+
"ClientOperation": 2
170+
},
171+
"connectivityUpdateReason": 1
172+
})
173+
174+
}
175+
);*/
176+
177+
const pageSeqData = await this.spHttpClient.get(
178+
`https://mknetpl.sharepoint.com/_api/v2.1/drives/b!Z-jDRnmYHkOW-wMtAMqXjf801B2I88lLjnyxyQ7wiQc6VZAxUHixRo-E_ABgbWlu/items/4566ae2c-c701-4aab-9565-decf2e01853a/opStream?ump=1&filter=sequenceNumber%20ge%20${pageContentJson.AuthoringMetadata.SequenceId}%20and%20sequenceNumber%20le%205106`,
179+
SPHttpClient.configurations.v1
180+
);
181+
const pageSeqDataJson = await pageSeqData.json();
182+
183+
184+
const getLatestSequenceId = pageSeqDataJson.value[pageSeqDataJson.value.length - 1].sequenceNumber;
185+
186+
const pageCoSaveResult = await this.spHttpClient.post(
187+
`${currentWeb}/_api/sitepages/pages(${currentPageId})/SavePageCoAuth`,
188+
SPHttpClient.configurations.v1,
189+
{
190+
headers: {
191+
'If-Match': '*'
192+
},
193+
body: JSON.stringify({
194+
//AuthorByline:[],
195+
//BannerImageUrl: pageContentJson.BannerImageUrl,
196+
CanvasContent1: JSON.stringify(canvasContent),
197+
//LayoutWebpartsContent: pageContentJson.LayoutWebpartsContent,
198+
//Title: pageContentJson.Title,
199+
//TopicHeader: pageContentJson.TopicHeader,
200+
// WebTranspileContent: pageContentJson.WebTranspileContent,
201+
AuthoringMetadata: {
202+
ClientOperation: 3,
203+
//ClientOperation: 2,
204+
FluidContainerCustomId: pageContentJson.AuthoringMetadata.FluidContainerCustomId,
205+
IsSingleUserSession: true,
206+
SequenceId: getLatestSequenceId,
207+
SessionId: pageContentJson.AuthoringMetadata.SessionId
208+
},
209+
CoAuthState: {
210+
Action: 1,
211+
//LockAction: 1,
212+
LockAction: 2,
213+
SharedLockId: pageContentJson.CoAuthState?.SharedLockId
214+
},
215+
Collaborators: [
216+
//{ LoginName: "mkornet@mknetpl.onmicrosoft.com" }
217+
]
218+
})
219+
}
220+
);
221+
222+
223+
const pageCoSaveResultJson = await pageCoSaveResult.json();
224+
console.log('Page co-save result:', pageCoSaveResultJson);
225+
226+
227+
228+
/*await this.spHttpClient.post(
229+
`${currentWeb}/_api/sitepages/pages(${currentPageId})/ExtendSessionCoAuth`,
230+
SPHttpClient.configurations.v1,
231+
{
232+
headers: {
233+
'If-Match': '*'
234+
},
235+
body: JSON.stringify({
236+
"authoringMetadata":
237+
{
238+
"SessionId": pageContentJson.AuthoringMetadata.SessionId,
239+
"SequenceId": pageContentJson.AuthoringMetadata.SequenceId,
240+
"FluidContainerCustomId": pageContentJson.AuthoringMetadata.FluidContainerCustomId,
241+
"IsSingleUserSession": true,
242+
"ClientOperation": 2
243+
},
244+
"connectivityUpdateReason": 1
245+
})
246+
247+
}
248+
);*/
249+
}
250+
else {
251+
await this.spHttpClient.post(
252+
`${currentWeb}/_api/sitepages/pages(${currentPageId})/savepage`,
253+
SPHttpClient.configurations.v1,
254+
{
255+
headers: {
256+
'accept': 'application/json;odata=nometadata',
257+
'content-type': 'application/json;odata=nometadata',
258+
'If-Match': '*'
259+
},
260+
body: JSON.stringify({
261+
CanvasContent1: JSON.stringify(canvasContent)
262+
})
263+
}
264+
);
265+
}
129266
} catch (error) {
130267
console.error('Error adding section to page:', error);
131268
throw error;

ztest.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
"CoAuthState": {
3+
"SharedLockId": "c0eea935-a62f-42c9-87e4-4c60b0339db7",
4+
"Action": 2,
5+
"LockAction": 1
6+
},
7+
"AuthoringMetadata": {
8+
"SessionId": "c0eea935-a62f-42c9-87e4-4c60b0339db7",
9+
"SequenceId": 136,
10+
"FluidContainerCustomId": "61ca86f7-8ab0-40b6-aa5c-10ee5b1d43cd",
11+
"IsSingleUserSession": true,
12+
"ClientOperation": 2
13+
},
14+
"Collaborators": [
15+
{
16+
"LoginName": "mkornet@mknetpl.onmicrosoft.com"
17+
}
18+
]
19+
}

ztest1.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
"CoAuthState": {
3+
"SharedLockId": "c0eea935-a62f-42c9-87e4-4c60b0339db7",
4+
"Action": 1,
5+
"LockAction": 2
6+
},
7+
"AuthoringMetadata": {
8+
"SessionId": "c0eea935-a62f-42c9-87e4-4c60b0339db7",
9+
"SequenceId": 136,
10+
"FluidContainerCustomId": "61ca86f7-8ab0-40b6-aa5c-10ee5b1d43cd",
11+
"IsSingleUserSession": true,
12+
"ClientOperation": 3
13+
},
14+
"Collaborators": []
15+
}

0 commit comments

Comments
 (0)