Skip to content

Commit

Permalink
[MIM-848] Mim 848 feature toggle summer cleanup (#2820)
Browse files Browse the repository at this point in the history
* Remove unused feature toggles
MIM-848

* Remove old feature toggles that are enabled true by default

* Remove unused highchart-expert feature toggle

* Remove hide-in-header-qa feature and feature toggle

* Re-import isEnabled in default

* Fix import

* Re-implement highchart-expert feature toggle

* Re-implement deactive part cache feature toggles for article list and released statistics

* Revert "Remove hide-in-header-qa feature and feature toggle"

This reverts commit 5b4851f.
  • Loading branch information
johnnadeluy authored Jul 24, 2024
1 parent 2d713e8 commit 592e3b6
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 82 deletions.
2 changes: 0 additions & 2 deletions src/main/resources/admin/tools/dashboard/dashboard.es6
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { parseContributions, getEnvironmentString } from '/lib/ssb/utils/utils'
import { render } from '/lib/thymeleaf'
import { renderError } from '/lib/ssb/error/error'
import { React4xp } from '/lib/enonic/react4xp'
import { isEnabled } from '/lib/featureToggle'

const view = resolve('./dashboard.html')
const DEFAULT_CONTENTSTUDIO_URL = getToolUrl('com.enonic.app.contentstudio', 'main')
Expand Down Expand Up @@ -63,7 +62,6 @@ function renderPart(req) {
internalBaseUrl: `${INTERNAL_BASE_URL}`,
internalStatbankUrl: `${INTERNAL_STATBANK_URL}`,
statregRapportUrl: `${STATREG_RAPPORT_URL}`,
toggleDebugging: isEnabled('dashboard-redux-logging-debugging', true, 'ssb'),
title: `${environmentString ? `${environmentString}: ` : ''}SSB Dashboard`,
})
.setId('dashboard')
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/lib/ssb/cron/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { list, schedule, type TaskMapper } from '/lib/cron'
import { cronJobLog } from '/lib/ssb/utils/serverLog'
import { ENONIC_CMS_DEFAULT_REPO } from '/lib/ssb/repo/common'
import { publishDataset } from '/lib/ssb/dataset/publishOld'
import { isEnabled } from '/lib/featureToggle'

const createUserContext: ContextParams = {
// Master context (XP)
Expand Down Expand Up @@ -139,15 +138,13 @@ export function setupCronJobs(): void {
}

// Push RSS Statkal
const pushRssStatkalEnabled: boolean = isEnabled('push-rss-statkal', false, 'ssb')
scheduleJob({
name: 'pushRssStatkal',
description: 'Push kommende publiseringer til rss/statkal',
descriptor: 'pushRssStatkal',
cronValue:
app.config && app.config['ssb.task.pushRssStatkal'] ? app.config['ssb.task.pushRssStatkal'] : '10 08 * * *',
timeZone: timezone,
updateEnabledTo: pushRssStatkalEnabled,
})

// Delete expired event logs for queries
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/lib/ssb/parts/highcharts/graph/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// @ts-nocheck

import { localize } from '/lib/xp/i18n'
import { isEnabled } from '/lib/featureToggle'
import { ensureArray } from '/lib/ssb/utils/arrayUtils'

export const style = {
Expand Down Expand Up @@ -326,7 +325,7 @@ export const createDefaultConfig = (highchartData, displayName, language) => ({
},
},
title: {
text: isEnabled('highcharts-y-axix-title-mobile', true, 'ssb') ? highchartData.yAxisTitle : '',
text: highchartData.yAxisTitle,
},
},
// right y axis
Expand All @@ -340,7 +339,7 @@ export const createDefaultConfig = (highchartData, displayName, language) => ({
},
},
title: {
text: isEnabled('highcharts-y-axix-title-mobile', true, 'ssb') ? highchartData.yAxisTitle : '',
text: highchartData.yAxisTitle,
},
},
],
Expand Down
7 changes: 2 additions & 5 deletions src/main/resources/lib/ssb/utils/nameSearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getNameGraphDataFromRepo, type NameData, nameGraphRepoExists } from '/l
import { request, HttpRequestParams, HttpResponse } from '/lib/http-client'

