-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ConfigProvider in mappings editor to provide docLinks to runtime …
…field editor
- Loading branch information
Showing
10 changed files
with
83 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...plugins/index_management/public/application/components/mappings_editor/config_context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { createContext, useContext, useState } from 'react'; | ||
|
||
import { DocLinksStart } from './shared_imports'; | ||
import { IndexSettings } from './types'; | ||
|
||
interface ContextState { | ||
indexSettings: IndexSettings; | ||
docLinks?: DocLinksStart; | ||
} | ||
|
||
interface Context { | ||
value: ContextState; | ||
update: (value: ContextState) => void; | ||
} | ||
|
||
const ConfigContext = createContext<Context | undefined>(undefined); | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const ConfigProvider = ({ children }: Props) => { | ||
const [state, setState] = useState<ContextState>({ | ||
indexSettings: {}, | ||
}); | ||
|
||
return ( | ||
<ConfigContext.Provider value={{ value: state, update: setState }}> | ||
{children} | ||
</ConfigContext.Provider> | ||
); | ||
}; | ||
|
||
export const useConfig = () => { | ||
const ctx = useContext(ConfigContext); | ||
if (ctx === undefined) { | ||
throw new Error('useConfig must be used within a <ConfigProvider />'); | ||
} | ||
return ctx; | ||
}; |
34 changes: 0 additions & 34 deletions
34
...index_management/public/application/components/mappings_editor/index_settings_context.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters