-
Notifications
You must be signed in to change notification settings - Fork 0
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
an/destination and template api keys #16
Draft
ashnel
wants to merge
2
commits into
master
Choose a base branch
from
an/destination-and-template-api-keys
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
color: #a7a7a7 !important; | ||
} | ||
|
||
.devise-links { | ||
.devise-links, p { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class KeysController < ApplicationController | ||
# puts('fewfew', current_user) | ||
|
||
before_action :check_authentication, only: [:index] | ||
|
||
def check_authentication | ||
unless current_user | ||
flash[:notice] = "This page is not available" | ||
redirect_to root_path | ||
end | ||
end | ||
|
||
def index | ||
@current_user = current_user | ||
render "keys/index" | ||
end | ||
|
||
def set_template_workspace_api_key | ||
current_user.update_attribute(:template_clubhouse_api_token, params["template_workspace_api_key"]) | ||
|
||
redirect_to keys_url | ||
end | ||
|
||
def delete_template_workspace_api_key | ||
current_user.update_attribute(:template_clubhouse_api_token, nil) | ||
|
||
redirect_to keys_url | ||
end | ||
|
||
def set_destination_workspace_api_key | ||
current_user.update_attribute(:destination_clubhouse_api_token, params["destination_workspace_api_key"]) | ||
|
||
redirect_to keys_url | ||
end | ||
|
||
def delete_destination_workspace_api_key | ||
current_user.update_attribute(:destination_clubhouse_api_token, nil) | ||
|
||
redirect_to keys_url | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,37 @@ | ||
<div class='page-container'> | ||
<div class='home-container'> | ||
<div class='logout-container'> | ||
<div class='menu-container'> | ||
<%= link_to root_url, class: 'logout-button', method: :delete do %> | ||
<%= fa_icon "home 2x"%> | ||
<% end %> | ||
<%= link_to keys_path, class: 'logout-button' do %> | ||
<%= fa_icon "key 2x"%> | ||
<% end %> | ||
<%= link_to destroy_user_session_path, class: 'logout-button', method: :delete do %> | ||
<%= fa_icon "sign-out 2x"%> | ||
<% end %> | ||
</div> | ||
<div> | ||
<h1>Clubhouse API Token</h1> | ||
<% if !@current_user.clubhouse_api_token %> | ||
<%= form_tag clubhouse_set_destination_workspace_api_key_path do |f| %> | ||
<div class='form-group'> | ||
<%= text_field_tag(:destination_workspace_api_key, nil, placeholder: 'Enter your API token', class: 'form-control') %> | ||
</div> | ||
<div class='form-group'> | ||
<%= submit_tag "Add Token", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% else %> | ||
<p>You already have an API token set. If you'd like to add a new one please delete your current token.</p> | ||
<%= form_tag clubhouse_delete_destination_workspace_api_key_path do |f| %> | ||
<div class='form-group'> | ||
<%= submit_tag "Delete Token", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<h1>Clubhouse Projects</h1> | ||
<%= form_tag clubhouse_initialize_clubhouse_setup_path do |f| %> | ||
<div class='row justify-content-center form-group'> | ||
<% @template_projects.each do |item| %> | ||
<div class='col-4'> | ||
<%= check_box_tag "template_projects[#{item['id']}]", item['name'] %> | ||
<%= label_tag("project #{item['id']}", item['name']) %> | ||
</div> | ||
<% if @template_projects.length < 2 %> | ||
<p>Clubhouse Projects <%= @template_projects %> </p> | ||
<% else %> | ||
<%= form_tag clubhouse_initialize_clubhouse_setup_path do |f| %> | ||
<div class='row justify-content-center form-group'> | ||
<% @template_projects.each do |item| %> | ||
<div class='col-4'> | ||
<%= check_box_tag "template_projects[#{item['id']}]", item['name'] %> | ||
<%= label_tag("project #{item['id']}", item['name']) %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class='form-group'> | ||
<%= submit_tag "Initiallize Clubhouse", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<div class='form-group'> | ||
<%= submit_tag "Initiallize Clubhouse", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<div class='page-container'> | ||
<div class='home-container'> | ||
<div class='menu-container'> | ||
<%= link_to root_url, class: 'logout-button', method: :delete do %> | ||
<%= fa_icon "home 2x"%> | ||
<% end %> | ||
<%= link_to keys_path, class: 'logout-button' do %> | ||
<%= fa_icon "key 2x"%> | ||
<% end %> | ||
<%= link_to destroy_user_session_path, class: 'logout-button', method: :delete do %> | ||
<%= fa_icon "sign-out 2x"%> | ||
<% end %> | ||
</div> | ||
<div> | ||
<h1>Clubhouse API Keys</h1> | ||
<h4>Template API Key</h4> | ||
<% if !@current_user.template_clubhouse_api_token %> | ||
<%= form_tag(keys_set_template_workspace_api_key_path, {class: "row"}) do |f| %> | ||
<div class='form-group col-10'> | ||
<%= text_field_tag(:template_workspace_api_key, nil, placeholder: 'Enter your template API token', class: 'form-control') %> | ||
</div> | ||
<div class='form-group col-2'> | ||
<%= submit_tag "Save", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% else %> | ||
<%= form_tag(keys_delete_template_workspace_api_key_path, {class: "row"}) do |f| %> | ||
<p class='col-10 form-para'>Template workspace API token set.</p> | ||
<div class='form-group col-2'> | ||
<%= submit_tag "Delete", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<h4>Destination API Key</h4> | ||
<% if !@current_user.destination_clubhouse_api_token %> | ||
<%= form_tag(keys_set_destination_workspace_api_key_path, {class: "row"}) do |f| %> | ||
<div class='form-group col-10'> | ||
<%= text_field_tag(:destination_workspace_api_key, nil, placeholder: 'Enter your destination API token', class: 'form-control') %> | ||
</div> | ||
<div class='form-group col-2'> | ||
<%= submit_tag "Save", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% else %> | ||
<%= form_tag(keys_delete_destination_workspace_api_key_path, {class: "row"}) do |f| %> | ||
<p class='col-10 form-para'>Template workspace API token set.</p> | ||
<div class='form-group col-2'> | ||
<%= submit_tag "Delete", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20200630154708_change_api_key_on_user_from_destination_to_template.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeApiKeyOnUserFromDestinationToTemplate < ActiveRecord::Migration[6.0] | ||
def change | ||
rename_column :users, :clubhouse_api_token, :template_clubhouse_api_token | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20200630165219_add_destination_clubhouse_api_key_to_user.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddDestinationClubhouseApiKeyToUser < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :users, :destination_clubhouse_api_token, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change because for some reason I kept getting an error even though my logout button was using the :delete method. I'm not sure why it thinks it was :get but this was the only way around. I'm not confident this is the right change but I had to make it so the app would stop breaking.
Thoughts?