Skip to content

Commit

Permalink
Merge branch 'main' into jmo-grant-details-url
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsmohan authored Mar 11, 2024
2 parents ba26c78 + 8d047d7 commit cfb0c51
Show file tree
Hide file tree
Showing 43 changed files with 450 additions and 244 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ categories:
collapse-after: 10
labels:
- bug
- title: 🗂️ Database Changes
collapse-after: 1
labels:
- database-changes
- title: 📖 Documentation improvements
collapse-after: 10
labels:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0
with:
platforms: linux/amd64,linux/arm64
- name: Authenticate docker
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
BAKEFILE_PATH: ${{ steps.meta.outputs.bake-file }}
- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
uses: docker/build-push-action@af5a7ed5ba88268d5278f7203fb52cd833f66d6e # v5.2.0
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ jobs:
github.com:443
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Download website build artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ needs.build.outputs.website-artifacts-key }}
path: ${{ needs.build.outputs.website-artifacts-path }}
- name: Download docker build attestation artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ needs.build.outputs.server-attestation-artifacts-key }}
path: ${{ needs.build.outputs.server-attestation-artifacts-path }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
ref: ${{ inputs.ref }}
show-progress: 'false'
persist-credentials: 'false'
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
- uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
name: Cache plugin dir
with:
path: .tflint.d/plugins
Expand All @@ -279,4 +279,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Run TFLint
run: tflint --format compact --recursive --minimum-failure-severity=error
run: tflint --format compact --recursive --minimum-failure-severity=warning
4 changes: 2 additions & 2 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
registry.terraform.io:443
releases.hashicorp.com:443
- name: Download Terraform artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ inputs.tf-plan-artifacts-key }}
path: ${{ github.workspace }}/terraform
Expand All @@ -94,7 +94,7 @@ jobs:
with:
terraform_version: ${{ steps.get_tf_version.outputs.TF_VERSION }}
- name: Download website artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ inputs.website-artifacts-key }}
path: ${{ inputs.website-artifacts-path }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
env:
GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
- name: Download website artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ inputs.website-artifacts-key }}
path: ${{ inputs.website-artifacts-path }}
Expand Down
8 changes: 7 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"recommendations": ["Vue.volar", "dbaeumer.vscode-eslint"]
"recommendations": [
"Vue.volar",
"hashicorp.terraform",
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
2 changes: 1 addition & 1 deletion docs/decisions/0007-adopt-vue-recommended-linting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 0007. Adopt vue/recommended linting

Date: 2024-02-26
Status: Proposed
Status: Accepted

## Context and Problem Statement

Expand Down
113 changes: 109 additions & 4 deletions packages/client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
es6: true,
},
extends: [
'plugin:vue/essential',
'plugin:vue/recommended',
'@vue/airbnb',
],
parserOptions: {
Expand All @@ -24,11 +24,116 @@ module.exports = {
'no-restricted-syntax': 'off',

'import/prefer-default-export': 'off',

'vue/multi-word-component-names': 'off',
'vue/no-mutating-props': 'off',
},
overrides: [
// This override is part of the process of upgrading plugin:vue/essential -> plugin:vue/recommended.
// In order to avoid a huge stop-the-world PR, we're introducing the plugin upgrade and a file list here
// that ignores the added rules. That way, we can bring individual files into compliance in smaller, less
// disruptive PRs. We'll plan to burn down the list of files in this list until we're done and can remove
// this override entirely.
{
files: [
// File list to ignore generated by `yarn run lint --no-fix --format unix | sed -E 's/:.+//g' | uniq`
'./src/App.vue',
'./src/arpa_reporter/App.vue',
'./src/arpa_reporter/components/AlertBox.vue',
'./src/arpa_reporter/components/DownloadButton.vue',
'./src/arpa_reporter/components/DownloadFileButton.vue',
'./src/arpa_reporter/components/DownloadFileButtonSmall.vue',
'./src/arpa_reporter/components/DownloadTemplateBtn.vue',
'./src/arpa_reporter/components/Navigation.vue',
'./src/arpa_reporter/components/StandardForm.vue',
'./src/arpa_reporter/views/Agencies.vue',
'./src/arpa_reporter/views/Agency.vue',
'./src/arpa_reporter/views/Home.vue',
'./src/arpa_reporter/views/Login.vue',
'./src/arpa_reporter/views/NewTemplate.vue',
'./src/arpa_reporter/views/NewUpload.vue',
'./src/arpa_reporter/views/ReportingPeriod.vue',
'./src/arpa_reporter/views/ReportingPeriods.vue',
'./src/arpa_reporter/views/Subrecipient.vue',
'./src/arpa_reporter/views/Subrecipients.vue',
'./src/arpa_reporter/views/Upload.vue',
'./src/arpa_reporter/views/Uploads.vue',
'./src/arpa_reporter/views/User.vue',
'./src/arpa_reporter/views/Users.vue',
'./src/arpa_reporter/views/Validation.vue',
'./src/components/GrantsTable.vue',
'./src/components/Layout.vue',
'./src/components/Modals/AddKeyword.vue',
'./src/components/Modals/AddOrganization.vue',
'./src/components/Modals/AddTeam.vue',
'./src/components/Modals/AddUser.vue',
'./src/components/Modals/EditOrganization.vue',
'./src/components/Modals/EditTeam.vue',
'./src/components/Modals/EditUser.vue',
'./src/components/Modals/GrantDetailsLegacy.vue',
'./src/components/Modals/ImportTeams.vue',
'./src/components/Modals/ImportUsers.vue',
'./src/components/Modals/ProfileSettings.vue',
'./src/components/Modals/SavedSearchPanel.vue',
'./src/components/Modals/SearchPanel.vue',
'./src/components/SearchFilter.vue',
'./src/components/Uploader.vue',
'./src/components/UserAvatar.vue',
'./src/main.js',
'./src/views/ArpaAnnualPerformanceReporter.vue',
'./src/views/Dashboard.vue',
'./src/views/EligibilityCodes.vue',
'./src/views/GrantDetails.vue',
'./src/views/Grants.vue',
'./src/views/Home.vue',
'./src/views/Keywords.vue',
'./src/views/Login.vue',
'./src/views/MyGrants.vue',
'./src/views/MyProfile.vue',
'./src/views/NotFound.vue',
'./src/views/Organizations.vue',
'./src/views/RecentActivity.vue',
'./src/views/Teams.vue',
'./src/views/UpcomingClosingDates.vue',
'./src/views/Users.vue',
],
rules: {
// List of essential rules we previously had turned off
'vue/multi-word-component-names': 'off',
'vue/no-mutating-props': 'off',
// List of strongly recommended rules introduced (https://eslint.vuejs.org/rules/#priority-b-strongly-recommended-improving-readability)
'vue/attribute-hyphenation': 'off',
'vue/component-definition-name-casing': 'off',
'vue/first-attribute-linebreak': 'off',
'vue/html-closing-bracket-newline': 'off',
'vue/html-closing-bracket-spacing': 'off',
'vue/html-end-tags': 'off',
'vue/html-indent': 'off',
'vue/html-quotes': 'off',
'vue/html-self-closing': 'off',
'vue/max-attributes-per-line': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/mustache-interpolation-spacing': 'off',
'vue/no-multi-spaces': 'off',
'vue/no-spaces-around-equal-signs-in-attribute': 'off',
'vue/no-template-shadow': 'off',
'vue/one-component-per-file': 'off',
'vue/prop-name-casing': 'off',
'vue/require-default-prop': 'off',
'vue/require-explicit-emits': 'off',
'vue/require-prop-types': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/v-bind-style': 'off',
'vue/v-on-event-hyphenation': 'off',
'vue/v-on-style': 'off',
'vue/v-slot-style': 'off',
// List of recommended rules introduced (https://eslint.vuejs.org/rules/#priority-b-strongly-recommended-improving-readability)
'vue/attributes-order': 'off',
'vue/component-tags-order': 'off',
'vue/no-lone-template': 'off',
'vue/no-multiple-slot-args': 'off',
'vue/no-v-html': 'off',
'vue/order-in-components': 'off',
'vue/this-in-template': 'off',
},
},
{
files: [
'**/__tests__/*.{j,t}s?(x)',
Expand Down
21 changes: 12 additions & 9 deletions packages/client/src/views/GrantDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
</div>
<b-container fluid v-if="selectedGrant && !loading">
<div class="grant-details-container">
<div class="grant-details-back-link" v-if="isFirstPageLoad">
<router-link :to="{ name: 'grants' }">Browse Grants</router-link>
</div>
<div class="grant-details-back-link" v-else>
<a @click="$router.back()">Back</a>
<div class="grant-details-back-link">
<router-link v-if="isFirstPageLoad" :to="{ name: 'grants' }">Browse Grants</router-link>
<a href="#" @click="$router.back()" v-else>Back to Results</a>
</div>
<!-- Left page column: headline -->
<h2 class="grant-details-headline m-0">{{ selectedGrant.title }}</h2>
Expand Down Expand Up @@ -447,6 +445,7 @@ export default {
</script>
<style lang="css">
.grant-details-container {
padding-right: 80px;
padding-left: 80px;
Expand All @@ -461,12 +460,16 @@ export default {
column-gap: 90px;
row-gap: 48px;
.grant-details-back-link {
padding-top: 20px;
font-size: 1rem;
margin-top: 24px;
font-size: 14px;
font-weight: 700;
color: #6D7278;
a {
color: #6D7278;
cursor: pointer;
color: black;
text-decoration: none;
&::hover {
text-decoration: underline;
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion packages/client/src/views/MyGrants.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<div class="grants-tabs">
<b-tabs align="left" style="margin-top: 1.5rem" lazy v-model="activeTab">
<b-tabs
align="left"
style="margin-top: 1.5rem"
lazy
v-model="activeTab"
:key="activeTab /* Force reload when tab changes to hacky fix a visual artifact, see: https://github.com/usdigitalresponse/usdr-gost/issues/2721 */"
>
<b-tab title="Interested">
<GrantsTable searchTitle="Interested" showInterested :showSearchControls="false"/>
</b-tab>
Expand Down
15 changes: 15 additions & 0 deletions packages/server/__tests__/email/email.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,21 @@ describe('Email sender', () => {
expect(body).to.include(name);
expect(body).to.include(moment(openDate).format('MMMM Do YYYY'));
});
it('links to Grants.gov when Grant Details page is not live', async () => {
const agencies = await db.getAgency(fixtures.agencies.accountancy.id);
const agency = agencies[0];
agency.matched_grants = [fixtures.grants.healthAide];
const body = await email.buildDigestBody({ name: 'Saved search test', openDate: '2021-08-05', matchedGrants: agency.matched_grants });
expect(body).to.include(`https://www.grants.gov/search-results-detail/${fixtures.grants.healthAide.grant_id}`);
});
it('links to Grant Finder when Grant Details page is live', async () => {
process.env.NEW_GRANT_DETAILS_PAGE_ENABLED = 'true';
const agencies = await db.getAgency(fixtures.agencies.accountancy.id);
const agency = agencies[0];
agency.matched_grants = [fixtures.grants.healthAide];
const body = await email.buildDigestBody({ name: 'Saved search test', openDate: '2021-08-05', matchedGrants: agency.matched_grants });
expect(body).to.include(`${process.env.WEBSITE_DOMAIN}/grants/${fixtures.grants.healthAide.grant_id}`);
});
});
context('getAndSendGrantForSavedSearch', () => {
it('Sends an email for a saved search', async () => {
Expand Down
34 changes: 26 additions & 8 deletions packages/server/src/lib/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,17 @@ function sendWelcomeEmail(email, httpOrigin) {
});
}

function getGrantDetail(grant, emailNotificationType) {
const grantDetailTemplate = fileSystem.readFileSync(path.join(__dirname, '../static/email_templates/_grant_detail.html'));
function buildGrantDetailUrlSafe(grantId, emailNotificationType) {
const grantDetailUrl = new URL(process.env.WEBSITE_DOMAIN);
grantDetailUrl.pathname = `grants/${mustache.escape(grantId)}`;
grantDetailUrl.searchParams.set('utm_source', 'usdr-grants');
grantDetailUrl.searchParams.set('utm_medium', 'email');
grantDetailUrl.searchParams.set('utm_campaign', mustache.escape(emailNotificationType));
grantDetailUrl.searchParams.set('utm_content', 'grant-details');
return grantDetailUrl.toString();
}

const description = grant.description.substring(0, 380).replace(/(<([^>]+)>)/ig, '');
function buildGrantsUrlSafe(emailNotificationType) {
const grantsUrl = new URL(process.env.WEBSITE_DOMAIN);
if (emailNotificationType === notificationType.grantDigest) {
grantsUrl.pathname = 'grants';
Expand All @@ -164,7 +171,13 @@ function getGrantDetail(grant, emailNotificationType) {
}
grantsUrl.searchParams.set('utm_source', 'subscription');
grantsUrl.searchParams.set('utm_medium', 'email');
grantsUrl.searchParams.set('utm_campaign', emailNotificationType);
grantsUrl.searchParams.set('utm_campaign', mustache.escape(emailNotificationType));
return grantsUrl.toString();
}

function getGrantDetail(grant, emailNotificationType) {
const grantDetailTemplate = fileSystem.readFileSync(path.join(__dirname, '../static/email_templates/_grant_detail.html'));
const description = grant.description.substring(0, 380).replace(/(<([^>]+)>)/ig, '');
const grantDetail = mustache.render(
grantDetailTemplate.toString(), {
title: grant.title,
Expand All @@ -177,8 +190,13 @@ function getGrantDetail(grant, emailNotificationType) {
award_ceiling: grant.award_ceiling || 'Not available',
// estimated_funding: grant.estimated_funding, TODO: add once field is available in the database.
cost_sharing: grant.cost_sharing,
link_url: `https://www.grants.gov/search-results-detail/${grant.grant_id}`,
grants_url: grantsUrl.toString(),
link_url_safe: process.env.NEW_GRANT_DETAILS_PAGE_ENABLED === 'true'
? buildGrantDetailUrlSafe(grant.grant_id, emailNotificationType)
: `https://www.grants.gov/search-results-detail/${mustache.escape(grant.grant_id)}`,
link_description: process.env.NEW_GRANT_DETAILS_PAGE_ENABLED === 'true'
? 'Grant Finder'
: 'Grants.gov',
grants_url_safe: buildGrantsUrlSafe(emailNotificationType),
view_grant_label: emailNotificationType === notificationType.grantDigest ? undefined : 'View My Grants',
},
);
Expand Down Expand Up @@ -218,10 +236,10 @@ async function sendGrantAssignedNotficationForAgency(assignee_agency, grantDetai
// TODO: add plain text version of the email
const emailPlain = emailHTML.replace(/<[^>]+>/g, '');
const emailSubject = `Grant Assigned to ${assignee_agency.name}`;
const assginees = await db.getSubscribersForNotification(assignee_agency.id, notificationType.grantAssignment);
const assignees = await db.getSubscribersForNotification(assignee_agency.id, notificationType.grantAssignment);

const inputs = [];
assginees.forEach((assignee) => inputs.push(
assignees.forEach((assignee) => inputs.push(
{
toAddress: assignee.email,
emailHTML,
Expand Down
Loading

0 comments on commit cfb0c51

Please sign in to comment.