Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove pre UIRefresh2022 code #374

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions spec/config-spec.js

This file was deleted.

26 changes: 0 additions & 26 deletions spec/util/sheet-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const Sheet = require('../../src/util/sheet')
const config = require('../../src/config')

jest.mock('../../src/config')
describe('sheet', function () {
const oldEnv = process.env
beforeEach(() => {
config.mockReturnValue({ featureToggles: { UIRefresh2022: true } })
process.env.API_KEY = 'API_KEY'
})

@@ -113,27 +110,4 @@ describe('sheet', function () {
expect(mockCallback).toHaveBeenCalledTimes(1)
expect(mockCallback).toHaveBeenCalledWith({ message: errorMessage }, 'API_KEY')
})

it('should give the sheet not found error with old message', () => {
const errorMessage = 'Oops! We can’t find the Google Sheet you’ve entered. Can you check the URL?'
const mockCallback = jest.fn()
const xhrMock = { open: jest.fn(), send: jest.fn(), readyState: 4, status: 404, response: 'response' }
jest.spyOn(window, 'XMLHttpRequest').mockImplementation(() => xhrMock)
config.mockReturnValue({ featureToggles: { UIRefresh2022: false } })

const sheet = new Sheet('http://example.com/a/b/c/d/?x=y')
sheet.validate(mockCallback)
xhrMock.onreadystatechange(new Event(''))

expect(xhrMock.open).toHaveBeenCalledTimes(1)
expect(xhrMock.open).toHaveBeenCalledWith(
'GET',
'https://docs.google.com/spreadsheets/d/http://example.com/a/b/c/d/?x=y',
true,
)
expect(xhrMock.send).toHaveBeenCalledTimes(1)
expect(xhrMock.send).toHaveBeenCalledWith(null)
expect(mockCallback).toHaveBeenCalledTimes(1)
expect(mockCallback).toHaveBeenCalledWith({ message: errorMessage }, 'API_KEY')
})
})
16 changes: 0 additions & 16 deletions src/config.js

This file was deleted.

14 changes: 3 additions & 11 deletions src/graphing/blips.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ const { renderBlipDescription } = require('./components/quadrantTables')
const Blip = require('../models/blip')
const isEmpty = require('lodash/isEmpty')
const { replaceSpaceWithHyphens, removeAllSpaces } = require('../util/stringUtil')
const config = require('../config')
const featureToggles = config().featureToggles
const _ = {
sortBy: require('lodash/sortBy'),
}
@@ -86,24 +84,18 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor
)
let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip)
let iterationCounter = 0
let foundAPlace = false

while (iterationCounter < maxIterations) {
if (thereIsCollision(coordinates, allBlipCoordinatesInRing, blip.width)) {
coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip)
} else {
foundAPlace = true
// found a valid coordinate
break
}
iterationCounter++
}
if (!featureToggles.UIRefresh2022 && !foundAPlace && blip.width > graphConfig.minBlipWidth) {
blip.width = blip.width - 1
blip.scale = Math.max((blip.scale || 1) - 0.1, 0.7)
return findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoordinatesInRing, quadrantOrder)
} else {
return coordinates
}

return coordinates
}

function blipAssistiveText(blip) {
31 changes: 5 additions & 26 deletions src/graphing/components/banner.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
const d3 = require('d3')

const config = require('../../config')
const { addPdfCoverTitle } = require('../pdfPage')
const featureToggles = config().featureToggles

function renderBanner(renderFullRadar) {
if (featureToggles.UIRefresh2022) {
const documentTitle = document.title[0].toUpperCase() + document.title.slice(1)
const documentTitle = document.title[0].toUpperCase() + document.title.slice(1)

document.title = documentTitle
d3.select('.hero-banner__wrapper').append('p').classed('hero-banner__subtitle-text', true).text(document.title)
d3.select('.hero-banner__title-text').on('click', renderFullRadar)
document.title = documentTitle
d3.select('.hero-banner__wrapper').append('p').classed('hero-banner__subtitle-text', true).text(document.title)
d3.select('.hero-banner__title-text').on('click', renderFullRadar)

addPdfCoverTitle(documentTitle)
} else {
const header = d3.select('body').insert('header', '#radar')
header
.append('div')
.attr('class', 'radar-title')
.append('div')
.attr('class', 'radar-title__text')
.append('h1')
.text(document.title)
.style('cursor', 'pointer')
.on('click', renderFullRadar)

header
.select('.radar-title')
.append('div')
.attr('class', 'radar-title__logo')
.html('<a href="https://www.thoughtworks.com"> <img src="/images/logo.png" /> </a>')
}
addPdfCoverTitle(documentTitle)
}

module.exports = {
Loading