Skip to content

Commit

Permalink
Add HTML pages for OIDC resources under /profile/
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Oct 19, 2023
1 parent 2356051 commit 193a9e0
Show file tree
Hide file tree
Showing 74 changed files with 2,709 additions and 50 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ Rails/UniqueValidationWithoutIndex:
Rails/ActionControllerTestCase:
Enabled: false # Causes every integration test to fail

Rails/Output:
Exclude:
- app/views/**/*_view.rb
- app/views/**/*_component.rb

Layout/ArgumentAlignment:
Enabled: false

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ gem "browser", "~> 5.3", ">= 5.3.1"
gem "bcrypt", "~> 3.1", ">= 3.1.18"
gem "maintenance_tasks", "~> 2.1"
gem "strong_migrations", "~> 1.6"
gem "phlex-rails", "~> 1.0"

# Admin dashboard
gem "avo", "~> 2.42"
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
cbor (0.5.9.6)
cgi (0.3.6)
chartkick (5.0.4)
choice (0.2.0)
chunky_png (1.4.0)
Expand Down Expand Up @@ -206,6 +207,8 @@ GEM
dry-initializer (3.1.1)
email_validator (2.2.3)
activemodel
erb (4.0.3)
cgi (>= 0.3.3)
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
Expand Down Expand Up @@ -443,6 +446,14 @@ GEM
parser (3.2.1.1)
ast (~> 2.4.1)
pg (1.5.4)
phlex (1.8.1)
concurrent-ruby (~> 1.2)
erb (>= 4)
zeitwerk (~> 2.6)
phlex-rails (1.0.0)
phlex (~> 1.7)
rails (>= 6.1, < 8)
zeitwerk (~> 2.6)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -747,6 +758,7 @@ DEPENDENCIES
opensearch-dsl (~> 0.2.0)
opensearch-ruby (~> 1.0)
pg (~> 1.4)
phlex-rails (~> 1.0)
pry-byebug (~> 3.10)
puma (~> 6.1)
pundit (~> 2.3)
Expand Down
71 changes: 71 additions & 0 deletions app/assets/javascripts/oidc_api_key_role_form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
$(function () {
function wire() {
var removeNestedButtons = $("button.form__remove_nested_button");

removeNestedButtons.off("click");
removeNestedButtons.click(function (e) {
e.preventDefault();
var button = $(this);
var nestedField = button.closest(".form__nested_fields");

nestedField.remove();
});

var addNestedButtons = $("button.form__add_nested_button");
addNestedButtons.off("click");
addNestedButtons.click(function (e) {
e.preventDefault();
var button = $(this);
var nestedFields = button.siblings("template.form__nested_fields");

var content = nestedFields
.html()
.replace(/NEW_OBJECT/g, new Date().getTime());

$(content).insertAfter(button.siblings().last());

wire();
});
}

wire();

// var enableGemScopeCheckboxes = $(
// "#push_rubygem, #yank_rubygem, #add_owner, #remove_owner"
// );
// var hiddenRubygemId = "hidden_api_key_rubygem_id";
// toggleGemSelector();

// enableGemScopeCheckboxes.click(function () {
// toggleGemSelector();
// });

// function toggleGemSelector() {
// var isApplicableGemScopeSelected = enableGemScopeCheckboxes.is(":checked");
// var gemScopeSelector = $("#api_key_rubygem_id");

// if (isApplicableGemScopeSelected) {
// gemScopeSelector.removeAttr("disabled");
// removeHiddenRubygemField();
// } else {
// gemScopeSelector.val("");
// gemScopeSelector.prop("disabled", true);
// addHiddenRubygemField();
// }
// }

// function addHiddenRubygemField() {
// $("<input>")
// .attr({
// type: "hidden",
// id: hiddenRubygemId,
// name: "api_key[rubygem_id]",
// value: "",
// })
// .appendTo(".t-body form .api_key_rubygem_id_form");
// }

// function removeHiddenRubygemField() {
// $("#" + hiddenRubygemId + ":hidden").remove();
// }
});
3 changes: 3 additions & 0 deletions app/assets/stylesheets/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
.l-mr-4 {
margin-right: 1rem; }

.l-mb-0 {
margin-bottom: 0 !important; }

.l-mb-4 {
margin-bottom: 1rem; }

Expand Down
35 changes: 32 additions & 3 deletions app/assets/stylesheets/modules/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@
.form__input__addon-left .form__input {
padding-left: 45px; }

