Skip to content

Commit

Permalink
refactor: remove dasherize (#50620)
Browse files Browse the repository at this point in the history
  • Loading branch information
moT01 committed Jun 8, 2023
1 parent 2f9ce8d commit 167a8e7
Show file tree
Hide file tree
Showing 48 changed files with 115 additions and 180 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ config/superblocks.js
config/superblocks.test.js

### Generated utils files ###
utils/block-nameify.js
utils/block-nameify.test.js
utils/slugs.js
utils/slugs.test.js
utils/index.js
utils/get-lines.js
utils/get-lines.test.js
Expand Down
4 changes: 0 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ config/certification-settings.js
config/donation-settings.js
config/superblocks.js
config/superblocks.test.js
utils/block-nameify.js
utils/block-nameify.test.js
utils/slugs.js
utils/slugs.test.js
utils/index.js
utils/get-lines.js
utils/get-lines.test.js
Expand Down
1 change: 1 addition & 0 deletions client/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
block
certification
challengeType
dashedName
fields {
slug
}
Expand Down
21 changes: 12 additions & 9 deletions client/src/templates/Challenges/components/completion-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { withTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

import { dasherize } from '../../../../../utils/slugs';
import Login from '../../../components/Header/components/login';
import { executeGA } from '../../../redux/actions';
import {
Expand Down Expand Up @@ -40,15 +39,15 @@ const mapStateToProps = createSelector(

(
challengeFiles: ChallengeFiles,
{ title }: { title: string; id: string },
{ dashedName }: { dashedName: string },
completedChallengesIds: string[],
isOpen: boolean,
isSignedIn: boolean,
allChallengesInfo: AllChallengesInfo,
message: string
) => ({
challengeFiles,
title,
dashedName,
completedChallengesIds,
isOpen,
isSignedIn,
Expand Down Expand Up @@ -144,16 +143,20 @@ class CompletionModal extends Component<
}

render(): JSX.Element {
const { close, isOpen, isSignedIn, message, t, title, submitChallenge } =
this.props;
const {
close,
isOpen,
isSignedIn,
message,
t,
dashedName,
submitChallenge
} = this.props;

if (isOpen) {
executeGA({ event: 'pageview', pagePath: '/completion-modal' });
}
// normally dashedName should be graphQL queried and then passed around,
// but it's only used to make a nice filename for downloading, so dasherize
// is fine here.
const dashedName = dasherize(title);

return (
<Modal
animation={false}
Expand Down
5 changes: 1 addition & 4 deletions client/src/utils/get-completion-percentage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AllChallengesInfo } from '../redux/prop-types';
import { dasherize } from '../../../utils/slugs';
import { isFinalProject } from '../../utils/challenge-types';

export function getCompletedPercentage(
Expand Down Expand Up @@ -43,9 +42,7 @@ export const getCurrentBlockIds = (
const { challengeEdges, certificateNodes } = allChallengesInfo;
const currentCertificateIds =
certificateNodes
.filter(
node => dasherize(node.challenge.certification) === certification
)[0]
.filter(node => node.challenge.certification === certification)[0]
?.challenge.tests.map(test => test.id) ?? [];
const currentBlockIds = challengeEdges
.filter(edge => edge.node.challenge.block === block)
Expand Down
5 changes: 3 additions & 2 deletions client/utils/gatsby/challenge-page-creator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const { dasherize } = require('../../../utils/slugs');
const { sortChallengeFiles } = require('../../../utils/sort-challengefiles');
const { challengeTypes, viewTypes } = require('../challenge-types');

Expand Down Expand Up @@ -79,6 +78,7 @@ function getTemplateComponent(challengeType) {
exports.createChallengePages = function (createPage) {
return function ({ node: { challenge } }, index, allChallengeEdges) {
const {
dashedName,
certification,
superBlock,
block,
Expand All @@ -96,6 +96,7 @@ exports.createChallengePages = function (createPage) {
component: getTemplateComponent(challengeType),
context: {
challengeMeta: {
dashedName,
certification,
superBlock,
block,
Expand Down Expand Up @@ -163,7 +164,7 @@ exports.createBlockIntroPages = function (createPage) {
path: slug,
component: intro,
context: {
block: dasherize(block),
block,
slug
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Caesars Cipher Project",
"isUpcomingChange": true,
"dashedName": "build-a-caesars-cipher-project",
"usesMultifileEditor": false,
"helpCategory": "JavaScript",
"order": 17,
Expand All @@ -14,4 +15,4 @@
"Build a Caesars Cipher"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Cash Register Project",
"isUpcomingChange": true,
"dashedName": "build-a-cash-register-project",
"usesMultifileEditor": false,
"helpCategory": "JavaScript",
"order": 14,
Expand All @@ -14,4 +15,4 @@
"Build a Cash Register"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Celestial Bodies Database Project",
"isUpcomingChange": false,
"dashedName": "build-a-celestial-bodies-database-project",
"order": 2,
"helpCategory": "Backend Development",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Celestial Bodies Database"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Data Graph Explorer Project",
"isUpcomingChange": false,
"dashedName": "build-a-data-graph-explorer-project",
"order": 19,
"helpCategory": "Python",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Data Graph Explorer"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Financial Calculator Project",
"isUpcomingChange": false,
"dashedName": "build-a-financial-calculator-project",
"order": 17,
"helpCategory": "Python",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Financial Calculator"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Graphing Calculator Project",
"isUpcomingChange": false,
"dashedName": "build-a-graphing-calculator-project",
"order": 11,
"helpCategory": "Python",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Graphing Calculator"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Multi-Function Calculator Project",
"isUpcomingChange": false,
"dashedName": "build-a-multi-function-calculator-project",
"order": 6,
"helpCategory": "Python",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Multi-Function Calculator"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Number Guessing Game Project",
"isUpcomingChange": false,
"dashedName": "build-a-number-guessing-game-project",
"order": 13,
"helpCategory": "Backend Development",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Number Guessing Game"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Palindrome Checker Project",
"isUpcomingChange": true,
"dashedName": "build-a-palindrome-checker-project",
"usesMultifileEditor": false,
"helpCategory": "JavaScript",
"order": 3,
Expand All @@ -14,4 +15,4 @@
"Build a Palindrome Checker"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Periodic Table Database Project",
"isUpcomingChange": false,
"dashedName": "build-a-periodic-table-database-project",
"order": 12,
"helpCategory": "Backend Development",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Periodic Table Database"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Personal Portfolio Webpage Project",
"isUpcomingChange": false,
"dashedName": "build-a-personal-portfolio-webpage-project",
"usesMultifileEditor": true,
"helpCategory": "HTML-CSS",
"order": 19,
Expand All @@ -14,4 +15,4 @@
"Build a Personal Portfolio Webpage"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Product Landing Page Project",
"isUpcomingChange": false,
"dashedName": "build-a-product-landing-page-project",
"usesMultifileEditor": true,
"helpCategory": "HTML-CSS",
"order": 16,
Expand All @@ -14,4 +15,4 @@
"Build a Product Landing Page"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Roman Numeral Converter Project",
"isUpcomingChange": true,
"dashedName": "build-a-roman-numeral-converter-project",
"usesMultifileEditor": false,
"helpCategory": "JavaScript",
"order": 6,
Expand All @@ -14,4 +15,4 @@
"Build a Roman Numeral Converter"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Salon Appointment Scheduler Project",
"isUpcomingChange": false,
"dashedName": "build-a-salon-appointment-scheduler-project",
"order": 9,
"helpCategory": "Backend Development",
"time": "30 hours",
Expand All @@ -13,4 +14,4 @@
"Build a Salon Appointment Scheduler"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Survey Form Project",
"isUpcomingChange": false,
"dashedName": "build-a-survey-form-project",
"usesMultifileEditor": true,
"helpCategory": "HTML-CSS",
"order": 4,
Expand All @@ -14,4 +15,4 @@
"Build a Survey Form"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Technical Documentation Page Project",
"isUpcomingChange": false,
"dashedName": "build-a-technical-documentation-page-project",
"usesMultifileEditor": true,
"helpCategory": "HTML-CSS",
"order": 13,
Expand All @@ -14,4 +15,4 @@
"Build a Technical Documentation Page"
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Build a Telephone Number Validator Project",
"isUpcomingChange": true,
"dashedName": "build-a-telephone-number-validator-project",
"usesMultifileEditor": false,
"helpCategory": "JavaScript",
"order": 10,
Expand All @@ -14,4 +15,4 @@
"Build a Telephone Number Validator"
]
]
}
}

0 comments on commit 167a8e7

Please sign in to comment.