Skip to content

Commit

Permalink
Cleanup not used files (#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
moczolaszlo authored Nov 15, 2024
1 parent acfdf96 commit f80ed92
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { AppConfig } from '@/models/AppConfig';
import DateFormatter from '@/utils/dateFormatter';
import { segmentTrack } from '@/utils/segmentTracking';
import BitriseYmlApi from '@/core/api/BitriseYmlApi';
import { useFormattedYml } from '../common/RepoYmlStorageActions';
import useFormattedYml from '@/hooks/useFormattedYml';

const ErrorNotification = ({ status, message }: { status?: number; message: string }) => {
let action: NotificationProps['action'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Box, Button, Dialog, DialogBody, DialogFooter, Notification, Text, useT
import CopyToClipboard from 'react-copy-to-clipboard';
import { AppConfig } from '@/models/AppConfig';
import { segmentTrack } from '@/utils/segmentTracking';
import useFormattedYml from '@/hooks/useFormattedYml';
import useGetAppConfigFromRepoCallback from '../../hooks/api/useGetAppConfigFromRepoCallback';
import YmlNotFoundInRepositoryError from '../common/notifications/YmlNotFoundInRepositoryError';
import YmlInRepositoryInvalidError from '../common/notifications/YmlInRepositoryInvalidError';
import { useFormattedYml } from '../common/RepoYmlStorageActions';

type UpdateConfigurationDialogProps = {
onClose: () => void;
Expand Down
23 changes: 0 additions & 23 deletions source/javascripts/components/common/InlineLink.tsx

This file was deleted.

109 changes: 0 additions & 109 deletions source/javascripts/components/common/RepoYmlStorageActions.tsx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions source/javascripts/hooks/api/useGetAppConfigCallback.ts

This file was deleted.

52 changes: 52 additions & 0 deletions source/javascripts/hooks/useFormattedYml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useEffect, useRef, useState } from 'react';

import { AppConfig } from '@/models/AppConfig';
import BitriseYmlApi from '@/core/api/BitriseYmlApi';
import useMonolithApiCallback from '@/hooks/api/useMonolithApiCallback';

const identityParser = (result: string): any => result;

const useFormattedYml = (appConfig: AppConfig): string => {
const [yml, setYml] = useState(typeof appConfig === 'string' ? appConfig : '');
const formatAppConfigRef = useRef<(options?: RequestInit) => void>();
const { failed, result, call } = useMonolithApiCallback<string>(
'/api/cli/format',
{
method: 'POST',
headers: {
Accept: 'application/x-yaml, application/json',
},
},
identityParser,
);

// NOTE: call function isn't referentially stable
useEffect(() => {
formatAppConfigRef.current = call;
});

// Set the js-yaml value as fallback, kick off format endpoint
useEffect(() => {
const yaml = BitriseYmlApi.toYml(appConfig);
setYml(yaml);

if (typeof appConfig === 'object') {
formatAppConfigRef.current?.({
body: JSON.stringify({
app_config_datastore_yaml: yaml,
}),
});
}
}, [appConfig]);

// When result finally comes in override the fallback value
useEffect(() => {
if (result && !failed) {
setYml(result);
}
}, [result, failed]);

return yml;
};

export default useFormattedYml;
29 changes: 0 additions & 29 deletions source/javascripts/utils/changeCase.ts

This file was deleted.

0 comments on commit f80ed92

Please sign in to comment.