Skip to content

Commit

Permalink
EDSC-3971: Update feature toggles to be string for CI variables
Browse files Browse the repository at this point in the history
Bamboo vars are passed in as strings so we need to key off of a string value instead since otherwise all the vars for this will truthy
  • Loading branch information
eudoroolivares2016 authored Jan 29, 2024
1 parent 01d2b53 commit 81568d7
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions static.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"lambda": "eed-PORTAL-ENV-serverless-lambda"
},
"disableEddDownload": "false",
"disableOrdering": false,
"disableDatabaseComponents": false,
"disableOrdering": "false",
"disableDatabaseComponents": "false",
"macOSEddDownloadSize":130,
"windowsEddDownloadSize":100,
"linuxEddDownloadSize":90
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class SpatialSelectionDropdown extends PureComponent {
render() {
const { disableDatabaseComponents } = getApplicationConfig()

// Parse string field `disableDatabaseComponents` disable shapefile search if true
const disableShapefileSearch = disableDatabaseComponents === 'true'

const spatialSelectionFileSpan = (
<span>
File
Expand Down Expand Up @@ -131,10 +134,10 @@ export class SpatialSelectionDropdown extends PureComponent {
icon={FaFile}
onClick={() => this.onItemClick('file')}
label="Select Shapefile"
disabled={disableDatabaseComponents}
disabled={disableShapefileSearch}
>
{
disableDatabaseComponents ? (
disableShapefileSearch ? (
<OverlayTrigger
placement="right"
overlay={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('SpatialSelectionDropdown component', () => {
describe('if the database is disabled', () => {
test('searching with the `shapefileUpload` buttons should also be disabled', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

const { enzymeWrapper } = setup()
Expand All @@ -119,7 +119,7 @@ describe('SpatialSelectionDropdown component', () => {

test('hovering over the shapefile reveals tool-tip', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

const { enzymeWrapper } = setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const AuthRequiredContainer = ({
const { disableDatabaseComponents } = getApplicationConfig()

const token = get('authToken')
if (disableDatabaseComponents) {
if (disableDatabaseComponents === 'true') {
remove('authToken')
}

Expand All @@ -32,7 +32,7 @@ export const AuthRequiredContainer = ({
setIsLoggedIn(false)
if (!noRedirect) {
let location = `${apiHost}/login?ee=${earthdataEnvironment}&state=${encodeURIComponent(returnPath)}`
if (disableDatabaseComponents) {
if (disableDatabaseComponents === 'true') {
location = '/search'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('AuthRequiredContainer component', () => {
describe('when database components are turned off', () => {
test('should redirect to the home `search` page', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

setup()
Expand All @@ -120,7 +120,7 @@ describe('AuthRequiredContainer component', () => {

test('the token cookie should be cleared', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

jest.spyOn(tinyCookie, 'remove').mockImplementation(() => null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const ErrorBannerContainer = ({ errors, onRemoveError }) => {
const regex = /connect ECONNREFUSED/
const dbConnectionError = regex.test(error.message)

if (disableDatabaseComponents && dbConnectionError) {
if ((disableDatabaseComponents === 'true') && dbConnectionError) {
console.log('Error caught for database being down ', error.message)

return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function setup(overrideProps) {
describe('When the database is disabled', () => {
test('ensure that error messages for database connections refusals do not render', async () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementationOnce(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

const { enzymeWrapper } = setup({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const mapStateToProps = (state) => ({
export const SecondaryToolbarContainer = (props) => {
const { disableDatabaseComponents } = getApplicationConfig()
let secondaryToolbarEnabled = true
if (disableDatabaseComponents) secondaryToolbarEnabled = false

if (disableDatabaseComponents === 'true') secondaryToolbarEnabled = false

const {
authToken,
earthdataEnvironment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SecondaryToolbar from '../../../components/SecondaryToolbar/SecondaryTool

beforeEach(() => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: false
disableDatabaseComponents: 'false'
}))
})

Expand Down Expand Up @@ -114,7 +114,7 @@ describe('SecondaryToolbarContainer component', () => {
describe('if the secondaryToolbar should be disabled', () => {
test('passes the `secondaryToolbarEnabled` prop and to the Secondary toolbar as false', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableDatabaseComponents: true
disableDatabaseComponents: 'true'
}))

const { enzymeWrapper } = setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as getApplicationConfig from '../../../../../../sharedUtils/config'

beforeEach(() => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableOrdering: false
disableOrdering: 'false'
}))
})

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('buildAccessMethods', () => {
describe('when ordering is disabled', () => {
test('no echo-order access method is returned', () => {
jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({
disableOrdering: true
disableOrdering: 'true'
}))

const collectionMetadata = {
Expand Down
2 changes: 1 addition & 1 deletion static/src/js/util/accessMethods/buildAccessMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => {

// Only process orderOptions if the service type uses orderOptions
// Do not include access if orders are disabled
if (supportsOrderOptions.includes(serviceType.toLowerCase()) && !disableOrdering) {
if (supportsOrderOptions.includes(serviceType.toLowerCase()) && (disableOrdering !== 'true')) {
const { items: orderOptionsItems } = orderOptions
if (orderOptionsItems === null) return

Expand Down

0 comments on commit 81568d7

Please sign in to comment.