Skip to content

Commit

Permalink
feat: make collapsible a feature toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaminia Cavallo authored and Flaminia Cavallo committed Jul 9, 2024
1 parent 1d7ab9d commit fd6bb57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/data-workspace/section-form/section-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import { useSectionFilter } from '../../shared/index.js'
import { useFeature } from '../use-feature.js'
import { SectionFormSection } from './section.js'
import styles from './section.module.css'

Expand All @@ -23,6 +24,7 @@ export const SectionForm = ({ dataSet, globalFilterText }) => {

const { displayOptions: displayOptionString } = dataSet
const displayOptions = parseDisplayOptions(displayOptionString)
const featureToggleCollapsible = useFeature('collapsible')

if (dataSet.renderAsTabs) {
return (
Expand All @@ -31,7 +33,6 @@ export const SectionForm = ({ dataSet, globalFilterText }) => {
sections={dataSet.sections}
dataSetId={dataSet.id}
direction={displayOptions?.tabsDirection}
collapsible={displayOptions?.collapsibleSections}
/>
)
}
Expand All @@ -44,7 +45,7 @@ export const SectionForm = ({ dataSet, globalFilterText }) => {
dataSetId={dataSet.id}
key={s.id}
globalFilterText={globalFilterText}
collapsible={displayOptions?.collapsibleSections}
collapsible={featureToggleCollapsible}
/>
))}
</>
Expand All @@ -53,10 +54,7 @@ export const SectionForm = ({ dataSet, globalFilterText }) => {

SectionForm.propTypes = {
dataSet: PropTypes.shape({
displayOptions: PropTypes.shape({
collapsibleSections: PropTypes.bool,
tabsDirection: PropTypes.oneOf(['vertical', 'horizontal']),
}),
displayOptions: PropTypes.string,
id: PropTypes.string,
renderAsTabs: PropTypes.bool,
sections: PropTypes.arrayOf(
Expand Down
8 changes: 8 additions & 0 deletions src/data-workspace/use-feature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { StringParam, useQueryParam } from 'use-query-params'

export function useFeature(feature) {
const [allFeatures] = useQueryParam('features', StringParam)
const features = allFeatures?.split(',')

return !!features?.includes(feature)
}

0 comments on commit fd6bb57

Please sign in to comment.