diff --git a/app/controllers/client_api/configurations_controller.rb b/app/controllers/client_api/configurations_controller.rb new file mode 100644 index 000000000..30c623ba3 --- /dev/null +++ b/app/controllers/client_api/configurations_controller.rb @@ -0,0 +1,23 @@ +module ClientApi + class ConfigurationsController < ApplicationController + + def about_scinote + respond_to do |format| + format.json do + render json: { + scinoteVersion: Scinote::Application::VERSION, + addons: list_all_addons + }, status: :ok + end + end + end + + private + + def list_all_addons + Rails::Engine.subclasses + .select { |c| c.name.start_with?('Scinote') } + .map(&:parent) + end + end +end diff --git a/app/javascript/src/components/Navigation/components/AboutScinoteModal.jsx b/app/javascript/src/components/Navigation/components/AboutScinoteModal.jsx new file mode 100644 index 000000000..665b4cf2a --- /dev/null +++ b/app/javascript/src/components/Navigation/components/AboutScinoteModal.jsx @@ -0,0 +1,35 @@ +// @flow +import React from "react"; +import type { Node } from "react"; +import { FormattedMessage } from "react-intl"; +import { Modal } from "react-bootstrap"; + +type Props = { + showModal: boolean, + scinoteVersion: string, + addons: Array, + onModalClose: Function +}; + +export default (props: Props): Node => { + const { showModal, scinoteVersion, addons, onModalClose } = props; + return ( + + + + + + + + + + +

{scinoteVersion}

+ + + + {addons.map((addon: string): Node =>

{addon}

)} +
+
+ ); +}; diff --git a/app/javascript/src/components/Navigation/components/InfoDropdown.jsx b/app/javascript/src/components/Navigation/components/InfoDropdown.jsx index 4e81ed3d0..e01328f56 100644 --- a/app/javascript/src/components/Navigation/components/InfoDropdown.jsx +++ b/app/javascript/src/components/Navigation/components/InfoDropdown.jsx @@ -11,6 +11,8 @@ import { } from "../../../config/routes"; import { getSciNoteInfo } from "../../../services/api/configurations_api"; +import AboutScinoteModal from "./AboutScinoteModal"; + type State = { modalOpen: boolean, scinoteVersion: string, @@ -20,21 +22,26 @@ type State = { class InfoDropdown extends Component<*, State> { constructor(props: any) { super(props); - this.state = { modalOpen: false, scinoteVersion: "", addons: [] }; - (this: any).showAboutUsModal = this.showAboutUsModal.bind(this); + this.state = { showModal: false, scinoteVersion: "", addons: [] }; + (this: any).showAboutSciNoteModal = this.showAboutSciNoteModal.bind(this); + (this: any).closeModal = this.closeModal.bind(this); } - showAboutUsModal(): void { + showAboutSciNoteModal(): void { getSciNoteInfo().then(response => { const { scinoteVersion, addons } = response; (this: any).setState({ scinoteVersion, addons, - modalOpen: true + showModal: true }); }); } + closeModal(): void { + (this: any).setState({ showModal: false }); + } + render() { return ( { - + + ); diff --git a/app/javascript/src/config/locales/messages.js b/app/javascript/src/config/locales/messages.js index c1258cdf4..88cef0ad6 100644 --- a/app/javascript/src/config/locales/messages.js +++ b/app/javascript/src/config/locales/messages.js @@ -6,7 +6,10 @@ export default { update: "Update", edit: "Edit", loading: "Loading ...", - upload: "Upload" + upload: "Upload", + about_scinote: "About sciNote", + core_version: "sciNote core version", + addon_versions: "Addon versions" }, page_title: { root: "SciNote", diff --git a/config/routes.rb b/config/routes.rb index 77bea4053..8d430a8f6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ Rails.application.routes.draw do get '/settings/*all', to: 'client_api/settings#index' namespace :client_api, defaults: { format: 'json' } do - %i(activities teams notifications users confirmations).each do |path| + %i(activities teams notifications users configurations).each do |path| draw path end end diff --git a/config/routes/configurations.rb b/config/routes/configurations.rb new file mode 100644 index 000000000..198449f22 --- /dev/null +++ b/config/routes/configurations.rb @@ -0,0 +1,2 @@ +# scinote configurations routes +get '/about_scinote', to: 'configurations#about_scinote' diff --git a/config/routes/confirmations.rb b/config/routes/confirmations.rb deleted file mode 100644 index 8cb5cbcf2..000000000 --- a/config/routes/confirmations.rb +++ /dev/null @@ -1,2 +0,0 @@ -# scinote configurations routes -get '/about_scinote', to: 'configurations_controller#about_scinote'