Skip to content

Commit

Permalink
Merge branch 'main' into dbex/97078-events-type-selection-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
freeheeling authored Dec 21, 2024
2 parents 9d02afe + 0004e8a commit 2aea3eb
Show file tree
Hide file tree
Showing 555 changed files with 21,806 additions and 8,465 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/cd-deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Continuous Deploy Production Test Workflow

on:
workflow_dispatch:
inputs:
commit_sha:
description: Deploy specific commit
required: true

jobs:
get-workflow-environment:
runs-on: ubuntu-latest
outputs:
environment_name: ${{ steps.check-environment.outputs.env_name }}
steps:
- name: Check environment
id: check-environment
run: |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo env_name='production' >> $GITHUB_OUTPUT
else
echo env_name='' >> $GITHUB_OUTPUT
fi
deploy:
name: Deploy
if: ${{ github.event.client_payload.github_ref == 'refs/heads/main' }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017
with:
fetch-depth: 0

- name: Install dependencies
uses: ./.github/workflows/install
timeout-minutes: 30
with:
key: ${{ hashFiles('yarn.lock') }}
yarn_cache_folder: .cache/yarn
path: |
.cache/yarn
node_modules
- name: Check if commit can be deployed
id: check-deployability
run: node ./script/github-actions/check-deployability.js
env:
BUILDTYPE: vagovprod

- name: Configure AWS credentials (1)
if: steps.check-deployability.outputs.is_deployable == 'true'
uses: ./.github/workflows/configure-aws-credentials
with:
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: us-gov-west-1


- name: Get AWS IAM role
if: steps.check-deployability.outputs.is_deployable == 'true'
uses: ./.github/workflows/inject-secrets
with:
ssm_parameter: /frontend-team/github-actions/parameters/AWS_FRONTEND_PROD_ROLE
env_variable_name: AWS_FRONTEND_PROD_ROLE

- name: Configure AWS Credentials (2)
if: steps.check-deployability.outputs.is_deployable == 'true'
uses: ./.github/workflows/configure-aws-credentials
with:
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: us-gov-west-1
role: ${{ env.AWS_FRONTEND_NONPROD_ROLE != '' && env.AWS_FRONTEND_NONPROD_ROLE || env.AWS_FRONTEND_PROD_ROLE }}
role_duration: 900
session_name: vsp-frontendteam-githubaction

- name: Deploy
if: steps.check-deployability.outputs.is_deployable == 'true'
run: ./script/github-actions/partial-deploy.sh -s $SRC -d $DEST -a $ASSET_DEST -v

env:
SRC: s3://vetsgov-website-builds-s3-upload/${{ github.event.client_payload.github_sha }}/vagovprod.tar.bz2
DEST: s3://www.va.gov
ASSET_DEST: s3://prod-va-gov-assets

notify-failure:
name: Notify Failure
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' && (failure() || cancelled()) }}
needs: [deploy]
env:
ALERT_TEAMS: true # Alerts teams for single/grouped app builds when set to true
DEVOPS_CHANNEL_ID: C37M86Y8G #devops-deploys
VETS_WEBSITE_CHANNEL_ID: C02V265VCGH #status-vets-website

steps:
- name: Checkout
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017
with:
fetch-depth: 0

- name: Install dependencies
if: env.ALERT_TEAMS == 'true'
uses: ./.github/workflows/install
timeout-minutes: 30
with:
key: ${{ hashFiles('yarn.lock') }}
yarn_cache_folder: .cache/yarn
path: |
.cache/yarn
node_modules
- name: Get changed applications
id: get-changed-apps
if: env.ALERT_TEAMS == 'true'
uses: ./.github/workflows/get-changed-apps
with:
output-type: 'slack_group'

- name: Notify application team in Slack
if: env.ALERT_TEAMS == 'true' && steps.get-changed-apps.outputs.slack_groups != ''
uses: department-of-veterans-affairs/platform-release-tools-actions/slack-notify@main
continue-on-error: true
with:
payload: '{"attachments": [{"color": "#FF0800","blocks": [{"type": "section","text": {"type": "mrkdwn","text": "${{steps.get-changed-apps.outputs.slack_groups}} CI for your application failed on the `main` branch in `vets-website`: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>\n For help troubleshooting, see the <https://depo-platform-documentation.scrollhelp.site/developer-docs/Handling-failed-single%2Fgrouped-application-pipelines.2066645150.html|documentation> on failed workflow runs."}}]}]}'
channel_id: ${{ env.VETS_WEBSITE_CHANNEL_ID }}
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Notify Slack
if: steps.get-changed-apps.outputs.slack_groups == ''
uses: department-of-veterans-affairs/platform-release-tools-actions/slack-notify@main
continue-on-error: true
with:
payload: '{"attachments": [{"color": "#FF0800","blocks": [{"type": "section","text": {"type": "mrkdwn","text": "`main` branch CI in `vets-website` failed: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>"}}]}]}'
channel_id: ${{ env.VETS_WEBSITE_CHANNEL_ID }}
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1 change: 0 additions & 1 deletion .github/workflows/continuous-deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
repository_dispatch:
types: [cd-production-deploy]


jobs:
deploy:
name: Deploy
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"@babel/runtime": "^7.15.4",
"@datadog/browser-logs": "^5.8.0",
"@datadog/browser-rum": "^4.49.0",
"@department-of-veterans-affairs/component-library": "^48.2.0",
"@department-of-veterans-affairs/component-library": "^48.3.0",
"@department-of-veterans-affairs/css-library": "^0.16.1",
"@department-of-veterans-affairs/react-jsonschema-form": "^1.2.5",
"@department-of-veterans-affairs/va-forms-system-core": "1.6.1",
Expand Down Expand Up @@ -334,7 +334,7 @@
"url-search-params-polyfill": "^8.1.1",
"uswds": "1.6.10",
"vanilla-lazyload": "^16.1.0",
"vets-json-schema": "https://github.com/department-of-veterans-affairs/vets-json-schema.git#a84abd360072a0d4aaa8b1984cee2c33e1844335",
"vets-json-schema": "https://github.com/department-of-veterans-affairs/vets-json-schema.git#6732ef3d0c5804484f7e3aa580333ecad29eb085",
"web-vitals": "^4.2.4"
},
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState, useEffect } from 'react';

