Skip to content

Commit c260cea

Browse files
author
Hang Le
committed
Merge branch 'bugfix/swapping-between-sharing-permissions' into 'devel'
Bugfix/swapping between sharing permissions Closes #1140 See merge request sds-dev/sd-connect/swift-browser-ui!178
2 parents 2c4eb8f + c1dea6e commit c260cea

File tree

6 files changed

+41
-37
lines changed

6 files changed

+41
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
184184
- (GL #1066) Fix for sharing/permissions not removed correctly
185185
- (GL #1078) Fix overwriting existing files with upload
186186
- (GL #1108) Fix deleting large amount of objects (~100 items) with long names
187-
- (GL #1125) Remove shared containers if the owner container is deleted
187+
- (GL #1140) Fix Sharing permissions swapping between options after sharing
188188

189189
### Removed
190190

swift_browser_ui/common/vault_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ async def get_project_whitelist(
319319
"""
320320
resp = await self._request(
321321
"GET",
322-
f"c4ghransit/sharing/{project}/{container}",
322+
f"c4ghtransit/sharing/{project}/{container}",
323323
params={"id": receiver},
324324
)
325325
return resp

swift_browser_ui_frontend/src/common/conv.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ export async function syncContainerACLs(store) {
113113
// Check if the shared access only concerns view rights
114114
let tmpid = await client.projectCheckIDs(share);
115115

116-
let whitelistUrl = new URL(
116+
let whitelistUrl = new URL(store.state.uploadEndpoint.concat(
117117
`/check/${store.state.active.name}/${container}/${tmpid.name}`,
118-
store.state.uploadEndpoint,
119-
);
118+
));
120119
let signatureUrl = new URL("/sign/3600", document.location.origin);
121120
signatureUrl.searchParams.append(
122121
"path",

swift_browser_ui_frontend/src/components/ContainerTable.vue

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export default {
7474
data() {
7575
return {
7676
containers: [],
77+
sharingContainers: [],
78+
sharedContainers: [],
7779
direction: "asc",
7880
footerOptions: {
7981
itemsPerPageOptions: [5, 10, 25, 50, 100],
@@ -106,7 +108,8 @@ export default {
106108
this.getPage();
107109
},
108110
conts() {
109-
this.getPage();
111+
Promise.all([this.getSharingContainers(), this.getSharedContainers()])
112+
.then(() => this.getPage());
110113
},
111114
showTimestamp() {
112115
this.getPage();
@@ -119,7 +122,7 @@ export default {
119122
openShareModal: function () {
120123
if(!this.openShareModal) {
121124
setTimeout(() => {
122-
this.getPage();
125+
this.getSharingContainers().then(() => this.getPage());
123126
}, 3000);
124127
}
125128
},
@@ -135,6 +138,14 @@ export default {
135138
this.abortController.abort();
136139
},
137140
methods: {
141+
async getSharingContainers () {
142+
this.sharingContainers =
143+
await getSharingContainers(this.active.id, this.abortController.signal);
144+
},
145+
async getSharedContainers () {
146+
this.sharedContainers =
147+
await getSharedContainers(this.active.id, this.abortController.signal);
148+
},
138149
async getPage () {
139150
let offset = 0;
140151
let limit = this.conts?.length;
@@ -148,15 +159,10 @@ export default {
148159
limit = this.paginationOptions.itemsPerPage;
149160
}
150161
151-
const sharingContainers =
152-
await getSharingContainers(this.active.id, this.abortController.signal);
153-
const sharedContainers =
154-
await getSharedContainers(this.active.id, this.abortController.signal);
155-
156162
const getSharedStatus = (folderName) => {
157-
if (sharingContainers.indexOf(folderName) > -1) {
163+
if (this.sharingContainers.indexOf(folderName) > -1) {
158164
return this.$t("message.table.sharing");
159-
} else if (sharedContainers.findIndex(
165+
} else if (this.sharedContainers.findIndex(
160166
cont => cont.container === folderName) > -1) {
161167
return this.$t("message.table.shared");
162168
}
@@ -373,21 +379,11 @@ export default {
373379
this.sortDirection = event.detail.direction;
374380
375381
if (this.sortBy === "sharing") {
376-
const sharingContainers =
377-
await getSharingContainers(
378-
this.active.id,
379-
this.abortController.signal,
380-
);
381-
const sharedContainers =
382-
await getSharedContainers(
383-
this.active.id,
384-
this.abortController.signal,
385-
);
386-
387-
let allSharing = this.conts.map(x => sharingContainers.includes(x.name)
388-
? this.$t("message.table.sharing") : "");
382+
let allSharing = this.conts.map(x =>
383+
this.sharingContainers.includes(x.name)
384+
? this.$t("message.table.sharing") : "");
389385
let allShared = this.conts.map(x =>
390-
sharedContainers.some(cont => cont.container === x.name)
386+
this.sharedContainers.some(cont => cont.container === x.name)
391387
? this.$t("message.table.shared") : "");
392388
393389
let combined = allSharing.map((value, idx) =>

swift_browser_ui_frontend/src/components/ShareModal.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export default {
178178
return {
179179
tags: [],
180180
openShareGuide: false,
181+
view: false,
181182
read: false,
182183
write: false,
183184
loading: false,
@@ -406,10 +407,11 @@ export default {
406407
signatureUrl.searchParams.append("path", `/cryptic/${this.$store.state.active.name}/${folder}`);
407408
let signed = await GET(signatureUrl);
408409
signed = await signed.json();
409-
let whitelistUrl = new URL(
410+
411+
let whitelistUrl = new URL(this.$store.state.uploadEndpoint.concat(
410412
`/cryptic/${this.$store.state.active.name}/${folder}`,
411-
this.$store.state.uploadEndpoint,
412-
);
413+
));
414+
413415
whitelistUrl.searchParams.append(
414416
"valid",
415417
signed.valid,

swift_browser_ui_frontend/src/components/ShareModalTable.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ export default {
164164
rights,
165165
);
166166
167+
await this.$store.state.client.shareEditAccess(
168+
this.projectId,
169+
`${this.folderName}_segments`,
170+
[sharedProjectId],
171+
rights,
172+
);
173+
167174
let projectIDs = await this.$store.state.client.projectCheckIDs(
168175
sharedProjectId,
169176
);
@@ -172,10 +179,10 @@ export default {
172179
signatureUrl.searchParams.append("path", `/cryptic/${this.$store.state.active.name}/${this.folderName}`);
173180
let signed = await GET(signatureUrl);
174181
signed = await signed.json();
175-
let whitelistUrl = new URL(
182+
183+
let whitelistUrl = new URL(this.$store.state.uploadEndpoint.concat(
176184
`/cryptic/${this.$store.state.active.name}/${this.folderName}`,
177-
this.$store.state.uploadEndpoint,
178-
);
185+
));
179186
whitelistUrl.searchParams.append(
180187
"valid",
181188
signed.valid,
@@ -239,10 +246,10 @@ export default {
239246
signatureUrl.searchParams.append("path", `/cryptic/${this.$store.state.active.name}/${this.folderName}`);
240247
let signed = await GET(signatureUrl);
241248
signed = await signed.json();
242-
let whitelistUrl = new URL(
249+
250+
let whitelistUrl = new URL(this.$store.state.uploadEndpoint.concat(
243251
`/cryptic/${this.$store.state.active.name}/${this.folderName}`,
244-
this.$store.state.uploadEndpoint,
245-
);
252+
));
246253
whitelistUrl.searchParams.append(
247254
"valid",
248255
signed.valid,

0 commit comments

Comments
 (0)