Skip to content

Commit

Permalink
update to get defaultIndexName via formState
Browse files Browse the repository at this point in the history
  • Loading branch information
joemcelroy committed Oct 11, 2024
1 parent ac7532f commit ac9efc1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const CreateIndexForm = ({
}: CreateIndexFormProps) => {
const { application } = useKibana().services;
const [indexNameHasError, setIndexNameHasError] = useState<boolean>(false);
const [defaultIndexName] = useState<string>(formState.indexName);
const usageTracker = useUsageTracker();
const { createIndex, isLoading } = useCreateIndex();
const onCreateIndex = useCallback(
Expand All @@ -65,13 +64,13 @@ export const CreateIndexForm = ({
}
usageTracker.click(AnalyticsEvents.startCreateIndexClick);

if (defaultIndexName !== formState.indexName) {
if (formState.defaultIndexName !== formState.indexName) {
usageTracker.click(AnalyticsEvents.startCreateIndexPageModifyIndexName);
}

createIndex({ indexName: formState.indexName });
},
[usageTracker, createIndex, formState.indexName, defaultIndexName]
[usageTracker, createIndex, formState.indexName, formState.defaultIndexName]
);
const onIndexNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newIndexName = e.target.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ import { CreateIndexFormState } from './types';
import { useKibana } from '../../hooks/use_kibana';

function initCreateIndexState(): CreateIndexFormState {
const defaultIndexName = generateRandomIndexName();
return {
indexName: generateRandomIndexName(),
indexName: defaultIndexName,
defaultIndexName,
codingLanguage: getDefaultCodingLanguage(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import type { AvailableLanguages } from '../../code_examples';

export interface CreateIndexFormState {
indexName: string;
defaultIndexName: string;
codingLanguage: AvailableLanguages;
}

0 comments on commit ac9efc1

Please sign in to comment.