Skip to content

Commit

Permalink
added more mime types for yaml file (#909)
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan committed Mar 12, 2024
1 parent d3aefba commit 3812afd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public/pages/Rules/containers/ImportRule/ImportRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { NotificationsStart } from 'opensearch-dashboards/public';
import { CoreServicesContext } from '../../../../components/core_services';
import { setBreadCrumb, validateRule } from '../../utils/helpers';
import { DataStore } from '../../../../store/DataStore';
import { yamlMediaTypes } from '../../utils/constants';

export interface ImportRuleProps {
services: BrowserServices;
Expand All @@ -29,7 +30,7 @@ export const ImportRule: React.FC<ImportRuleProps> = ({ history, services, notif
const onChange = useCallback((files: any) => {
setFileError('');

if (files[0]?.type === 'application/x-yaml') {
if (yamlMediaTypes.has(files[0]?.type)) {
let reader = new FileReader();
reader.readAsText(files[0]);
reader.onload = function () {
Expand Down
2 changes: 2 additions & 0 deletions public/pages/Rules/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ export const ruleSeverity: {
export const ruleSource: string[] = ['Standard', 'Custom'];

export const ruleStatus: string[] = ['experimental', 'test', 'stable'];

export const yamlMediaTypes = new Set(['application/x-yaml', 'text/yaml', 'text/x-yaml']);

0 comments on commit 3812afd

Please sign in to comment.