Skip to content

Commit

Permalink
Refactor FilesSourceSupports in FilesSourceProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 13, 2024
1 parent 1aaf0f3 commit 0917eda
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
39 changes: 39 additions & 0 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,15 @@ export interface components {
* @description Only users with the roles specified here can access this files source.
*/
requires_roles?: string | null;
/**
* @description Features supported by this file source.
* @default {
* "pagination": false,
* "search": false,
* "sorting": false
* }
*/
supports?: components["schemas"]["FilesSourceSupports"];
/**
* Type
* @description The type of the plugin.
Expand Down Expand Up @@ -5231,6 +5240,15 @@ export interface components {
* @description Only users with the roles specified here can access this files source.
*/
requires_roles?: string | null;
/**
* @description Features supported by this file source.
* @default {
* "pagination": false,
* "search": false,
* "sorting": false
* }
*/
supports?: components["schemas"]["FilesSourceSupports"];
/**
* Type
* @description The type of the plugin.
Expand All @@ -5250,6 +5268,27 @@ export interface components {
| components["schemas"]["BrowsableFilesSourcePlugin"]
| components["schemas"]["FilesSourcePlugin"]
)[];
/** FilesSourceSupports */
FilesSourceSupports: {
/**
* Pagination
* @description Whether this file source supports server-side pagination.
* @default false
*/
pagination?: boolean;
/**
* Search
* @description Whether this file source supports server-side search.
* @default false
*/
search?: boolean;
/**
* Sorting
* @description Whether this file source supports server-side sorting.
* @default false
*/
sorting?: boolean;
};
/** FillStepDefaultsAction */
FillStepDefaultsAction: {
/**
Expand Down
23 changes: 17 additions & 6 deletions lib/galaxy/files/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ class PluginKind(str, Enum):
"""


class FileSourceSupports(TypedDict):
"""Feature support flags for a file source plugin"""

# Indicates whether the file source supports pagination for listing files
pagination: NotRequired[bool]
# Indicates whether the file source supports server-side search for listing files
search: NotRequired[bool]
# Indicates whether the file source supports server-side sorting for listing files
sorting: NotRequired[bool]


class FilesSourceProperties(TypedDict):
"""Initial set of properties used to initialize a filesource.
Expand All @@ -98,9 +109,7 @@ class FilesSourceProperties(TypedDict):
uri_root: NotRequired[str]
type: NotRequired[str]
browsable: NotRequired[bool]
supports_pagination: NotRequired[bool]
supports_search: NotRequired[bool]
supports_sorting: NotRequired[bool]
supports: NotRequired[FileSourceSupports]


@dataclass
Expand Down Expand Up @@ -383,9 +392,11 @@ def to_dict(self, for_serialization=False, user_context: "OptionalUserContext" =
"browsable": self.get_browsable(),
"requires_roles": self.requires_roles,
"requires_groups": self.requires_groups,
"supports_pagination": self.supports_pagination,
"supports_search": self.supports_search,
"supports_sorting": self.supports_sorting,
"supports": {
"pagination": self.supports_pagination,
"search": self.supports_search,
"sorting": self.supports_sorting,
},
}
if self.get_browsable():
rval["uri_root"] = self.get_uri_root()
Expand Down
10 changes: 10 additions & 0 deletions lib/galaxy/schema/remote_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class RemoteFilesDisableMode(str, Enum):
files = "files"


class FilesSourceSupports(Model):
pagination: Annotated[bool, Field(description="Whether this file source supports server-side pagination.")] = False
search: Annotated[bool, Field(description="Whether this file source supports server-side search.")] = False
sorting: Annotated[bool, Field(description="Whether this file source supports server-side sorting.")] = False


class FilesSourcePlugin(Model):
id: str = Field(
...,
Expand Down Expand Up @@ -82,6 +88,10 @@ class FilesSourcePlugin(Model):
title="Requires groups",
description="Only users belonging to the groups specified here can access this files source.",
)
supports: Annotated[
FilesSourceSupports,
Field(default=..., description="Features supported by this file source."),
] = FilesSourceSupports()


class BrowsableFilesSourcePlugin(FilesSourcePlugin):
Expand Down

0 comments on commit 0917eda

Please sign in to comment.