Skip to content

Commit

Permalink
Merge pull request #130 from codytodonnell/bugfix/data
Browse files Browse the repository at this point in the history
Fix bugs causing issues with data paths
  • Loading branch information
codytodonnell authored Oct 7, 2024
2 parents 8df7bfa + 7736f18 commit dae7d47
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 121 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ jobs:
with:
working-directory: strudel-taskflows
browser: chrome
start: npm start
env:
VITE_BASE_URL: /strudel-kit/demo/
start: npm start
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:5175/strudel-kit/demo/',
baseUrl: 'http://localhost:5175/',
specPattern: ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', 'src/**/*.cy.{js,jsx,ts,tsx}']
},
});
2 changes: 0 additions & 2 deletions strudel-cookiecutter/base/{@cookiecutter.name@}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"gh-pages": "^6.1.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.0",
"typescript": "^5.2.2",
"vite": "^5.2.10"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { config } from '../../strudel.config';
import { AppLink } from './AppLink';
import { ImageWrapper } from './ImageWrapper';
import { cleanPath } from '../utils/queryParams.utils';

/**
* Bottom footer component
Expand Down Expand Up @@ -38,7 +39,7 @@ export const Footer: React.FC = () => {
{config.footer.image && (
<AppLink to="/">
<ImageWrapper height={60}>
<img src={`${import.meta.env.BASE_URL}/${config.footer.image}`} />
<img src={cleanPath(`${import.meta.env.BASE_URL}/${config.footer.image}`)} />
</ImageWrapper>
</AppLink>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import { AppLink } from './AppLink';
import { config } from '../../strudel.config';
import { ImageWrapper } from './ImageWrapper';
import { cleanPath } from '../utils/queryParams.utils';

/**
* Top navigation bar component
Expand Down Expand Up @@ -33,7 +34,7 @@ export const TopBar: React.FC = () => {
)}
{config.navbar.logo && (
<ImageWrapper height={30}>
<img src={`${import.meta.env.BASE_URL}/${config.navbar.logo}`} />
<img src={cleanPath(`${import.meta.env.BASE_URL}/${config.navbar.logo}`)} />
</ImageWrapper>
)}
</AppLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export const cleanUrl = (url: string) => {
return url.replace(/([^:]\/)\/+/g, "$1");
}

export const cleanPath = (url: string) => {
return url.replace(/\/\//g, "/");
}

/**
* Fetch data from a local CSV, TSV, or JSON, or an external API
* that returns JSON.
Expand All @@ -120,7 +124,8 @@ export const fetchData = async (dataSource: string) => {
const base = document.querySelector('base')?.getAttribute('href') ?? '';
// Use the VITE_BASE_URL env variable to specify a path prefix that
// should be added to routes and local requests
const basename = base + import.meta.env.VITE_BASE_URL;
const basePath = import.meta.env.VITE_BASE_URL || '';
const basename = base + basePath;
const fileExtension = dataSource.split('.').pop();
const isExternal = dataSource.startsWith('http');
const dataSourcePath = isExternal ? cleanUrl(dataSource) : cleanUrl(`${basename}/${dataSource}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const useDataFromSource = (dataSource: string): any => {
* Use the VITE_BASE_URL env variable to specify a path prefix that
* should be added to routes and local requests
*/
const basename = base + import.meta.env.VITE_BASE_URL;
const basePath = import.meta.env.VITE_BASE_URL || '';
const basename = base + basePath;

