Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get permissions during lazy-load; reduce bucket permissions requests #167

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/src/components/object/ObjectFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const searching = ref(false);
const selectedMetadata: Ref<MetadataPair[]> = ref([]);
const selectedTags: Ref<Tag[]> = ref([]);

// Emits
const emit = defineEmits(['selectedFilters']);

// Store subscriptions
objectStore.$onAction(({ name, args }) => {
// If someone calls fetchObjects to refresh the table, clear the filter
Expand Down Expand Up @@ -118,7 +121,7 @@ const selectedFilterValuesChanged = () => {
// Get the 'display' property out from selected tag and metadata
const metaToSearch: Array<MetadataPair> = selectedMetadata.value.map(({ ...meta }: any) => meta);
const tagSetToSearch: Array<Tag> = selectedTags.value.map(({ ...tag }: any) => tag);

emit('selectedFilters', { metaToSearch, tagSetToSearch });
// Search the object store with the tagset as a param and metadata as headers
objectStore.fetchObjects(
{
Expand Down
18 changes: 0 additions & 18 deletions frontend/src/components/object/ObjectList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { computed, onMounted, ref } from 'vue';

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'onMounted' is defined but never used

Check warning on line 3 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'onMounted' is defined but never used

import {
DeleteObjectButton,
Expand All @@ -26,7 +26,7 @@
});

// Store
const bucketStore = useBucketStore();

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bucketStore' is assigned a value but never used

Check warning on line 29 in frontend/src/components/object/ObjectList.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bucketStore' is assigned a value but never used
//const navStore = useNavStore();
const objectStore = useObjectStore();
const permissionStore = usePermissionStore();
Expand Down Expand Up @@ -57,24 +57,6 @@
const closeUpload = () => {
displayUpload.value = false;
};

// const updateBreadcrumb = async () => {
// try {
// const bucket = await bucketStore.getBucketInfo(props.bucketId as string);
// navStore.replace('__listObjectsDynamic', bucket?.bucketName ?? 'Unknown bucket');
// } catch (error: any) {
// toast.add({ severity: 'error', summary: 'Unable to load bucket information.', detail: error, life: 5000 });
// }
// };

onMounted(async () => {
// Removed for now
// updateBreadcrumb();

await bucketStore.fetchBuckets({ userId: getUserId.value, objectPerms: true });
// TODO: userId+bucketPerms bringing back deleted files??
await objectStore.fetchObjects({ bucketId: props.bucketId, userId: getUserId.value, bucketPerms: true });
});
</script>

<template>
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/components/object/ObjectProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
// Props
type Props = {
objectId: string;
versionId?: string;
// versionId?: string;
fullView: boolean;
};

const props = withDefaults(defineProps<Props>(), {
versionId: undefined
// versionId: undefined
});

// Store
const bucketStore = useBucketStore();
const metadataStore = useMetadataStore();

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'metadataStore' is assigned a value but never used

Check warning on line 26 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'metadataStore' is assigned a value but never used
const objectStore = useObjectStore();
const userStore = useUserStore();
const { getUserSearch } = storeToRefs(userStore);
Expand All @@ -32,17 +32,18 @@
const bucket: Ref<Bucket | undefined> = ref(undefined);
const createdBy: Ref<string | undefined> = ref(undefined);
const object: Ref<COMSObject | undefined> = ref(undefined);
const objectMetadata: Ref<Metadata | undefined> = ref(undefined);

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'objectMetadata' is assigned a value but never used

Check warning on line 35 in frontend/src/components/object/ObjectProperties.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'objectMetadata' is assigned a value but never used
const updatedBy: Ref<string | undefined> = ref(undefined);

// Actions
async function load() {
object.value = objectStore.findObjectById(props.objectId);
await bucketStore.fetchBuckets({ bucketId: object.value?.bucketId });
bucket.value = bucketStore.findBucketById(object.value?.bucketId as string);

if (props.fullView) {
objectMetadata.value = metadataStore.findMetadataByObjectId(object.value?.id as string);
// to get bucket name
await bucketStore.fetchBuckets({ bucketId: object.value?.bucketId });
bucket.value = bucketStore.findBucketById(object.value?.bucketId as string);

await userStore.fetchUsers({ userId: [object.value?.createdBy, object.value?.updatedBy] });
createdBy.value = getUserSearch.value.find((x) => x.userId === object.value?.createdBy)?.fullName;
updatedBy.value = getUserSearch.value.find((x) => x.userId === object.value?.updatedBy)?.fullName;
Expand Down
Loading
Loading