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 9 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
96 changes: 95 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5997,6 +5997,87 @@ export interface components {
*/
visible: boolean;
};
/**
* HDAInaccessible
* @description History Dataset Association information when the user can not access it.
*/
HDAInaccessible: {
/**
* Accessible
* @constant
*/
accessible: Record<string, never>;
/** 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
Expand Down Expand Up @@ -6924,6 +7005,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 +7022,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 +13613,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 +13794,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 +16545,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 +17136,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 +17188,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 +17421,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 +17479,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 +17530,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 +17762,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
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const emit = defineEmits(["update:filter-text", "reloadContents"]);

const router = useRouter();
const { config } = useConfig();
const { currentUser } = storeToRefs(useUserStore());
const { currentUser, isAnonymous } = storeToRefs(useUserStore());
const { historySize, numItemsActive, numItemsDeleted, numItemsHidden } = useHistoryContentStats(
toRef(props, "history")
);
Expand Down Expand Up @@ -146,7 +146,7 @@ onMounted(() => {

<BButtonGroup v-if="currentUser">
<BButton
v-if="config && config.object_store_allows_id_selection"
v-if="config && config.object_store_allows_id_selection && !isAnonymous"
:id="`history-storage-${history.id}`"
title="Manage Preferred History Storage"
variant="link"
Expand All @@ -157,7 +157,7 @@ onMounted(() => {
</BButton>

<PreferredStorePopover
v-if="config && config.object_store_allows_id_selection"
v-if="config && config.object_store_allows_id_selection && !isAnonymous"
:history-id="history.id"
:history-preferred-object-store-id="historyPreferredObjectStoreId"
:user="currentUser">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ function updateFilterValue(filterKey: string, newValue: any) {
}

function getItemKey(item: HistoryItem) {
return item.type_id;
return itemUniqueKey(item);
martenson marked this conversation as resolved.
Show resolved Hide resolved
}

function itemUniqueKey(item: HistoryItem) {
Expand Down
2 changes: 2 additions & 0 deletions client/src/style/scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ $galaxy-state-border: (
"deleted": darken($state-default-border, 30%),
"hidden": $state-default-border,
"setting_metadata": $state-warning-border,
"inaccessible": darken($state-default-border, 10%),
);

$galaxy-state-bg: (
Expand All @@ -216,6 +217,7 @@ $galaxy-state-bg: (
"deleted": darken($state-default-bg, 30%),
"hidden": $state-default-bg,
"setting_metadata": $state-warning-bg,
"inaccessible": darken($state-default-bg, 10%),
);

@each $state in map-keys($galaxy-state-border) {
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class HDASummary(HDACommon):
class HDAInaccessible(HDACommon):
"""History Dataset Association information when the user can not access it."""

accessible: bool = AccessibleField
accessible: Literal[False]
state: DatasetStateField


Expand Down Expand Up @@ -3271,7 +3271,7 @@ class HDACustom(HDADetailed):
model_config = ConfigDict(extra="allow")


AnyHDA = Union[HDACustom, HDADetailed, HDASummary]
AnyHDA = Union[HDACustom, HDADetailed, HDASummary, HDAInaccessible]
AnyHDCA = Union[HDCADetailed, HDCASummary]
AnyHistoryContentItem = Annotated[
Union[
Expand Down
Loading