Skip to content

Commit 4ed223e

Browse files
authored
Merge pull request #871 from CSCfi/bugfix/fixes-for-data-table
Bugfix/fixes for data table
2 parents a323799 + ccccd73 commit 4ed223e

File tree

7 files changed

+62
-41
lines changed

7 files changed

+62
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5555
- Made modal's scroll position to be always on top when opening a modal
5656
- Add tooltip for Copy Share ID button
5757
- Fine-tuned modals' font sizes and gaps between elements
58+
- (GH #871) Fixed for data table's folders' Options, sorting functionality, and modals' widths
5859
- (GH #858) Fixed for multiple bugs related to modals and background page's scrolling effect
5960
- (GH #853) Fix Node 18 needing python for npm install
6061
- (GH #827) Fixed for updating folder's items count and size when deleting objects inside it

swift_browser_ui_frontend/src/common/conv.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ export function tokenize(text, ignoreSmallerThan = 2) {
279279
export const DEV = process.env.NODE_ENV === "development";
280280

281281
export function sortObjects(objects, sortBy, sortDirection) {
282-
sortBy = sortBy === "size" ? "bytes" : sortBy;
282+
sortBy = sortBy === "size" ? "bytes"
283+
: sortBy === "items" ? "count" : sortBy;
283284

284285
objects.sort((a, b) => {
285286
let valueA = a[sortBy];
@@ -292,18 +293,18 @@ export function sortObjects(objects, sortBy, sortDirection) {
292293
}
293294

294295
if (typeof valueA === "string") {
296+
valueA = valueA.toLowerCase();
297+
valueB = valueB.toLowerCase();
295298
if (sortDirection === "asc") {
296-
return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
299+
return valueA < valueB ? -1 : valueA > valueB ? 1 : 0;
297300
}
298-
299-
return valueB.toLowerCase().localeCompare(valueA.toLowerCase());
301+
return valueB < valueA ? -1 : valueB > valueA ? 1 : 0;
300302
}
301303

302304
if (typeof valueA === "number") {
303305
if (sortDirection === "asc") {
304306
return valueA - valueB;
305307
}
306-
307308
return valueB - valueA;
308309
}
309310
});

swift_browser_ui_frontend/src/common/globalFunctions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,18 @@ export async function getSharedContainers (projectId) {
5353
: [];
5454
}
5555

56+
export async function getAccessDetails (
57+
projectId,
58+
folderName,
59+
sourceProjectId)
60+
{
61+
return store.state.client
62+
? await store.state.client.getAccessDetails(
63+
projectId,
64+
folderName,
65+
sourceProjectId)
66+
: [];
67+
}
68+
5669

5770

swift_browser_ui_frontend/src/components/ContainerTable.vue

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
toggleCreateFolderModal,
2828
getSharingContainers,
2929
getSharedContainers,
30+
getAccessDetails,
3031
toggleCopyFolderModal,
3132
} from "@/common/globalFunctions";
3233
import {swiftDeleteContainer} from "@/common/api";
@@ -139,7 +140,18 @@ export default {
139140
return "";
140141
};
141142
142-
this.containers = this.conts.slice(offset, offset + limit).reduce((
143+
// Map the 'accessRights' to the container if it's a shared container
144+
const mappedContainers = await Promise.all(this.conts.map(async(cont) => {
145+
const sharedDetails = cont.owner ? await getAccessDetails(
146+
this.$route.params.project,
147+
cont.container,
148+
cont.owner) : null;
149+
const accessRights = sharedDetails ? sharedDetails.access : null;
150+
return sharedDetails && accessRights ?
151+
{...cont, accessRights} : {...cont};
152+
}));
153+
154+
this.containers = mappedContainers.slice(offset, offset + limit).reduce((
143155
items,
144156
item,
145157
) => {
@@ -230,35 +242,24 @@ export default {
230242
},
231243
},
232244
// Share button is disabled for Shared (with you) Folders
233-
item.owner ?
234-
{
235-
value: null,
236-
component: {
237-
tag: "c-button",
238-
params: {
239-
text: true,
240-
size: "small",
241-
disabled: true,
242-
},
243-
},
244-
} :
245-
{
246-
value: this.$t("message.share.share"),
247-
component: {
248-
tag: "c-button",
249-
params: {
250-
text: true,
251-
size: "small",
252-
title: this.$t("message.share.share"),
253-
path: mdiShareVariantOutline,
254-
onClick: (item) => {
255-
this.$store.commit("toggleShareModal", true);
256-
this.$store.commit(
257-
"setFolderName", item.data.name.value);
258-
},
245+
{
246+
value: this.$t("message.share.share"),
247+
component: {
248+
tag: "c-button",
249+
params: {
250+
text: true,
251+
size: "small",
252+
title: this.$t("message.share.share"),
253+
path: mdiShareVariantOutline,
254+
onClick: (item) => {
255+
this.$store.commit("toggleShareModal", true);
256+
this.$store.commit(
257+
"setFolderName", item.data.name.value);
259258
},
259+
disabled: item.owner,
260260
},
261261
},
262+
},
262263
{
263264
value: null,
264265
component: {
@@ -267,7 +268,7 @@ export default {
267268
items: [
268269
{
269270
name: this.$t("message.copy"),
270-
action: item.owner
271+
action: item.owner
271272
? () => toggleCopyFolderModal(item.name, item.owner)
272273
: () => toggleCopyFolderModal(item.name),
273274
disabled: !item.bytes ? true : false,
@@ -281,22 +282,24 @@ export default {
281282
action: () => this.confirmDelete(
282283
item.name, item.count,
283284
),
285+
disabled: item.owner && item.accessRights.length > 1,
284286
},
285287
],
286288
customTrigger: {
287289
value: this.$t("message.options"),
290+
disabled: true,
288291
component: {
289292
tag: "c-button",
290293
params: {
291294
text: true,
292295
path: mdiDotsHorizontal,
293296
title: "Menu with custom trigger",
294297
size: "small",
298+
disabled: item.owner
299+
&& item.accessRights.length === 1,
295300
},
296301
},
297302
},
298-
path: mdiDotsHorizontal,
299-
300303
},
301304
},
302305
},

swift_browser_ui_frontend/src/components/Containers.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ export default {
9494
});
9595
}
9696
else if (this.$route.name === "SharedTo") {
97-
this.renderingContainers = this.containers.filter(cont =>
98-
cont.owner,
99-
);
97+
this.renderingContainers = this.containers ?
98+
this.containers.filter(cont => cont.owner) : [];
10099
} else {
101100
this.renderingContainers = this.containers;
102101
}

swift_browser_ui_frontend/src/components/ObjectTable.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@
114114
<script>
115115
import { swiftDeleteObjects } from "@/common/api";
116116
import { getHumanReadableSize, truncate } from "@/common/conv";
117-
import { getSharedContainers } from "@/common/globalFunctions";
117+
import {
118+
getSharedContainers,
119+
getAccessDetails,
120+
} from "@/common/globalFunctions";
118121
import { liveQuery } from "dexie";
119122
import { useObservable } from "@vueuse/rxjs";
120123
import CObjectTable from "@/components/CObjectTable";
@@ -296,7 +299,7 @@ export default {
296299
cont => cont.container === this.container) > -1) {
297300
this.isSharedFolder = true;
298301
const sharedDetails
299-
= await this.client.getAccessDetails(
302+
= await getAccessDetails(
300303
this.project,
301304
this.container,
302305
this.$route.params.owner,

swift_browser_ui_frontend/src/pages/BrowserPage.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<c-modal
1111
v-control
1212
v-csc-model="openCreateFolderModal"
13+
width="64vw"
1314
>
1415
<CreateFolderModal />
1516
</c-modal>
@@ -34,7 +35,7 @@
3435
<c-modal
3536
v-control
3637
v-csc-model="openShareModal"
37-
width="50vw"
38+
width="64vw"
3839
>
3940
<ShareModal />
4041
</c-modal>

0 commit comments

Comments
 (0)