diff --git a/invenio_jobs/administration/jobs.py b/invenio_jobs/administration/jobs.py index 3ffd01b..0c3b4c7 100644 --- a/invenio_jobs/administration/jobs.py +++ b/invenio_jobs/administration/jobs.py @@ -8,7 +8,7 @@ """Invenio administration view module.""" -from invenio_administration.views.base import AdminResourceListView +from invenio_administration.views.base import AdminResourceListView, AdminResourceEditView, AdminResourceDetailView, AdminResourceCreateView from invenio_i18n import lazy_gettext as _ @@ -25,18 +25,18 @@ class JobsListView(AdminResourceListView): pid_path = "id" icon = "settings" template = "invenio_jobs/system/jobs/jobs-search.html" + create_view_name = "jobs-create" display_search = False display_delete = False - display_create = False - display_edit = False + display_create = True + display_edit = True item_field_list = { "job": {"text": _("Jobs"), "order": 1, "width": 3}, "last_run_start_time": {"text": _("Last run"), "order": 2, "width": 3}, "user": {"text": _("Started by"), "order": 3, "width": 3}, "next_run": {"text": _("Next run"), "order": 4, "width": 3}, - "action": {"text": _("Action"), "order": 5, "width": 2}, } search_config_name = "JOBS_SEARCH" @@ -44,7 +44,7 @@ class JobsListView(AdminResourceListView): search_facets_config_name = "JOBS_FACETS" -class JobsDetailsView(AdminResourceListView): +class JobsDetailsView(AdminResourceDetailView): """Configuration for Jobs detail view which shows runs.""" def get_api_endpoint(self, pid_value=None): @@ -59,10 +59,10 @@ def get_api_endpoint(self, pid_value=None): disabled = lambda _: True template = "invenio_jobs/system/jobs/jobs-details.html" - display_delete = False - display_edit = False + display_delete = True display_search = False - display_create = False + display_edit = True + display_create = True list_view_name = "jobs" pid_path = "id" @@ -73,9 +73,62 @@ def get_api_endpoint(self, pid_value=None): "duration": {"text": _("Duration"), "order": 2, "width": 2}, "message": {"text": _("Message"), "order": 3, "width": 10}, "user": {"text": _("Started by"), "order": 4, "width": 2}, - "action": {"text": _("Action"), "order": 5, "width": 2}, } search_config_name = "JOBS_SEARCH" search_sort_config_name = "JOBS_SORT_OPTIONS" search_facets_config_name = "JOBS_FACETS" + +class JobsEditView(AdminResourceEditView): + """Configuration for job edit view.""" + + name = "job-edit" + url = "/jobs//edit" + resource_config = "jobs_resource" + title = "Job Edit" + pid_path = "id" + api_endpoint = "/jobs" + list_view_name = "jobs" + + form_fields = { + "title": { + "order": 1, + "text": _("Title"), + "description": _("A title of the job."), + }, + "description": { + "order": 2, + "text": _("Description"), + "description": _("A short description about the job."), + }, + "created": {"order": 5}, + "updated": {"order": 6}, + } + + +class JobsCreateView(AdminResourceCreateView): + """Configuration for Jobs create view.""" + + name = "jobs-create" + url = "/jobs/create" + resource_config = "jobs_resource" + pid_path = "id" + api_endpoint = "/jobs" + title = "Create Job" + list_view_name = "jobs" + + form_fields = { + "title": { + "order": 1, + "text": _("Title"), + "description": _("A title of the job."), + }, + "description": { + "order": 2, + "text": _("Description"), + "description": _("A short description about the job."), + }, + "created": {"order": 3}, + "updated": {"order": 4}, + } + diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js index e799ffb..c80be0f 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/search/JobSearchResultItemLayout.js @@ -13,13 +13,24 @@ import React, { Component } from "react"; import { UserListItemCompact, toRelativeTime } from "react-invenio-forms"; import { withState } from "react-searchkit"; import { Popup, Table, Button, Icon } from "semantic-ui-react"; -// import { RunButton } from "./RunButton"; +import { RunButton } from "./RunButton"; +import { Actions } from "@js/invenio_administration"; import { StatusFormatter } from "./StatusFormatter"; +import { AdminUIRoutes } from "@js/invenio_administration/src/routes"; import { http } from "react-invenio-forms"; class SearchResultItemComponent extends Component { render() { - const { result } = this.props; + const { + title, + actions, + apiEndpoint, + idKeyPath, + listUIEndpoint, + resourceName, + displayDelete, + displayEdit, + result } = this.props; return ( @@ -93,10 +104,10 @@ class SearchResultItemComponent extends Component { : toRelativeTime(result.next_run, i18next.language) ?? "−"} - - {/* */} + + ); diff --git a/setup.cfg b/setup.cfg index 0cef36b..0f4e565 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,6 +61,8 @@ invenio_assets.webpack = invenio_administration.views = jobs_list = invenio_jobs.administration.jobs:JobsListView jobs_details = invenio_jobs.administration.jobs:JobsDetailsView + jobs_edit = invenio_jobs.administration.jobs:JobsEditView + jobs_create = invenio_jobs.administration.jobs:JobsCreateView invenio_base.api_apps = jobs = invenio_jobs:InvenioJobs invenio_base.api_blueprints =