Skip to content

Commit

Permalink
Replace extra field directly with url
Browse files Browse the repository at this point in the history
For the sake of simplicity
  • Loading branch information
davelopez committed May 15, 2024
1 parent 935d048 commit 440d2db
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
20 changes: 10 additions & 10 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2637,11 +2637,6 @@ export interface components {
* @description Documentation or extended description for this plugin.
*/
doc: string;
/**
* Extra
* @description Extra configuration options that the plugin may serialize. This is plugin specific.
*/
extra?: Record<string, never> | null;
/**
* ID
* @description The `FilesSource` plugin identifier
Expand Down Expand Up @@ -2672,6 +2667,11 @@ export interface components {
* @description The URI root used by this type of plugin.
*/
uri_root: string;
/**
* URL
* @description Optional URL that might be provided by some plugins to link to the remote source.
*/
url?: string | null;
/**
* Writeable
* @description Whether this files source plugin allows write access.
Expand Down Expand Up @@ -5215,11 +5215,6 @@ export interface components {
* @description Documentation or extended description for this plugin.
*/
doc: string;
/**
* Extra
* @description Extra configuration options that the plugin may serialize. This is plugin specific.
*/
extra?: Record<string, never> | null;
/**
* ID
* @description The `FilesSource` plugin identifier
Expand All @@ -5245,6 +5240,11 @@ export interface components {
* @description The type of the plugin.
*/
type: string;
/**
* URL
* @description Optional URL that might be provided by some plugins to link to the remote source.
*/
url?: string | null;
/**
* Writeable
* @description Whether this files source plugin allows write access.
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Common/ExportRecordDOILink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function getDOIFromExportRecordUri(uri?: string) {
console.debug("No file source found for URI: ", uri);
return undefined;
}
const repositoryUrl = fileSource.extra?.url;
const repositoryUrl = fileSource.url;
if (!repositoryUrl) {
console.debug("Invalid repository URL for file source: ", fileSource);
return undefined;
Expand Down
15 changes: 7 additions & 8 deletions lib/galaxy/files/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import (
Any,
ClassVar,
Dict,
List,
Optional,
Set,
Expand Down Expand Up @@ -97,7 +96,7 @@ class FilesSourceProperties(TypedDict):
uri_root: NotRequired[str]
type: NotRequired[str]
browsable: NotRequired[bool]
extra: NotRequired[Dict[str, Any]]
url: NotRequired[Optional[str]]


@dataclass
Expand Down Expand Up @@ -301,7 +300,6 @@ def get_browsable(self) -> bool:

class BaseFilesSource(FilesSource):
plugin_kind: ClassVar[PluginKind] = PluginKind.rfs # Remote File Source by default, override in subclasses
serialize_extra_props: ClassVar[List[str]] = [] # Extra properties safe to serialize

def get_browsable(self) -> bool:
# Check whether the list method has been overridden
Expand Down Expand Up @@ -337,6 +335,10 @@ def get_uri_root(self) -> str:
root = uri_join(root, prefix)
return root

def get_url(self) -> Optional[str]:
"""Returns a URL that can be used to link to the remote source."""
return None

def to_relative_path(self, url: str) -> str:
return url.replace(self.get_uri_root(), "") or "/"

Expand Down Expand Up @@ -377,13 +379,10 @@ def to_dict(self, for_serialization=False, user_context: "OptionalUserContext" =
}
if self.get_browsable():
rval["uri_root"] = self.get_uri_root()
if self.get_url() is not None:
rval["url"] = self.get_url()
if for_serialization:
rval.update(self._serialization_props(user_context=user_context))
if self.serialize_extra_props:
extra_props = {}
for prop in self.serialize_extra_props:
extra_props[prop] = getattr(self, prop, None)
rval["extra"] = extra_props
return rval

def to_dict_time(self, ctime):
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/files/sources/_rdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class RDMFilesSourceProperties(FilesSourceProperties):
url: str
token: str
public_name: str

Expand Down Expand Up @@ -135,7 +134,6 @@ class RDMFilesSource(BaseFilesSource):
"""

plugin_kind = PluginKind.rdm
serialize_extra_props = ["url"]

def __init__(self, **kwd: Unpack[RDMFilesSourceProperties]):
props = self._parse_common_config_opts(kwd)
Expand All @@ -149,6 +147,9 @@ def __init__(self, **kwd: Unpack[RDMFilesSourceProperties]):
def repository(self) -> RDMRepositoryInteractor:
return self._repository_interactor

def get_url(self) -> Optional[str]:
return self.url

def get_repository_interactor(self, repository_url: str) -> RDMRepositoryInteractor:
"""Returns an interactor compatible with the given repository URL.
Expand Down
7 changes: 3 additions & 4 deletions lib/galaxy/schema/remote_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import Enum
from typing import (
Any,
Dict,
List,
Optional,
Union,
Expand Down Expand Up @@ -82,10 +81,10 @@ class FilesSourcePlugin(Model):
title="Requires groups",
description="Only users belonging to the groups specified here can access this files source.",
)
extra: Optional[Dict[str, Any]] = Field(
url: Optional[str] = Field(
None,
title="Extra",
description="Extra configuration options that the plugin may serialize. This is plugin specific.",
title="URL",
description="Optional URL that might be provided by some plugins to link to the remote source.",
)


Expand Down

0 comments on commit 440d2db

Please sign in to comment.