.form__input, .form__textarea, .form__select, .form__group {
.form__nested_fields, .form__input, .form__textarea, .form__select, .form__group {
margin-bottom: 30px; }

.form__nested_fields, .form__input, .form__textarea {
display: block;
width: 100%;
}

.form__nested_fields {
margin: 12px 0 12px 32px;
width: calc(100% - 32px); }

.form__input, .form__textarea {
-webkit-appearance: none;
padding: 12px 16px;
display: block;
width: 100%;
font-weight: 300;
font-size: 18px;
border: 1px solid #f2f3f4;
Expand Down Expand Up @@ -219,3 +226,25 @@
.form__checkbox__item .field_with_errors {
display: contents;
}

.form__flex_group {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
gap: 20px;
}

.form__flex_group > .form__submit {
margin: initial;
width: initial;
align-self: center;
}

.form__scope_checkbox_grid_group {
display: grid;
grid-template-columns: repeat(auto-fill, 200px);
grid-gap: 20px;
}
24 changes: 24 additions & 0 deletions app/assets/stylesheets/modules/gem.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
border: none;
font-weight: bold; }

.gem__code.multiline {
line-height: inherit;
white-space: pre-wrap;
border-radius: 0; }

.gem__code::-webkit-scrollbar {
display: none; }

Expand Down Expand Up @@ -155,6 +160,25 @@
width: 10px;
background-image: linear-gradient(to right, transparent 0%, white 100%); }

.gem__code__header {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding: .5rem;
border-top-left-radius: .25rem;
border-top-right-radius: .25rem;
border: #c1c4ca 1px solid;
border-bottom: 0; }

.gem__code__header .gem__code__icon {
position: inherit;
padding: .125rem;
width: 40px; }

.gem__code__icon.static {
position: static; }

.gem__code__tooltip--copy,
.gem__code__tooltip--copied {
display: none; }
Expand Down
79 changes: 79 additions & 0 deletions app/assets/stylesheets/modules/oidc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
dl.api_key_permissions {
margin-top: 1em;
display: grid;
grid-template-columns: 1fr 2fr;
}

dl.api_key_permissions dt {
font-weight: bold;
float: inherit;
}

dl.oidc_access_policy {
display: grid;
column-gap: 1rem;
grid-template-columns: fit-content(6rem) auto;
}

dl.oidc_access_policy > dd > * + * {
border-top-width: 2px;
border-top-style: solid;
border-top-color: #e2e8f0;
margin-top: .125rem;
padding-top: .125rem;
}

dl.provider_attributes {
column-gap: 1rem;
align-items: baseline;
row-gap: 1rem;
}

@media (max-width: 420px){
dl.provider_attributes {
display: flex;
flex-direction: column;
}
}
@media (min-width: 421px){
dl.provider_attributes {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}

dl.full-width {
width: 100%;
overflow-wrap: break-word;
word-break: break-word;

}

dl.provider_attributes dt.text-right {
text-align: right;
}

dl.provider_attributes dt.text-left {
text-align: left;
}

dl.provider_attributes dd ul.tag-list {
display: flex;
flex-direction: row;
list-style: none;
justify-content: start;
column-gap: 1rem;
flex-wrap: wrap;
align-items: baseline;
margin: 0;
}

dl.provider_attributes dd ul.tag-list li {
padding: 0.5rem 1rem;
background-color: #e2e8f0;
flex-shrink: 1;
border-radius: 9999px;
}
dl.provider_attributes dd ul.tag-list li:before {
height: 0;
}
8 changes: 4 additions & 4 deletions app/assets/stylesheets/modules/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,24 @@
color: white;
}

dl {
dl.search-fields {
margin: 6% 2%;
}

dt {
dl.search-fields dt {
float: left;
padding: 11px 0px;
color: #585858;
}


@media (min-width: 520px) {
dd {
dl.search-fields dd {
margin-left: 25%;
}
}

dd input {
dl.search-fields dd input {
max-width: none !important;;
}

Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/type.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ a.t-list__item {
font-style: normal;
content: "→"; }

.t-underline {
text-decoration: underline; }

.t-body p, .t-body ol li, .t-body ul li {
font-weight: 300;
font-size: 18px;
Expand Down Expand Up @@ -175,6 +178,8 @@ a.t-list__item {
overflow-x: scroll;
line-height: 1.33;
word-break: normal; }
.t-body pre code.multiline {
word-spacing: inherit; }
.t-body code {
font-weight: bold;
font-family: "courier", monospace;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/oidc/api_key_roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def assume_role
private

def set_api_key_role
@api_key_role = OIDC::ApiKeyRole.find_by!(token: params.require(:token))
@api_key_role = OIDC::ApiKeyRole.active.find_by!(token: params.require(:token))
end

def decode_jwt
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApiKeysController < ApplicationController

def index
@api_key = session.delete(:api_key)
@api_keys = current_user.api_keys.unexpired
@api_keys = current_user.api_keys.unexpired.not_oidc
redirect_to new_profile_api_key_path if @api_keys.empty?
end

Expand Down
Loading

0 comments on commit 193a9e0

Please sign in to comment.