useEffect(() => {
const fetchData = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const taskflow: CompareDataConfig = {
/**
* Source of the data for the initial list of items.
*/
source: "default/compare-data/scenarios.json",
source: "data/default/compare-data/scenarios.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const taskflow: ContributeDataConfig = {
/**
* Source of the data for the initial list of datasets on the portal page.
*/
source: "default/contribute-data/contributor_datasets.json",
source: "data/default/contribute-data/contributor_datasets.json",
/**
* Name of the field in the data that represents a unique identifier for each record.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const taskflow: MonitorActivitiesConfig = {
/**
* Source of the data for the initial list of items.
*/
source: "default/monitor-activities/experiments.json",
source: "data/default/monitor-activities/experiments.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const taskflow: RunComputationConfig = {
/**
* Source of the data for the initial list of items.
*/
source: "default/run-computation/list.json",
source: "data/default/run-computation/list.json",
/**
* Field name for the unique ID in the data source.
*/
Expand All @@ -28,7 +28,7 @@ export const taskflow: RunComputationConfig = {
/**
* Source of the data for the table on the inputs page.
*/
source: "default/run-computation/inputs.json",
source: "data/default/run-computation/inputs.json",
/**
* Field name for the unique ID in the data source.
*/
Expand All @@ -40,21 +40,21 @@ export const taskflow: RunComputationConfig = {
* The return format must be compatible with Plotly's data attribue.
* See the [Plotly Figure Reference](https://plotly.com/javascript/reference/index/) for more details.
*/
source: "default/run-computation/results_line_chart.json"
source: "data/default/run-computation/results_line_chart.json"
},
barChart: {
/**
* Source of the data for the bar chart on the results page.
* The return format must be compatible with Plotly's data attribue.
* See the [Plotly Figure Reference](https://plotly.com/javascript/reference/index/) for more details.
*/
source: "default/run-computation/results_bar_chart.json"
source: "data/default/run-computation/results_bar_chart.json"
},
results: {
/**
* Source of the data for the table on the results page.
*/
source: "default/run-computation/results_table.json",
source: "data/default/run-computation/results_table.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const taskflow: SearchDataRepositoriesConfig = {
/**
* Source of the data for the initial list of items on the main page.
*/
source: "default/search-data-repositories/datasets.json",
source: "data/default/search-data-repositories/datasets.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
2 changes: 1 addition & 1 deletion strudel-taskflows/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:5175/strudel-kit/demo/',
baseUrl: 'http://localhost:5175/',
specPattern: ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', 'src/**/*.cy.{js,jsx,ts,tsx}']
},
});
86 changes: 0 additions & 86 deletions strudel-taskflows/package-lock.json

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

2 changes: 0 additions & 2 deletions strudel-taskflows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"gh-pages": "^6.1.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.0",
"typescript": "^5.2.2",
"vite": "^5.2.10"
},
Expand Down
3 changes: 2 additions & 1 deletion strudel-taskflows/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { config } from '../../strudel.config';
import { AppLink } from './AppLink';
import { ImageWrapper } from './ImageWrapper';
import { cleanPath } from '../utils/queryParams.utils';

/**
* Bottom footer component
Expand Down Expand Up @@ -38,7 +39,7 @@ export const Footer: React.FC = () => {
{config.footer.image && (
<AppLink to="/">
<ImageWrapper height={60}>
<img src={`${import.meta.env.BASE_URL}/${config.footer.image}`} />
<img src={cleanPath(`${import.meta.env.BASE_URL}/${config.footer.image}`)} />
</ImageWrapper>
</AppLink>
)}
Expand Down
3 changes: 2 additions & 1 deletion strudel-taskflows/src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import { AppLink } from './AppLink';
import { config } from '../../strudel.config';
import { ImageWrapper } from './ImageWrapper';
import { cleanPath } from '../utils/queryParams.utils';

/**
* Top navigation bar component
Expand Down Expand Up @@ -33,7 +34,7 @@ export const TopBar: React.FC = () => {
)}
{config.navbar.logo && (
<ImageWrapper height={30}>
<img src={`${import.meta.env.BASE_URL}/${config.navbar.logo}`} />
<img src={cleanPath(`${import.meta.env.BASE_URL}/${config.navbar.logo}`)} />
</ImageWrapper>
)}
</AppLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const taskflow: CompareDataConfig = {
/**
* Source of the data for the initial list of items.
*/
source: "default/compare-data/scenarios.json",
source: "data/default/compare-data/scenarios.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const taskflow: ContributeDataConfig = {
/**
* Source of the data for the initial list of datasets on the portal page.
*/
source: "default/contribute-data/contributor_datasets.json",
source: "data/default/contribute-data/contributor_datasets.json",
/**
* Name of the field in the data that represents a unique identifier for each record.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const taskflow: MonitorActivitiesConfig = {
/**
* Source of the data for the initial list of items.
*/
source: "default/monitor-activities/experiments.json",
source: "data/default/monitor-activities/experiments.json",
/**
* Field name for the unique ID in the data source.
*/
Expand Down
Loading

0 comments on commit dae7d47

Please sign in to comment.