Skip to content

Commit

Permalink
Merge pull request #14 from equinor/fix/remove-acl-dependency
Browse files Browse the repository at this point in the history
fix/remove-acl-dependency
  • Loading branch information
mariush2 authored Jul 16, 2024
2 parents 40a26ac + 34b892a commit 8486818
Show file tree
Hide file tree
Showing 36 changed files with 5,548 additions and 8,766 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = {
},
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
excludedFiles: ['*.test.*', '*.stories.*', './src/providers/AuthProvider/**', './src/utils/auth_environment.ts'],
excludedFiles: ['*.test.*', '*.stories.*', './src/utils/environment.ts'],
rules: {
'no-console': ['warn', { allow: ['warn', 'error'] }],
}
Expand Down
12,843 changes: 5,158 additions & 7,685 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/subsurface-app-management",
"version": "1.0.6",
"version": "1.0.7",
"description": "React Typescript components/hooks to communicate with equinor/sam",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -51,7 +51,6 @@
"jwt-decode": "^4.0.0"
},
"devDependencies": {
"@equinor/amplify-components": "^7.10.5",
"@equinor/eds-icons": "^0.21.0",
"@faker-js/faker": "^8.4.1",
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down Expand Up @@ -114,7 +113,6 @@
"vitest": "^1.2.2"
},
"peerDependencies": {
"@equinor/amplify-components": "*",
"@equinor/eds-core-react": "*",
"@equinor/eds-icons": "*",
"@tanstack/react-query": "*",
Expand Down
14 changes: 7 additions & 7 deletions src/api/core/OpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
/* tslint:disable */
/* eslint-disable */
import type { ApiRequestOptions } from './ApiRequestOptions';
import { auth, environment } from 'src/utils';
import { environment } from 'src/utils';
import { CancelablePromise } from 'src/api';
import { request as __request } from 'src/api/core/request';
import { getLocalStorage, updateLocalStorage } from 'src/utils/localStorage';
import { JwtPayload, jwtDecode } from 'jwt-decode';

const { getToken: getApplicationToken } = auth;
const { getApiUrl, getEnvironmentName } = environment;
const { getEnvironmentName, getApiUrl } = environment;

type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Headers = Record<string, string>;
Expand Down Expand Up @@ -38,7 +37,7 @@ export class TokenService {
* @throws ApiError
*/
public static getAmplifyPortalToken(): CancelablePromise<string> {
return __request(OpenAPI, {
return __request(OpenAPI_SAM, {
method: 'GET',
url: '/api/v1/Token/AmplifyPortal',
});
Expand All @@ -49,7 +48,7 @@ export class TokenService {
* @throws ApiError
*/
public static getAmplifyPortalProductionToken(): CancelablePromise<string> {
return __request(OpenAPI, {
return __request(OpenAPI_SAM, {
method: 'GET',
url: '/api/v1/Token/AmplifyPortal/Production',
});
Expand Down Expand Up @@ -98,12 +97,12 @@ const getPortalProdToken = async () => {
);
};

export const OpenAPI: OpenAPIConfig = {
export const OpenAPI_SAM: OpenAPIConfig = {
BASE: getApiUrl(import.meta.env.VITE_API_URL),
VERSION: '1.0',
WITH_CREDENTIALS: false,
CREDENTIALS: 'include',
TOKEN: getApplicationToken,
TOKEN: undefined,
USERNAME: undefined,
PASSWORD: undefined,
HEADERS: undefined,
Expand All @@ -121,6 +120,7 @@ export const OpenAPI_Portal: OpenAPIConfig = {
HEADERS: undefined,
ENCODE_PATH: undefined,
};

export const OpenAPI_Portal_Prod: OpenAPIConfig = {
BASE: `https://api-amplify-portal-production.radix.equinor.com`,
VERSION: '1.0',
Expand Down
4 changes: 2 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* eslint-disable */
export { ApiError } from './core/ApiError';
export { CancelablePromise, CancelError } from './core/CancelablePromise';
export { OpenAPI, getPortalToken } from './core/OpenAPI';
export { OpenAPI_SAM, getPortalToken } from 'src/api/core/OpenAPI';
export { request } from './core/request';
export type { OpenAPIConfig } from './core/OpenAPI';
export type { OpenAPIConfig } from 'src/api/core/OpenAPI';

export type { CustomTutorialStep } from './models/CustomTutorialStep';
export type { AccessRoles } from './models/AccessRole';
Expand Down
8 changes: 4 additions & 4 deletions src/components/Feature/Feature.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { waitFor } from '@testing-library/react';

import { CancelablePromise } from 'src/api';
import { Feature } from 'src/components/Feature/Feature';
import { AuthProvider, FeatureToggleProvider } from 'src/providers';
import { FeatureToggleProvider } from 'src/providers';
import { render, screen } from 'src/tests/test-utils';

import { beforeEach, describe } from 'vitest';
Expand Down Expand Up @@ -51,9 +51,9 @@ function Wrappers({ children }: { children: ReactNode }) {
const queryClient = new QueryClient();
return (
<QueryClientProvider client={queryClient}>
<AuthProvider>
<FeatureToggleProvider>{children}</FeatureToggleProvider>
</AuthProvider>
<FeatureToggleProvider loadingComponent={<p>loading</p>}>
{children}
</FeatureToggleProvider>
</QueryClientProvider>
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/Feature/Feature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ interface FeatureProps {
featureKey: string;
children: ReactNode;
fallback?: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
showIfKeyMissing?: boolean;
showIfKeyIsMissing?: boolean;
}

export const Feature: FC<FeatureProps> = ({
featureKey,
children,
fallback,
showIfKeyMissing = true,
showIfKeyIsMissing = true,
}) => {
const { showContent } = useFeatureToggling(featureKey, showIfKeyMissing);
const { showContent } = useFeatureToggling({
featureKey,
showIfKeyIsMissing,
});

if (showContent) {
return <>{children}</>;
Expand Down
16 changes: 3 additions & 13 deletions src/hooks/hooks.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@ import { Meta, StoryFn } from '@storybook/react';
import styled from 'styled-components';

const hookList = [
{
name: 'useSignalRMessages',
body: 'Returns service bus messages with wss given a topic + host + token',
code: `const {
messages,
hasUnreadMessages,
setMessageAsRead,
setAllMessagesAsRead,
deleteMessage } = useSignalRMessages<MessageDto>('recap_notifications', 'url', 'token')`,
},
{
name: 'useFeatureToggling',
body: 'Returns if a given key should be feature toggled on/off',
code: 'const { showContent, isLoading } = useFeatureToggling("analytics")',
},
{
name: 'useAuth',
body: 'Returns auth object from AuthProvider',
code: 'const { account } = useAuth()',
name: 'useReleaseNotesQuery',
body: 'Returns release notes for a given app. Has optional options to override app name and enabled (react-query)',
code: 'const { data } = useReleaseNotesQuery()',
},
];

Expand Down
11 changes: 1 addition & 10 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import { useAuth } from '../providers/AuthProvider/AuthProvider';
import { useReleaseNotes } from '../providers/ReleaseNotesProvider';
import { useTutorialSteps } from '../providers/TutorialStepsProvider';
import { useFeatureToggling } from './useFeatureToggling';
import { useReleaseNotesQuery } from './useReleaseNotesQuery';

export {
useAuth,
useFeatureToggling,
useReleaseNotesQuery,
useTutorialSteps,
useReleaseNotes,
};
export { useFeatureToggling, useReleaseNotesQuery };
Loading

0 comments on commit 8486818

Please sign in to comment.