import { getCalculatorConfig, getNameSearchGraphData } from '/lib/ssb/dataset/calculator'
import { isEnabled } from '/lib/featureToggle'
import { type SolrResponse } from '/lib/types/solr'
import { type CalculatorConfig } from '/site/content-types'

Expand Down Expand Up @@ -53,10 +52,9 @@ export function getNameSearchResult(name: string, includeGraphData: boolean): So
}

export function prepareNameGraphResult(name: string): string {
const nameSearchGraphEnabled: boolean = isEnabled('name-graph', true, 'ssb')
const obj: ResultType = JSON.parse('{}')
obj.originalName = name
obj.nameGraph = nameSearchGraphEnabled ? prepareGraph(name) : []
obj.nameGraph = prepareGraph(name)
return JSON.stringify(obj)
}

Expand All @@ -65,10 +63,9 @@ export function prepareGraph(name: string): Array<NameGraph> {
}

function prepareResult(result: string, name: string, includeGraphData: boolean): string {
const nameSearchGraphEnabled: boolean = isEnabled('name-graph', true, 'ssb')
const obj: ResultType = JSON.parse(result)
obj.originalName = name
obj.nameGraphData = nameSearchGraphEnabled && includeGraphData ? prepareGraph(name) : []
obj.nameGraphData = includeGraphData ? prepareGraph(name) : []
return JSON.stringify(obj)
}

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/lib/types/partTypes/searchResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface SearchResultProps {
allContentTypesPhrase: string
allSubjectsPhrase: string
searchServiceUrl: string
nameSearchToggle: boolean
nameSearchData: object | undefined
nameSearchUrl: string
namePhrases: {
Expand Down
40 changes: 0 additions & 40 deletions src/main/resources/main.es6
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,14 @@ try {
{
space: 'ssb',
features: [
{
feature: 'rss-news',
enabled: true,
},
{
feature: 'rss-news-statistics',
enabled: false,
},
{
feature: 'article-isbn',
enabled: true,
},
{
feature: 'articlelist-sorting',
enabled: false,
},
{
feature: 'name-graph',
enabled: false,
},
{
feature: 'dashboard-redux-logging-debugging',
enabled: true,
},
{
feature: 'highchart-show-datatable',
enabled: false,
},
{
feature: 'highchart-react',
enabled: false,
},
{
feature: 'highcharts-y-axix-title-mobile',
enabled: false,
},
{
feature: 'name-search-in-freetext-search',
enabled: false,
},
{
feature: 'deactivate-partcache-released-statistics',
enabled: true,
Expand All @@ -79,14 +47,6 @@ try {
feature: 'new-publication-archive',
enabled: false,
},
{
feature: 'datefns-publication-archive',
enabled: false,
},
{
feature: 'push-rss-statkal',
enabled: false,
},
{
feature: 'highchart-expert',
enabled: false,
Expand Down
19 changes: 7 additions & 12 deletions src/main/resources/services/news/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ import { StatisticInListing, VariantInListing } from '/lib/ssb/dashboard/statreg
import { getTimeZoneIso } from '/lib/ssb/utils/dateUtils'
import { subDays, isSameDay, format, parseISO } from '/lib/vendor/dateFns'
import { fetchStatisticsWithReleaseToday } from '/lib/ssb/statreg/statistics'
import { isEnabled } from '/lib/featureToggle'
import { xmlEscape } from '/lib/text-encoding'
import { type Statistic } from '/site/mixins/statistic'
import { type Default as DefaultPageConfig } from '/site/pages/default'
import { type Page, type Article, type Statistics } from '/site/content-types'

function get(): XP.Response {
const rssNewsEnabled: boolean = isEnabled('rss-news', true, 'ssb')
const rssStatisticsEnabled: boolean = isEnabled('rss-news-statistics', false, 'ssb')
const mainSubjects: Array<Content<Page & DefaultPageConfig>> = rssNewsEnabled
? (query({
start: 0,
count: 100,
query: 'components.page.config.mimir.default.subjectType LIKE "mainSubject"',
}).hits as unknown as Array<Content<Page & DefaultPageConfig>>)
: []
const mainSubjects: Array<Content<Page & DefaultPageConfig>> = query({
start: 0,
count: 100,
query: 'components.page.config.mimir.default.subjectType LIKE "mainSubject"',
}).hits as unknown as Array<Content<Page & DefaultPageConfig>>

const news: Array<News> = rssNewsEnabled ? getNews(mainSubjects) : []
const statistics: Array<News> = rssNewsEnabled && rssStatisticsEnabled ? getStatisticsNews(mainSubjects) : []
const news: Array<News> = getNews(mainSubjects)
const statistics: Array<News> = getStatisticsNews(mainSubjects)
const xml = `<?xml version="1.0" encoding="utf-8"?>
<rssitems count="${news.length + statistics.length}">
${[...news, ...statistics]
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/site/pages/default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { isEnabled } from '/lib/featureToggle'
import { ensureArray } from '/lib/ssb/utils/arrayUtils'
import { type SubjectItem } from '/lib/types/subject'
import { type MunicipalityWithCounty, type RequestWithCode } from '/lib/types/municipalities'
import { isEnabled } from '/lib/featureToggle'
import { type Default as DefaultPageConfig } from '/site/pages/default'
import { type Page, type Statistics } from '/site/content-types'

Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/site/parts/article/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getAssociatedStatisticsLinks, getAssociatedArticleArchiveLinks } from '
import * as util from '/lib/util'
import { getPhrases } from '/lib/ssb/utils/language'
import { renderError } from '/lib/ssb/error/error'
import { isEnabled } from '/lib/featureToggle'
import { type ArticleProps } from '/lib/types/partTypes/article'
import { type Article } from '/site/content-types'

Expand Down Expand Up @@ -76,7 +75,7 @@ function renderPart(req: XP.Request) {
serialNumber: page.data.serialNumber,
associatedStatistics: getAssociatedStatisticsLinks(associatedStatisticsConfig),
associatedArticleArchives: getAssociatedArticleArchiveLinks(associatedArticleArchivesConfig),
isbn: isEnabled('article-isbn', true) ? page.data.isbnNumber : undefined,
isbn: page.data.isbnNumber,
}

return render('site/parts/article/article', props, req, {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/site/parts/highchart/highchart.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div data-th-if="${highchart && highchart.config && highchart.config.draft}" class="alert alert-info mb-4" role="alert" data-th-text="${'Tallet i figuren nedenfor er upublisert'}"></div>
<div data-th-if="${highchart && highchart.config && highchart.config.noDraftAvailable}" class="alert alert-warning mb-4" role="alert" data-th-text="${'Det finnes ingen upubliserte tall for denne figuren'}"></div>
<div class="col-12">
<figure data-th-fragment="graph" class="highcharts-figure mb-0" data-th-classappend="${highchart.hideTitle == true || showDataTableEnabled ? 'hide-title' : ''}" data-th-id="figure- + ${highchart.contentKey}" data-th-if="${highchart && highchart.config}">
<figure data-th-fragment="graph" class="highcharts-figure mb-0" data-th-classappend="${!!highchart.hideTitle ? '' : 'hide-title'}" data-th-id="figure- + ${highchart.contentKey}" data-th-if="${highchart && highchart.config}">
<figcaption class="figure-title" data-th-if="${highchart.config.title && highchart.config.title.text}" data-th-text="${highchart.config.title.text}"/>
<p class="figure-subtitle" data-th-if="${highchart.config.subtitle && highchart.config.subtitle.text}" data-th-text="${highchart.config.subtitle.text}"/>
<div class="show-datatable" data-th-if="${showDataTableEnabled}">
<div class="show-datatable">
<div class="ssb-tabs" role="tablist">
<button class="navigation-item active" data-th-id="show-graph- + ${highchart.contentKey}" role="tab">
<span data-th-text="${showAsGraphText}"></span>
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/site/parts/highchart/highchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function renderPart(req: XP.Request, highchartIds: Array<string>): XP.Response {
highcharts,
downloadText,
sourceText,
showDataTableEnabled: isEnabled('highchart-show-datatable', false, 'ssb'),
showAsGraphText,
showAsTableText,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function renderPart(req: XP.Request): XP.Response {
function errorConfig(title = 'Feil i JSON konfigurasjon', message = '') {
const _message =
message ||
`JSON konfigurasjonen er ikke gyldig.
`JSON konfigurasjonen er ikke gyldig.
<br/>
Sjekk validitet av JSON på <a href="https://jsonlint.com/" target="_blank">jsonlint.com</a>
<br/>
Hvis du har kopiert fra en kodesnutt på nettet, kan du prøve å konvertere den til JSON på <a href="https://www.convertsimple.com/convert-javascript-to-json/" target="_blank">convertsimple.com</a>.
Hvis du har kopiert fra en kodesnutt på nettet, kan du prøve å konvertere den til JSON på <a href="https://www.convertsimple.com/convert-javascript-to-json/" target="_blank">convertsimple.com</a>.
Det må begynne med <strong>{</strong> og slutte med <strong>}</strong>`

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '/lib/ssb/repo/statisticVariant'
import { stringToServerTime } from '/lib/ssb/utils/dateUtils'
import { parseISO } from '/lib/vendor/dateFns'

import { fromPartCache } from '/lib/ssb/cache/partCache'
import { renderError } from '/lib/ssb/error/error'
import { isEnabled } from '/lib/featureToggle'
Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/site/parts/searchResult/searchResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { formatDate } from '/lib/ssb/utils/dateUtils'

import { renderError } from '/lib/ssb/error/error'
import { sanitizeForSolr } from '/lib/ssb/utils/textUtils'
import { isEnabled } from '/lib/featureToggle'
import { type BestBet, type ContentTypePhrase, type SearchResultProps } from '/lib/types/partTypes/searchResult'

export function get(req: XP.Request): XP.Response {
Expand Down Expand Up @@ -231,8 +230,6 @@ export function renderPart(req: XP.Request) {
}

const totalHits = bestBet() ? solrResult.total + 1 : solrResult.total
const showNameSearch = isEnabled('name-search-in-freetext-search') ? true : false

/* prepare props */
const props: SearchResultProps = {
bestBetHit: bestBet(),
Expand All @@ -241,8 +238,7 @@ export function renderPart(req: XP.Request) {
term: sanitizedTerm,
count,
title: content.displayName,
nameSearchToggle: showNameSearch,
nameSearchData: showNameSearch ? getNameDataResult() : undefined,
nameSearchData: getNameDataResult(),
noHitMessage: localize({
key: 'searchResult.noHitMessage',
locale: language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function SearchResult(props: SearchResultProps) {
</Col>
<Divider dark />
</div>
{props.nameSearchToggle && props.nameSearchData ? renderNameResult() : undefined}
{props.nameSearchData ? renderNameResult() : undefined}
<ol className='list-unstyled '>
{renderListItem(bestBetHit!)}
{hits.map((hit, i) => {
Expand Down Expand Up @@ -332,7 +332,7 @@ function SearchResult(props: SearchResultProps) {
if (props.language === 'en') {
return (
<div>
{props.nameSearchToggle ? renderNameResult() : undefined}
{renderNameResult()}
<Title size={2}>{props.noHitMessage}</Title>
<p>
Go to <Link href='/en/navn'>name search</Link>
Expand All @@ -348,7 +348,7 @@ function SearchResult(props: SearchResultProps) {
} else {
return (
<div>
{props.nameSearchToggle ? renderNameResult() : undefined}
{renderNameResult()}
<Title size={2}>{props.noHitMessage}</Title>
<p>
Her finner du <Link href='/navn'>navnesøk</Link>
Expand Down

0 comments on commit 592e3b6

Please sign in to comment.