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

Added a form to projects to import a shared-project using directory path #4178

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions apps/dashboard/app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def new
@project = Project.new
end

# GET /projects/import
def import
@templates = []
@project = Project.new
end

# GET /projects/:id/edit
def edit
project_id = show_project_params[:id]
Expand Down Expand Up @@ -84,6 +90,17 @@ def create
end
end

# POST /projects/import
def import_save
# TODO: Call Project to save directory to lookup file
success = true
if success
redirect_to projects_path, notice: I18n.t('dashboard.jobs_project_imported')
else
redirect_to project_import_path, alert: I18n.t('dashboard.jobs_project_generic_error')
end
end

# DELETE /projects/:id
def destroy
project_id = params[:id]
Expand Down
10 changes: 10 additions & 0 deletions apps/dashboard/app/views/projects/import.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class='page-header text-center pb-3'>
<h1>
Import a Shared Project
</h1>
</div>
# TODO: Add a new partial for this. May be similar to index with a list of cards or a simple search
# Right now it point to "Create new Project" form
<%= bootstrap_form_for(@project, url: project_import_save_path, method: :post) do |form| %>
<%= render partial: "form", locals: { form: form }%>
<% end %>
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a new partial for this. I'm thinking it'll look a lot like the index with a list of cards. Maybe there's a simple search? Maybe you can expand the cards to see more details?

In any case, I'd say let's just put a TODO here and reset the _form.html.erb.

14 changes: 14 additions & 0 deletions apps/dashboard/app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,19 @@
</div>
<%- end -%>

<div class="mt-5 justify-content-center text-center project-icon">
<%= link_to(project_import_path,
title: I18n.t('dashboard.jobs_import_shared_project'),
class: 'text-dark btn btn-link') do
%>
<div class="text-center d-flex justify-content-center">
<strong>
<%= icon_tag(URI.parse("fas://file-import")) %><br>
<%= I18n.t('dashboard.jobs_import_shared_project') %>
</strong>
</div>
<% end %>
</div>

</div>
</div>
2 changes: 2 additions & 0 deletions apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ en:
files_remote_error_listing_remotes: 'Error listing Rclone remotes: %{error}'
jobs_create_blank_project: Create a new project
jobs_create_template_project: Create a new project from a template
jobs_import_shared_project: Import a shared project
jobs_launchers: Launchers
jobs_launchers_created: Launcher successfully created!
jobs_launchers_default_created: A 'hello_world.sh' was also added to this project.
Expand All @@ -156,6 +157,7 @@ en:
jobs_launchers_updated: Launcher manifest updated!
jobs_new_launcher: New Launcher
jobs_project_created: Project successfully created!
jobs_project_imported: Project successfully imported!
jobs_project_delete_project_confirmation: Delete all contents of project directory?
jobs_project_deleted: Project successfully deleted!
jobs_project_description_placeholder: Project description
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/config/locales/ja_JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ja_JP:
files_remote_error_listing_remotes: 'Error listing Rclone remotes: %{error}'
jobs_create_blank_project: Create a new project
jobs_create_template_project: Create a new project from a template
jobs_import_shared_project: Import a shared project
jobs_launchers: Launchers
jobs_launchers_created: Launcher successfully created!
jobs_launchers_default_created: A 'hello_world.sh' was also added to this project.
Expand All @@ -156,6 +157,7 @@ ja_JP:
jobs_launchers_updated: Launcher manifest updated!
jobs_new_launcher: New Launcher
jobs_project_created: Project successfully created!
jobs_project_imported: Project successfully imported!
jobs_project_delete_project_confirmation: Delete all contents of project directory?
jobs_project_deleted: Project successfully deleted!
jobs_project_description_placeholder: Project description
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ zh-CN:
files_remote_error_listing_remotes: 'Error listing Rclone remotes: %{error}'
jobs_create_blank_project: Create a new project
jobs_create_template_project: Create a new project from a template
jobs_import_shared_project: Import a shared project
jobs_launchers: Launchers
jobs_launchers_created: Launcher successfully created!
jobs_launchers_default_created: A 'hello_world.sh' was also added to this project.
Expand All @@ -152,6 +153,7 @@ zh-CN:
jobs_launchers_updated: Launcher manifest updated!
jobs_new_launcher: New Launcher
jobs_project_created: Project successfully created!
jobs_project_imported: Project successfully imported!
jobs_project_delete_project_confirmation: Delete all contents of project directory?
jobs_project_deleted: Project successfully deleted!
jobs_project_description_placeholder: Project description
Expand Down
3 changes: 3 additions & 0 deletions apps/dashboard/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

Rails.application.routes.draw do
if Configuration.can_access_projects?
get 'projects/import' => 'projects#import', :as => 'project_import'
post 'projects/import' => 'projects#import_save', :as => 'project_import_save'

resources :projects do
root 'projects#index'
get '/jobs/:cluster/:jobid' => 'projects#job_details', :defaults => { :format => 'turbo_stream' }, :as => 'job_details'
Expand Down
Loading