Skip to content

Commit

Permalink
Add missing dev checks (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dagonite authored Nov 5, 2024
1 parent b4621fb commit c87656c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/ConfigSettings/ConfigSettingsGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ const ConfigSettingsGeneral: React.FC<ConfigSettingsGeneralProps> = ({ children
useEffect(() => {
const fetchSpecification = async (): Promise<void> => {
try {
const isDev = process.env.REACT_APP_DEV_MODE === 'true';
const token = isDev ? null : localStorage.getItem('scigateway:token');
const headers: { [key: string]: string } = { 'Content-Type': 'application/json' };
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}

const response = await fetch(`${fiaApiUrl}/instrument/${instrumentName}/specification`, {
method: 'GET',
headers: {
Authorization: `Bearer ${localStorage.getItem('scigateway:token')}`,
},
headers,
});

if (!response.ok) {
Expand Down
3 changes: 2 additions & 1 deletion src/Jobs/JobsAll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const JobsAll: React.FC = () => {
const [orderBy, setOrderBy] = useState<string>('run_start');
const offset = currentPage * rowsPerPage;
const query = `limit=${rowsPerPage}&offset=${offset}&order_by=${orderBy}&order_direction=${orderDirection}&include_run=true`;
const token = localStorage.getItem('scigateway:token');
const isDev = process.env.REACT_APP_DEV_MODE === 'true';
const token = isDev ? null : localStorage.getItem('scigateway:token');
const fetchJobs = useFetchJobs(`${fiaApiUrl}/jobs`, query, setJobs, token);
const fetchTotalCount = useFetchTotalCount(`${fiaApiUrl}/jobs/count`, setTotalRows);

Expand Down
3 changes: 2 additions & 1 deletion src/Jobs/JobsGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const JobsGeneral: React.FC = () => {
const [orderBy, setOrderBy] = useState<string>('run_start');
const offset = currentPage * rowsPerPage;
const query = `limit=${rowsPerPage}&offset=${offset}&order_by=${orderBy}&order_direction=${orderDirection}&include_run=true`;
const token = localStorage.getItem('scigateway:token');
const isDev = process.env.REACT_APP_DEV_MODE === 'true';
const token = isDev ? null : localStorage.getItem('scigateway:token');
const fetchJobs = useFetchJobs(`${fiaApiUrl}/instrument/${selectedInstrument}/jobs`, query, setJobs, token);
const fetchTotalCount = useFetchTotalCount(`${fiaApiUrl}/instrument/${selectedInstrument}/jobs/count`, setTotalRows);

Expand Down

0 comments on commit c87656c

Please sign in to comment.