Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Expose query keys #30

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/subsurface-app-management",
"version": "1.1.7",
"version": "1.1.8",
"description": "React Typescript components/hooks to communicate with equinor/sam",
"types": "dist/index.d.ts",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './queryKeys';
9 changes: 9 additions & 0 deletions src/constants/queryKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const GET_FEATURE_TOGGLES_FOR_APP = 'getFeatureToggleFromAppName';
export const GET_TUTORIALS_FOR_APP = 'getTutorialsForApp';
export const GET_TUTORIALS_SAS_TOKEN = 'getTutorialsSasToken';

export const SAM_QUERIES = [
GET_FEATURE_TOGGLES_FOR_APP,
GET_TUTORIALS_FOR_APP,
GET_TUTORIALS_SAS_TOKEN,
];
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export * from './types';
export * from './utils';

export * from './api';

export * from './constants';
3 changes: 2 additions & 1 deletion src/providers/FeatureToggleProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useQuery } from '@tanstack/react-query';
// These 2 api imports need to be separated to be able to use vi.mock in tests
import { FeatureAPIType, GraphUser } from 'src/api';
import { FeatureToggleService } from 'src/api/services/FeatureToggleService';
import { GET_FEATURE_TOGGLES_FOR_APP } from 'src/constants/queryKeys';
import { EnvironmentType } from 'src/types';
import { environment } from 'src/utils';
import { getEnvironmentName } from 'src/utils/environment';
Expand Down Expand Up @@ -66,7 +67,7 @@ export const FeatureToggleProvider: FC<FeatureToggleProviderProps> = ({
isLoading,
isError,
} = useQuery({
queryKey: ['getFeatureToggleFromAppName'],
queryKey: [GET_FEATURE_TOGGLES_FOR_APP],
queryFn: async () =>
FeatureToggleService.getFeatureToggleFromApplicationName(applicationName),
});
Expand Down
3 changes: 0 additions & 3 deletions src/providers/TutorialProvider/TutorialProvider.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ export const DIALOG_EDGE_MARGIN = 24;
export const TUTORIAL_SEARCH_PARAM_KEY = 'tutorial';
export const TUTORIAL_LOCALSTORAGE_VALUE_STRING = 'hasCompletedTutorial';
export const TUTORIAL_HIGHLIGHTER_DATATEST_ID = 'tutorial-highlighter';

export const GET_TUTORIALS_FOR_APP = 'getTutorialsForApp';
export const GET_TUTORIALS_SAS_TOKEN = 'getTutorialsSasToken';
4 changes: 2 additions & 2 deletions src/providers/TutorialProvider/TutorialProvider.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useContext } from 'react';

import { useQuery } from '@tanstack/react-query';

import { TutorialService } from 'src/api/services/TutorialService';
import {
GET_TUTORIALS_FOR_APP,
GET_TUTORIALS_SAS_TOKEN,
} from './TutorialProvider.const';
import { TutorialService } from 'src/api/services/TutorialService';
} from 'src/constants/queryKeys';
import { TutorialContext } from 'src/providers/TutorialProvider/TutorialProvider';

export const useGetTutorialsForApp = (appName: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/providers/TutorialProvider/TutorialProvider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { CustomTutorialComponent } from './TutorialProvider.types';
import { Tutorial } from 'src/api';
import { TutorialProvider } from 'src/providers';
import {
GET_TUTORIALS_FOR_APP,
GET_TUTORIALS_SAS_TOKEN,
} from 'src/providers/TutorialProvider/TutorialProvider.const';
} from 'src/constants/queryKeys';
import { TutorialProvider } from 'src/providers';

import styled, { keyframes } from 'styled-components';

Expand Down
6 changes: 4 additions & 2 deletions src/providers/TutorialProvider/TutorialProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { waitFor } from '@testing-library/react';
import { render, renderHook, screen, userEvent } from '../../tests/test-utils';
import {
DIALOG_EDGE_MARGIN,
GET_TUTORIALS_FOR_APP,
GET_TUTORIALS_SAS_TOKEN,
TUTORIAL_HIGHLIGHTER_DATATEST_ID,
TUTORIAL_LOCALSTORAGE_VALUE_STRING,
} from './TutorialProvider.const';
import { CancelablePromise, Step, Tutorial, TutorialPosition } from 'src/api';
import {
GET_TUTORIALS_FOR_APP,
GET_TUTORIALS_SAS_TOKEN,
} from 'src/constants/queryKeys';
import { TutorialProvider } from 'src/providers';
import { useTutorial } from 'src/providers/TutorialProvider/TutorialProvider.hooks';
import { EnvironmentType } from 'src/types';
Expand Down