Skip to content

Commit

Permalink
ref(js): useLegacyStore for config in App (#29136)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser authored Oct 7, 2021
1 parent 3a186e0 commit 57b27a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 3 additions & 5 deletions static/app/views/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import HookStore from 'app/stores/hookStore';
import OrganizationsStore from 'app/stores/organizationsStore';
import OrganizationStore from 'app/stores/organizationStore';
import {useLegacyStore} from 'app/stores/useLegacyStore';
import {Config} from 'app/types';
import useApi from 'app/utils/useApi';
import withConfig from 'app/utils/withConfig';

import SystemAlerts from './systemAlerts';

Expand All @@ -32,7 +30,6 @@ const GlobalNotifications = HookOrDefault({
});

type Props = {
config: Config;
children: React.ReactNode;
};

Expand All @@ -42,8 +39,9 @@ const NewsletterConsent = lazy(() => import('app/views/newsletterConsent'));
/**
* App is the root level container for all uathenticated routes.
*/
function App({config, children}: Props) {
function App({children}: Props) {
const api = useApi();
const config = useLegacyStore(ConfigStore);
const {organization} = useLegacyStore(OrganizationStore);

// Command palette global-shortcut
Expand Down Expand Up @@ -174,7 +172,7 @@ function App({config, children}: Props) {
);
}

export default withConfig(App);
export default App;

const MainContainer = styled('div')`
display: flex;
Expand Down
17 changes: 9 additions & 8 deletions tests/js/spec/components/modals/sudoModal.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {act} from 'react-dom/test-utils';

import {mountWithTheme} from 'sentry-test/enzyme';

import {Client} from 'app/api';
import ConfigStore from 'app/stores/configStore';
import App from 'app/views/app';

describe('Sudo Modal', function () {
const setHaspasswordAuth = hasPasswordAuth =>
act(() => ConfigStore.set('user', {...ConfigStore.get('user'), hasPasswordAuth}));

beforeEach(function () {
Client.clearMockResponses();
Client.addMockResponse({
Expand Down Expand Up @@ -39,10 +44,8 @@ describe('Sudo Modal', function () {
});

it('can delete an org with sudo flow', async function () {
ConfigStore.set('user', {
...ConfigStore.get('user'),
hasPasswordAuth: true,
});
setHaspasswordAuth(true);

const wrapper = mountWithTheme(
<App>{<div>placeholder content</div>}</App>,
TestStubs.routerContext()
Expand Down Expand Up @@ -126,10 +129,8 @@ describe('Sudo Modal', function () {
});

it('shows button to redirect if user does not have password auth', async function () {
ConfigStore.set('user', {
...ConfigStore.get('user'),
hasPasswordAuth: false,
});
setHaspasswordAuth(false);

const wrapper = mountWithTheme(
<App>{<div>placeholder content</div>}</App>,
TestStubs.routerContext()
Expand Down

0 comments on commit 57b27a7

Please sign in to comment.