Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5319 from GCTC-NTGC/release/v1.3.0
Browse files Browse the repository at this point in the history
Release/v1.3.0 - Deployed to Prod on 2021-03-02
  • Loading branch information
tristan-orourke authored Mar 2, 2021
2 parents b25be8f + de30189 commit d8e2f11
Show file tree
Hide file tree
Showing 381 changed files with 18,534 additions and 7,580 deletions.
25 changes: 16 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
"jest": true
},
"extends": [
"airbnb",
"plugin:react/recommended",
"plugin:testcafe/recommended",
"plugin:@typescript-eslint/recommended",
"airbnb",
"plugin:prettier/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react",
"plugin:testcafe/recommended"
"prettier"
],
"globals": {
"Atomics": "readonly",
Expand All @@ -28,12 +26,15 @@
"project": "./tsconfig.json"
},
"plugins": [
"prettier",
"react",
"@typescript-eslint",
"react-hooks",
"testcafe"
"testcafe",
"@typescript-eslint"
],
"rules": {
"camelcase": "warn",
"consistent-return": "warn",
"import/no-extraneous-dependencies": [
"error",
{
Expand All @@ -46,6 +47,7 @@
"warn",
"never"
],
"react/display-name": "off",
"react/prop-types": "off",
"react/jsx-filename-extension": [
1,
Expand All @@ -57,6 +59,7 @@
}
],
"react/jsx-props-no-spreading": "off",
"react/require-default-props": "off",
"jsx-a11y/label-has-for": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
Expand All @@ -68,7 +71,6 @@
}
],
"no-param-reassign": "warn",
"@typescript-eslint/ban-ts-ignore": "warn",
"jsx-a11y/no-noninteractive-element-to-interactive-role": [
"error",
{
Expand Down Expand Up @@ -106,7 +108,12 @@
]
}
],
"@typescript-eslint/no-empty-function": "warn"
"@typescript-eslint/no-empty-function": "warn",
"no-use-before-define": "off",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-use-before-define": "warn",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
},
"settings": {
"react": {
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ jobs:
${{ runner.os }}-composer-
- name: Install dependencies
uses: MilesChou/composer-action/7.2/install@master
uses: php-actions/composer@v5
with:
args: install --no-interaction --prefer-dist --no-progress --no-suggest
args: --no-interaction --prefer-dist --no-progress --no-suggest
php_version: 7.2
version: 1

- name: Setup Node.js
uses: actions/setup-node@v1
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
stories: ['../**/*.stories.@(tsx)'],
stories: ['../resources/assets/js/**/*.stories.@(tsx)'],
addons: [
'@storybook/addon-knobs/register',
'@storybook/addon-actions/register',
Expand Down
10 changes: 8 additions & 2 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<link href="https://talent.test/css/app.css" rel="stylesheet" type="text/css" />
<link href="https://talent.test/css/h2.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Euphoria+Script&amp;subset=latin-ext" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous" />
<script src="https://talent.test/js/modernizr.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/@hydrogen-design-system/system@latest/dist/compiled/latest/system.min.js">
</script>
<script>
const addClone = setInterval(function () {
const addDesignSystems = setInterval(function () {
if (document.getElementById('root')) {
document.querySelector('#root').setAttribute('data-clone', '');
clearInterval(addClone);
document.querySelector('#root').setAttribute('data-h2-system', '');
document.querySelector('#root').setAttribute('data-h2-props', '');
clearInterval(addDesignSystems);
}
}, 200);
</script>
13 changes: 10 additions & 3 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
var path = require("path");
module.exports = ({ config }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
include: path.resolve(__dirname, "..", "resources/assets/js"),
use: [
require.resolve("ts-loader"),
require.resolve("react-docgen-typescript-loader"),
]
{
loader: require.resolve("ts-loader"),
options: {
transpileOnly: true,
}
}
],
});

config.resolve.extensions.push(".ts", ".tsx");
return config;
};
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"workbench.settings.useSplitJSON": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": false,
"editor.codeActionsOnSaveTimeout": 1500
}
15 changes: 14 additions & 1 deletion app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request;

if (!function_exists('humanizeDate')) {
/**
Expand Down Expand Up @@ -161,3 +161,16 @@ function ptDayEndToUtcTime(string $date) : Date
return $date;
}
}

if (!function_exists('detectInternetExplorer')) {
/**
* Detect User Agent Internet Explorer
*
* @return boolean
*/
function detectInternetExplorer()
{
$agent = Request::server('HTTP_USER_AGENT');
return preg_match('~MSIE|Internet Explorer~i', $agent) || preg_match('~Trident/7.0(.*)?; rv:11.0~', $agent);
}
}
86 changes: 86 additions & 0 deletions app/Http/Controllers/Api/ApplicantController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateApplicantProfile;
use App\Http\Resources\ApplicantProfile as ApplicantProfileResource;
use App\Models\Applicant;
use App\Models\ApplicantClassification;

class ApplicantController extends Controller
{

/**
* Retrieve Applicant profile.
*
* @param Applicant $applicant Incoming Applicant object.
*
* @return mixed
*/
public function getProfile(Applicant $applicant)
{
$applicant->loadMissing('applicant_classifications');
return new ApplicantProfileResource($applicant);
}

/**
* Update Applicant profile.
*
* @param UpdateApplicantProfile $request Form Validation casted request object.
* @param Applicant $applicant Incoming Applicant object.
*/
public function updateProfile(UpdateApplicantProfile $request, Applicant $applicant)
{
$validatedRequest = $request->validated();
// If there are no applicant classifications in the request,
// then delete all applicant classifications attached to applicant.
if (!array_key_exists('applicant_classifications', $validatedRequest)) {
$applicant->applicant_classifications()->delete();
} else {
$newApplicantClassifications = collect($validatedRequest['applicant_classifications'])->unique(
// Remove all duplicate classification-level combinations from the collection.
function ($newApplicantClassification) {
return $newApplicantClassification['classification_id'].$newApplicantClassification['level'];
}
);
$oldApplicantClassifications = $applicant->applicant_classifications;

// Delete old applicant classifications that were not resubmitted.
foreach ($oldApplicantClassifications as $oldApplicantClassification) {
$newApplicantClassification = $newApplicantClassifications->firstWhere(
'id',
$oldApplicantClassification['id']
);
if ($newApplicantClassification === null) {
$oldApplicantClassification->delete();
}
}


// Update old applicant classifications and/or create them if it doesn't exist.
$newApplicantClassifications->map(function ($newApplicantClassification) use ($oldApplicantClassifications) {
$applicantClassification = $oldApplicantClassifications->firstWhere(
'id',
$newApplicantClassification['id']
);
if (!$applicantClassification) {
$applicantClassification = new ApplicantClassification();
}
$applicantClassification->applicant_id = $newApplicantClassification['applicant_id'];
$applicantClassification->classification_id = $newApplicantClassification['classification_id'];
$applicantClassification->fill($newApplicantClassification);
$applicantClassification->save();
});
}

$applicant->citizenship_declaration_id = $validatedRequest['citizenship_declaration_id'];
$applicant->veteran_status_id = $validatedRequest['veteran_status_id'];
$applicant->save();

$applicant->refresh();
$applicant->loadMissing('applicant_classifications');

return new ApplicantProfileResource($applicant);
}
}
35 changes: 35 additions & 0 deletions app/Http/Controllers/Api/ApplicantSkillsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateApplicantSkills;
use App\Models\Applicant;
use App\Models\ExperienceSkill;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\DB;

class ApplicantSkillsController extends Controller
{
public function index(Applicant $applicant)
{
return [
'skill_ids' => $applicant->skills->pluck('id')->all()
];
}

public function update(UpdateApplicantSkills $request, Applicant $applicant)
{
$skillIds = $request->validated()['skill_ids'];
$applicant->skills()->sync($skillIds);

// $deletedExperienceSkills = $applicant->experienceSkillsQuery()->whereNotIn('skill_id', $skillIds)->get();
// I'm leaving the above line commented out for now, but if we want to do something with the
// deleted ExperienceSkill objects, we can retrieve them before deleting and include
// them in the api response.
$applicant->experienceSkillsQuery()->whereNotIn('skill_id', $skillIds)->delete();
return [
'skill_ids' => $skillIds,
// 'deleted_experience_skills' => JsonResource::collection($deletedExperienceSkills),
];
}
}
50 changes: 33 additions & 17 deletions app/Http/Controllers/Api/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function submit(Request $request, JobApplication $application)
if (!$applicationComplete) {
$userId = $application->applicant->user_id;
$msg = "Application $application->id for user $userId is invalid for submission: " .
implode('; ', $validator->detailedValidatorErrors($application));
implode('; ', $validator->detailedValidatorErrors($application));
Log::info($msg);

throw ValidationException::withMessages($validator->detailedValidatorErrors($application));
Expand All @@ -94,14 +94,21 @@ public function submit(Request $request, JobApplication $application)
*/
public function show(JobApplication $application)
{
$application->loadMissing(
'applicant',
// Initialize an empty Application Review if none exists. This
// simplifies the front end logic when performing batch updates.
if ($application->application_review === null) {
$application->application_review = new ApplicationReview();
$application->application_review->job_application_id = $application->id;
$application->application_review->save();
}

return new JobApplicationResource($application->fresh([
'applicant.user',
'application_review',
'citizenship_declaration',
'veteran_status',
'job_application_answers'
);
return new JobApplicationResource($application);
]));
}

/**
Expand All @@ -113,16 +120,24 @@ public function show(JobApplication $application)
*/
public function index(JobPoster $jobPoster)
{
$applications = $jobPoster->submitted_applications()
->with([
'applicant.user',
'application_review.department',
'citizenship_declaration',
'veteran_status'
])
->get();

return JobApplicationResource::collection($applications);
$applications = $jobPoster->submitted_applications()->get();

// Initialize an empty Application Review if none exists. This
// simplifies the front end logic when performing batch updates.
foreach ($applications as $application) {
if ($application->application_review === null) {
$application->application_review = new ApplicationReview();
$application->application_review->job_application_id = $application->id;
$application->application_review->save();
}
}

return JobApplicationResource::collection($applications->fresh([
'applicant.user',
'application_review.department',
'citizenship_declaration',
'veteran_status'
]));
}

/**
Expand Down Expand Up @@ -162,13 +177,14 @@ public function updateReview(Request $request, JobApplication $application)
]);
$review->save();

if ($application->job_poster->department_id === $strategicResponseDepartmentId
if (
$application->job_poster->department_id === $strategicResponseDepartmentId
&& in_array($review->review_status_id, $availabilityStatuses->toArray())
) {
$this->setAvailability($application);
}

$review->fresh();
$review = $review->fresh();
$review->loadMissing('department');

return new JsonResource($review);
Expand Down
Loading

0 comments on commit d8e2f11

Please sign in to comment.