/**
* useLocalStorage is a hook that provides a way to store and retrieve values from localStorage
* @param {string} key - The key to store the value under
Expand All @@ -11,10 +10,17 @@ export const useLocalStorage = (key, defaultValue) => {
let currentValue;

try {
currentValue = JSON.parse(
localStorage.getItem(key) || String(defaultValue),
);
const item = localStorage.getItem(key);
if (item === null) {
currentValue = defaultValue;
} else if (item.startsWith('{') || item.startsWith('[')) {
currentValue = JSON.parse(item);
} else {
currentValue = item;
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error getting value from localStorage', error);
currentValue = defaultValue;
}

Expand All @@ -30,6 +36,7 @@ export const useLocalStorage = (key, defaultValue) => {

const clearValue = () => {
localStorage.removeItem(key);
setValue(defaultValue);
};

return [value, setValue, clearValue];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { useEffect, useMemo } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { teardownProfileSession } from 'platform/user/profile/utilities';
import { updateLoggedInStatus } from 'platform/user/authentication/actions';

import { useLocalStorage } from './useLocalStorage';

export const useMockedLogin = () => {
const [, setHasSession] = useLocalStorage('hasSession', '');
const [
localHasSession,
setLocalHasSession,
clearLocalHasSession,
] = useLocalStorage('hasSession', '');

const loggedInFromState = useSelector(
state => state?.user?.login?.currentlyLoggedIn,
);

const loggedIn = useMemo(
() => localHasSession === 'true' || loggedInFromState,
[localHasSession, loggedInFromState],
);

const dispatch = useDispatch();

const logIn = () => {
setHasSession('true');
setLocalHasSession('true');
dispatch(updateLoggedInStatus(true));
};

const logOut = () => {
teardownProfileSession();
dispatch(updateLoggedInStatus(false));
setHasSession('');
clearLocalHasSession();
};

const useLoggedInQuery = location => {
useEffect(
() => {
if (location?.query?.loggedIn === 'true') {
setHasSession('true');
setLocalHasSession('true');
dispatch(updateLoggedInStatus(true));
}

if (location?.query?.loggedIn === 'false') {
teardownProfileSession();
dispatch(updateLoggedInStatus(false));
setHasSession('');
clearLocalHasSession();
}

// having the pollTimeout present triggers some api calls to be made locally and in codespaces
Expand All @@ -43,5 +57,5 @@ export const useMockedLogin = () => {
);
};

return { logIn, logOut, useLoggedInQuery };
return { logIn, logOut, useLoggedInQuery, loggedIn };
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const response = {
street: USER.MAILING_ADDRESS.ADDRESS_LINE1,
city: USER.MAILING_ADDRESS.CITY,
state: USER.MAILING_ADDRESS.STATE_CODE,
country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO2,
country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO3,
postalCode: USER.MAILING_ADDRESS.ZIP_CODE,
isMilitary: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const response = {
street: USER.MAILING_ADDRESS.ADDRESS_LINE1,
city: USER.MAILING_ADDRESS.CITY,
state: USER.MAILING_ADDRESS.STATE_CODE,
country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO2,
country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO3,
postalCode: USER.MAILING_ADDRESS.ZIP_CODE,
},
contactPhone: `${USER.HOME_PHONE.AREA_CODE}${USER.HOME_PHONE.PHONE_NUMBER}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const responses = {
res.json(
generateFeatureToggles({
aedpVADX: true,
coeAccess: true,
profileUseExperimental: true,
coeAccess: false,
profileUseExperimental: false,
}),
),
secondsOfDelay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class ProfileInformationEditView extends Component {
<va-button
data-testid="cancel-edit-button"
secondary
class="vads-u-margin--0 vads-u-margin-top--0 vads-u-width--full mobile-lg:vads-u-width--auto"
class="vads-u-margin--0 vads-u-margin-top--1p5 vads-u-width--full mobile-lg:vads-u-width--auto"
onClick={onCancel}
text={cancelButtonText || 'Cancel'}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

export const WIP = () => (
<div className="row vads-u-margin-bottom--5">
<div className="row vads-u-margin-y--5">
<div className="usa-width-two-thirds medium-8 columns">
<va-alert status="warning">
<h1 slot="headline" className="vads-u-font-size--h3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,42 @@ import { Link } from 'react-router';
export const VADXPlugin = () => {
return (
<div>
<p>VADX Plugin</p>
<p>
<Link to="/mock-form-ae-design-patterns/1">Pattern 1</Link>
</p>
<p>
<Link to="/mock-form-ae-design-patterns/2">Pattern 2</Link>
</p>
<p>VADX Plugin Example</p>
<div>
<Link to="/1">Pattern 1</Link>
<ul>
<li>
<Link to="/1/task-green">Task Green</Link>
</li>
<li>
<Link to="/1/task-yellow/introduction?loggedIn=true">
Task Yellow
</Link>
</li>
<li>
<Link to="/1/task-purple/introduction?loggedIn=true">
Task Purple
</Link>
</li>
</ul>
</div>
<div>
<Link to="/2">Pattern 2</Link>
<ul>
<li>
<Link to="/2/task-orange">Task Orange</Link>
</li>
<li>
<Link to="/2/task-gray/introduction?loggedIn=true">Task Gray</Link>
</li>
<li>
<Link to="/2/task-blue">Task Blue</Link>
</li>
<li>
<Link to="/2/post-study">Post Study</Link>
</li>
</ul>
</div>
</div>
);
};
Expand Down
Loading

0 comments on commit 2aea3eb

Please sign in to comment.