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

[24.0] do not expand datasets that are known to be inaccessible #17818

Merged
merged 14 commits into from
May 25, 2024
Merged
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
14 changes: 9 additions & 5 deletions client/openapi_to_schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ const inputFilePath = process.argv[2];
const localPath = new URL(inputFilePath, import.meta.url);
openapiTS(localPath, {
transform(schemaObject, metadata) {
if (
"const" in schemaObject &&
(typeof schemaObject.const === "string" || schemaObject.const instanceof String)
) {
return `"${schemaObject.const}"`;
if ("const" in schemaObject) {
const constType = typeof schemaObject.const;
switch (constType) {
case "number":
case "boolean":
return `${schemaObject.const}`;
default:
return `"${schemaObject.const}"`;
}
}
},
}).then((output) => console.log(output));
11 changes: 10 additions & 1 deletion client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export type DatasetSummary = components["schemas"]["HDASummary"];
*/
export type DatasetDetails = components["schemas"]["HDADetailed"];

/**
* Represents a HistoryDatasetAssociation that is inaccessible to the user.
*/
export type HDAInaccessible = components["schemas"]["HDAInaccessible"];

/**
* Contains storage (object store, quota, etc..) details for a dataset.
*/
Expand All @@ -97,7 +102,7 @@ export type DatasetStorageDetails = components["schemas"]["DatasetStorageDetails
/**
* Represents a HistoryDatasetAssociation with either summary or detailed information.
*/
export type DatasetEntry = DatasetSummary | DatasetDetails;
export type DatasetEntry = DatasetSummary | DatasetDetails | HDAInaccessible;

/**
* Contains summary information about a DCE (DatasetCollectionElement).
Expand Down Expand Up @@ -183,6 +188,10 @@ export function hasDetails(entry: DatasetEntry): entry is DatasetDetails {
return "peek" in entry;
}

export function isInaccessible(entry: DatasetEntry): entry is HDAInaccessible {
return "accessible" in entry && !entry.accessible;
}

/**
* Contains dataset metadata information.
*/
Expand Down
98 changes: 97 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5997,11 +5997,94 @@ export interface components {
*/
visible: boolean;
};
/**
* HDAInaccessible
* @description History Dataset Association information when the user can not access it.
*/
HDAInaccessible: {
/**
* Accessible
* @constant
*/
accessible: false;
/** Copied From Ldda Id */
copied_from_ldda_id?: string | null;
/**
* Create Time
* @description The time and date this item was created.
*/
create_time: string | null;
/**
* Deleted
* @description Whether this item is marked as deleted.
*/
deleted: boolean;
/**
* HID
* @description The index position of this item in the History.
*/
hid: number;
/**
* History Content Type
* @description This is always `dataset` for datasets.
* @constant
*/
history_content_type: "dataset";
/**
* History ID
* @example 0123456789ABCDEF
*/
history_id: string;
/**
* Id
* @example 0123456789ABCDEF
*/
id: string;
/**
* Name
* @description The name of the item.
*/
name: string | null;
/**
* State
* @description The current state of this dataset.
*/
state: components["schemas"]["DatasetState"];
tags: components["schemas"]["TagCollection"];
/**
* Type
* @description The type of this item.
*/
type: string;
/**
* Type - ID
* @description The type and the encoded ID of this item. Used for caching.
*/
type_id?: string | null;
/**
* Update Time
* @description The last time and date this item was updated.
*/
update_time: string | null;
/**
* URL
* @deprecated
* @description The relative URL to access this item.
*/
url: string;
/**
* Visible
* @description Whether this item is visible or hidden to the user by default.
*/
visible: boolean;
};
/**
* HDAObject
* @description History Dataset Association Object
*/
HDAObject: {
/** Accessible */
accessible?: boolean | null;
/** Copied From Ldda Id */
copied_from_ldda_id?: string | null;
/**
Expand Down Expand Up @@ -6924,6 +7007,7 @@ export interface components {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand All @@ -6940,6 +7024,7 @@ export interface components {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand Down Expand Up @@ -13530,6 +13615,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand Down Expand Up @@ -13710,7 +13796,8 @@ export interface operations {
"application/json":
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"];
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"];
};
};
/** @description Validation Error */
Expand Down Expand Up @@ -16460,12 +16547,14 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
| (
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand Down Expand Up @@ -17049,6 +17138,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"];
};
Expand Down Expand Up @@ -17100,6 +17190,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"];
};
Expand Down Expand Up @@ -17332,12 +17423,14 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
| (
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand Down Expand Up @@ -17388,6 +17481,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"];
};
Expand Down Expand Up @@ -17438,6 +17532,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"];
};
Expand Down Expand Up @@ -17669,6 +17764,7 @@ export interface operations {
| components["schemas"]["HDACustom"]
| components["schemas"]["HDADetailed"]
| components["schemas"]["HDASummary"]
| components["schemas"]["HDAInaccessible"]
| components["schemas"]["HDCADetailed"]
| components["schemas"]["HDCASummary"]
)[];
Expand Down
21 changes: 16 additions & 5 deletions client/src/components/History/Content/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ const contentId = computed(() => {

const contentCls = computed(() => {
const status = contentState.value && contentState.value.status;
if (props.selected) {
if (props.item.accessible === false) {
return "alert-inaccessible";
} else if (props.selected) {
return "alert-info";
} else if (!status) {
return `alert-success`;
} else {
return `alert-${status}`;
}
});

const contentState = computed(() => {
return STATES[state.value] && STATES[state.value];
});
Expand All @@ -116,6 +117,9 @@ const state = computed<keyof StateMap>(() => {
if (props.isPlaceholder) {
return "placeholder";
}
if (props.item.accessible === false) {
return "inaccessible";
}
if (props.item.populated_state === "failed") {
return "failed_populated_state";
}
Expand All @@ -135,7 +139,13 @@ const state = computed<keyof StateMap>(() => {
});

const dataState = computed(() => {
return state.value === "new_populated_state" ? "new" : state.value;
if (props.item.accessible === false) {
return "inaccessible";
} else if (state.value === "new_populated_state") {
return "new";
} else {
return state.value;
}
});

const tags = computed(() => {
Expand Down Expand Up @@ -334,7 +344,7 @@ function unexpandedClick(event: Event) {
:data-state="dataState"
tabindex="0"
role="button"
draggable
:draggable="props.item.accessible === false ? false : true"
@dragstart="onDragStart"
@dragend="onDragEnd"
@keydown="onKeyDown">
Expand Down Expand Up @@ -428,8 +438,9 @@ function unexpandedClick(event: Event) {
</span>
<!-- collections are not expandable, so we only need the DatasetDetails component here -->
<BCollapse :visible="expandDataset" class="px-2 pb-2">
<div v-if="item.accessible === false">You are not allowed to access this dataset</div>
<DatasetDetails
v-if="expandDataset && item.id"
v-else-if="expandDataset && item.id"
:id="item.id"
:writable="writable"
:show-highlight="(isHistoryItem && filterable) || addHighlightBtn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { BLink } from "bootstrap-vue";
import { computed } from "vue";

import { hasDetails } from "@/api";
import { STATES } from "@/components/History/Content/model/states";
import { useDatasetStore } from "@/stores/datasetStore";

Expand All @@ -26,6 +27,7 @@ const props = withDefaults(defineProps<Props>(), {

const emit = defineEmits<{
(e: "toggleHighlights"): void;
(e: "edit"): void;
}>();

const result = computed(() => datasetStore.getDataset(props.id));
Expand All @@ -40,7 +42,7 @@ function toggleHighlights() {

<template>
<div>
<div v-if="result && !isLoading" class="dataset">
<div v-if="result && !isLoading && hasDetails(result)" class="dataset">
<div class="details not-loading">
<div class="summary">
<div v-if="stateText" class="mb-1">{{ stateText }}</div>
Expand Down
14 changes: 13 additions & 1 deletion client/src/components/History/Content/model/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import type { components } from "@/api/schema";

type DatasetState = components["schemas"]["DatasetState"];
// The 'failed' state is for the collection job state summary, not a dataset state.
type State = DatasetState | "failed" | "placeholder" | "failed_populated_state" | "new_populated_state";
type State =
| DatasetState
| "failed"
| "placeholder"
| "failed_populated_state"
| "new_populated_state"
| "inaccessible";

interface StateRepresentation {
status: "success" | "warning" | "info" | "danger" | "secondary";
Expand Down Expand Up @@ -120,6 +126,12 @@ export const STATES: StateMap = {
icon: "clock",
nonDb: true,
},
inaccessible: {
status: "warning",
text: "User not allowed to access this dataset.",
icon: "lock",
nonDb: true,
},
} as const satisfies StateMap;

/** We want to display a single state for a dataset collection whose elements may have mixed states.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function updateDsc(collection: any, fields: Object | undefined) {
}

function getItemKey(item: DCESummary) {
return item.id;
return `${item.element_type}-${item.id}`;
}

function onScroll(newOffset: number) {
Expand Down
Loading
Loading