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

Make the icons in application menu configurable (external services, metadata domains) #1519

Merged
merged 9 commits into from
May 1, 2024

Conversation

ewelinagr
Copy link
Member

@ewelinagr ewelinagr commented Apr 17, 2024

Implements FAIRSPC-50

Unfortunately there is no way to include external files in helm install/upgrade command, so the current workaround is to pass icon files one by one with --set-file option (as I described in the readme file). Hopefully this feature will be included in helm, since there is already a PR for that:
helm/helm#10077 (unfortunately waiting for 4 years now...).

README.adoc Show resolved Hide resolved
if (object.iconPath === null) {
return Promise.resolve(object);
}
return axios.get(object.iconPath, {responseType: 'blob'}).then(response => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I understand correctly, we don't cache now the icons? They are pretty static, something to make sense to cache in browser. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, I had a plan to add caching, but then forgot about it! Thanks, I'll add it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added now

@@ -44,11 +46,25 @@ public static class Storage {
private String rootDirectoryIri;
}

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Service {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name it more specifically, something like ExternalService, otherwise it is a bit general

Copy link
Member Author

@ewelinagr ewelinagr Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try different name... This is how we call this option in the configuration, just services, and I just moved it from Saturn to Pluto.


@RestController
@Slf4j
@AllArgsConstructor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource is a singleton and unmodifiable. This is correct to define fields final, @RequiredArgsConstructor can be used instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter in this case if I use RequiredArgsConstructor vs AllArgsConstructor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not critical, the only advantage is that it will be safer to add new dependencies


private final PlutoConfig plutoConfig;
/**
* GET /api/iconsvg/{icon_name} : returns an icon of specified name if exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return tag can be used for proper layout and common practice

}
}

public String getIconUrl(String name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If to leave it here, I would suggest to make it private as it is for internal usage. But rather I would suggest to make PlutoConfig responsible for the methods and exposing them. Resource/Controller layer should be responsible only for accepting a request and routing it further to dedicated service

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not only used internally and PlutoConfig is more of a DTO, so I don't think methods belong there. I will see how to organize this better

@@ -33,7 +34,8 @@ public ResponseEntity<List<MetadataSourceInfo>> metadataSources() {
.map(source -> new MetadataSourceInfo(
source.getName(),
source.getLabel(),
String.format("/api/metadata-sources/%s", source.getName())))
source.getName() != null ? String.format("/api/metadata-sources/%s", source.getName()) : null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the parametrized path to const

@frankyhollywood
Copy link
Contributor

Overall looks good!

The only thing I don't get is why services configuration is moved from Saturn to Pluto, can you explain a bit because it makes it more complex than it used to be.

@ewelinagr
Copy link
Member Author

ewelinagr commented Apr 24, 2024

Overall looks good!

The only thing I don't get is why services configuration is moved from Saturn to Pluto, can you explain a bit because it makes it more complex than it used to be.

My goal was to simplify things actually :)
"Services" were added before Pluto was introduced, that is why these were in Saturn.
What this endpoint does is just passing the defined configuration to Mercury, no logic there - it is the same as /storages, /metadata-sources and /config endpoints that are already in Pluto.
And I wanted to place icons together with Pluto, since it is already responsible for serving the static content (Services and icons are connected).

@ewelinagr ewelinagr merged commit 0de8142 into dev May 1, 2024
6 checks passed
@ewelinagr ewelinagr deleted the FAIRSPC-50-icons-config branch May 1, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants