Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
peggles2 committed Nov 15, 2023
2 parents 090ed01 + 9533f09 commit 44ddf7c
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/remove-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
pushd solution/backend
npm install serverless -g
npm install
# remove the database if its there.
serverless invoke --config ./serverless-experimental.yml --function empty_bucket --stage dev${PR}
# remove the database if its there.
serverless invoke --config ./serverless-experimental.yml --function drop_database --stage dev${PR}
~/work/cmcs-eregulations/cmcs-eregulations/.github/workflows/delete_cloudformation_stacks.sh cmcs-eregs-site-dev${PR} $PR "./serverless-experimental.yml"
popd
Expand Down
18 changes: 16 additions & 2 deletions solution/backend/content_search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,29 @@ def search(self, search_query):
search_query,
start_sel='<span class="search-highlight">',
stop_sel='</span>',
config='english'
min_words=30,
config='english',
fragment_delimiter='...'
),
document_name_headline=SearchHeadline(
"doc_name_string",
search_query,
start_sel="<span class='search-highlight'>",
stop_sel="</span>",
config='english',
highlight_all=True
min_words=30,
highlight_all=True,
fragment_delimiter='...'
),
content_headline=SearchHeadline(
"content",
search_query,
start_sel="<span class='search-highlight'>",
stop_sel="</span>",
config='english',
min_words=30,
highlight_all=True,
fragment_delimiter='...'
),
).order_by('-rank')

Expand Down
20 changes: 5 additions & 15 deletions solution/backend/content_search/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from file_manager.serializers import DocumentTypeSerializer, SubjectSerializer


class ContentSearchSerializer(DetailsSerializer, serializers.Serializer, ):
class ContentListSerializer(DetailsSerializer, serializers.Serializer, ):
doc_name_string = serializers.CharField()
file_name_string = serializers.CharField()
date_string = serializers.DateField()
Expand All @@ -21,20 +21,10 @@ class ContentSearchSerializer(DetailsSerializer, serializers.Serializer, ):
document_name_headline = HeadlineField()
summary_headline = HeadlineField()


class ContentListSerializer(DetailsSerializer, serializers.Serializer, ):
doc_name_string = serializers.CharField()
file_name_string = serializers.CharField()
date_string = serializers.DateField()
summary_string = serializers.CharField()
locations = serializers.SerializerMethodField()
document_type = DocumentTypeSerializer(many=False, read_only=True)
resource_type = serializers.CharField()
subjects = SubjectSerializer(many=True, read_only=True)
category = serializers.SerializerMethodField()
url = serializers.CharField()
# content_type = serializers.CharField()
# content_id = serializers.IntegerField()
class ContentSearchSerializer(ContentListSerializer, ):
document_name_headline = HeadlineField()
summary_headline = HeadlineField()
content_headline = HeadlineField()


class ContentUpdateSerializer(serializers.Serializer):
Expand Down
9 changes: 9 additions & 0 deletions solution/backend/content_search/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,12 @@ def test_inclusive_subject_filter(self):
response = self.client.get(
f"/v3/content-search/?resource-type=internal&q=test&subjects={self.subject1.id}&subjects={self.subject2.id}")
self.check_exclusive_response(response, 0)

def test_content_search(self):
a = ContentIndex.objects.first()
a.content = "dummy dummy dummy"
a.save()
self.login()
response = self.client.get("/v3/content-search/?&q='dummy'")
data = get_paginated_data(response)
self.assertTrue("dummy" in data['results'][0]['content_headline'])
10 changes: 10 additions & 0 deletions solution/backend/empty_bucket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

import boto3


def handler(event, context):
bucket_name = os.environ.get("AWS_STORAGE_BUCKET_NAME", None)
s3 = boto3.resource('s3')
bucket = s3.Bucket(bucket_name)
bucket.objects.all().delete()
3 changes: 2 additions & 1 deletion solution/backend/serverless-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ custom:
associateWaf:
name: APIGateway-eregs-allow-usa-plus-territories-${self:custom.stage}
version: V2

functions: ${file(serverless_functions/${self:custom.environment}_functions.yml)}

resources:
Expand Down Expand Up @@ -178,11 +177,13 @@ resources:
- "s3:PutObject"
- "s3:GetObject"
- "s3:DeleteObject"
- "s3:ListBucket"
Resource:
- Fn::Join:
- ""
- - "arn:aws:s3:::"
- "Ref" : "ServerlessDeploymentBucket"
- "arn:aws:s3:::file-repo-eregs-${self:custom.stage}"
- "arn:aws:s3:::file-repo-eregs-${self:custom.stage}/*"
- Effect: "Allow"
Action:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ create_su:
layers:
- ${cf:cmcs-eregs-static-assets-${self:custom.stage}.PythonRequirementsLambdaLayerQualifiedArn}
timeout: 300
empty_bucket:
handler: empty_bucket.handler
layers:
- ${cf:cmcs-eregs-static-assets-${self:custom.stage}.PythonRequirementsLambdaLayerQualifiedArn}
timeout: 300
47 changes: 46 additions & 1 deletion solution/ui/e2e/cypress/e2e/policy-repository.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ describe("Policy Repository", () => {
cy.get(".result__link")
.eq(1)
.should("include.text", "Download")
.find("a span[data-testid=download-chip-d89af093-8975-4bcb-a747-abe346ebb274]")
.find(
"a span[data-testid=download-chip-d89af093-8975-4bcb-a747-abe346ebb274]"
)
.should("include.text", "Download MSG");

cy.checkAccessibility();
Expand Down Expand Up @@ -247,6 +249,49 @@ describe("Policy Repository", () => {
);
});

it("should filter the subject list when a search term is entered into the subject filter", () => {
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository/");

cy.injectAxe();

cy.get(`button[data-testid=remove-subject-1]`).should("not.exist");
cy.get(`button[data-testid=add-subject-1]`).should(
"include.text",
"Cures Act"
);
cy.get(`button[data-testid=clear-subject-filter]`).should("not.be.visible");

cy.checkAccessibility();

cy.get("input#subjectReduce")
.should("exist")
.should("have.value", "")
.type("21", { force: true });
cy.get(`button[data-testid=clear-subject-filter]`).should("exist");
cy.get("input#subjectReduce").should("have.value", "21");
cy.get(".subjects__list li").should("have.length", 1);
cy.get(`button[data-testid=add-subject-1]`).should(
"include.text",
"21st Century Cures Act"
);
cy.get(`button[data-testid=add-subject-1]`).click({
force: true,
});
cy.url().should("include", "/policy-repository?subjects=1");
cy.get(`button[data-testid=remove-subject-1]`).should("exist");
cy.get(`button[data-testid=clear-subject-filter]`).should("exist");

cy.checkAccessibility();

cy.get(`button[data-testid=clear-subject-filter]`).click({
force: true,
});
cy.get("input#subjectReduce").should("have.value", "");
cy.get(".subjects__list li").should("have.length", 78);
});

it("should display and fetch the correct search query on load if it is included in URL", () => {
cy.intercept("**/v3/content-search/?q=test**").as("qFiles");
cy.viewport("macbook-15");
Expand Down
1 change: 1 addition & 0 deletions solution/ui/regulations/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"eqeqeq": "off",
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-nested-ternary": "off",
"prefer-template": "off",
"vue/order-in-components": "off",
"vue/no-unsupported-features": [
"error",
Expand Down
8 changes: 8 additions & 0 deletions solution/ui/regulations/css/scss/_application_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ $font_size_hero_h1_tablet: 20px;
}
}

@mixin font-bold-keep-width-reset {
text-shadow: none;

@supports (-webkit-text-stroke-width: 0.04ex) {
-webkit-text-stroke-width: 0;
}
}

//--------------------------
// Breakpoints
//--------------------------
Expand Down
126 changes: 106 additions & 20 deletions solution/ui/regulations/css/scss/partials/_policy_repository.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

@import "../application_settings";

@mixin common-remove-btn-styles {
display: flex;
align-items: center;
justify-content: center;
background-color: $policy_subject_close_background;
color: $policy_subject_selected_chip_background;
border-radius: 4px;

&:hover,
&:focus,
&:active {
background-color: #c0c1c3;
}

i {
pointer-events: none;
}
}

#policyRepositoryApp.repository-view,
#policyRepositorySearchApp.repository-search-view {
margin-bottom: 1rem;
Expand Down Expand Up @@ -31,6 +50,8 @@
display: flex;
border-right: none;
border-bottom: 2px solid $border_color;
padding-left: 0px;
padding-right: 0px;

@include screen-md {
border-right: 2px solid $border_color;
Expand Down Expand Up @@ -61,17 +82,29 @@
flex: 1;
margin-bottom: 1rem;

@mixin filter-container-styles {
padding: 0.75rem 1rem;
@mixin filter-borders {
border: 2px solid $border_color;
border-radius: 4px;
}

@mixin filter-container-styles {
@include filter-borders;

padding: 0.75rem 1rem;
margin-block-start: 1rem;
margin-block-end: 1rem;
}

.sticky-container {
position: sticky;
top: $header_height;
padding-left: 1rem;
padding-right: 1rem;

@include screen-md {
position: sticky;
top: $header_height;
max-height: calc(100vh - 90px);
overflow-y: auto;
}
}

.selections__container {
Expand All @@ -92,24 +125,11 @@
padding: 4px 8px;

button {
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
margin-left: 8px;
background-color: $policy_subject_close_background;
color: $policy_subject_selected_chip_background;
border-radius: 4px;
&:hover,
&:focus,
&:active {
background-color: #c0c1c3;
}

i {
pointer-events: none;
}
@include common-remove-btn-styles;
}
}
}
Expand Down Expand Up @@ -138,11 +158,69 @@
}
}

.subjects__list-container {
@include filter-container-styles;

display: flex;
flex-direction: column;
min-height: 200px;

.subjects__loading {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
}

form {
display: flex;
flex-direction: column;
position: relative;

label[for="subjectReduce"] {
font-size: 14px;
}

input#subjectReduce {
@include filter-borders;

flex: 1;
height: 1.5rem;
margin: 12px 0;
padding: 4px 24px 4px 4px;
box-sizing: content-box !important; // thanks, Vuetify

&:focus,
&:focus-visible,
&:focus-within,
&:active {
outline: none !important;
border: 2px solid $secondary_border_color !important;
}
}

.subjects__filter-reset {
@include common-remove-btn-styles;

top: 50%;
right: -3px;
transform: translate(-50%);
position: absolute;
width: 20px;
height: 20px;

&--hidden {
display: none;
}
}
}
}

.subjects__list {
height: 300px;
overflow: scroll;

@include filter-container-styles;
padding: 0;
margin: 0;

.subjects__li {
margin-bottom: 0.75rem;
Expand All @@ -156,6 +234,14 @@
color: #000;
width: 100%;

.match__container {
@include font-bold-keep-width;

.match {
@include font-bold-keep-width-reset;
}
}

&:hover,
&:focus,
&:active {
Expand Down
Loading

0 comments on commit 44ddf7c

Please sign in to comment.