Skip to content

Commit

Permalink
sams use helper from sourcefabric common (#4700)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis authored Dec 12, 2024
1 parent 6b334d2 commit 89997bd
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 29 deletions.
28 changes: 17 additions & 11 deletions scripts/extensions/sams/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/extensions/sams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"watch": "tsc -watch -p src"
},
"dependencies": {
"@superdesk/common": "^0.0.13",
"@sourcefabric/common": "0.0.33",
"reselect": "~4.0.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as React from 'react';
import {connect} from 'react-redux';
import {noop, cloneDeep} from 'lodash';
import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {ASSET_STATE, IAssetItem, ISetItem, IAssetTag, IAutoTaggingSearchResult} from '../../interfaces';
Expand All @@ -16,7 +17,6 @@ import {FormLabel, Input, Option, Select, Autocomplete, Tag, Label} from 'superd
import {FormGroup, FormRow} from '../../ui';

// Utils
import {getHumanReadableFileSize} from '../../utils/ui';
import {convertTagSearchResultToAssetTags} from '../../utils/assets';

interface IProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// External modules
import * as React from 'react';

import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {IAssetItem, IAssetCallback} from '../../interfaces';
import {superdeskApi} from '../../apis';
Expand All @@ -17,7 +19,6 @@ import {getThumbnailComponent} from './list';

// Utils
import {
getHumanReadableFileSize,
getIconTypeFromMimetype,
getAssetStateLabel,
} from '../../utils/ui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// External Modules
import * as React from 'react';
import {connect} from 'react-redux';
import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {IAssetItem, ISetItem, RENDITION} from '../../interfaces';
Expand Down Expand Up @@ -33,7 +34,6 @@ import {PageLayout} from '../../containers/PageLayout';
import {
getAssetStateLabel,
getIconTypeFromMimetype,
getHumanReadableFileSize,
showModalConnectedToStore,
getAssetRenditionDimension,
} from '../../utils/ui';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// External Modules
import * as React from 'react';

import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {IAssetItem, IAssetCallback} from '../../interfaces';
import {superdeskApi} from '../../apis';
Expand All @@ -15,7 +17,7 @@ import {
} from '../../ui/list';

// Utils
import {getIconTypeFromMimetype, getAssetStateLabel, getHumanReadableFileSize} from '../../utils/ui';
import {getIconTypeFromMimetype, getAssetStateLabel} from '../../utils/ui';
import {getDropdownItemsForActions, getMimetypeHumanReadable, isAssetLocked} from '../../utils/assets';

interface IProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as React from 'react';
import {Dispatch} from 'redux';
import {connect} from 'react-redux';
import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {ASSET_ACTIONS, IAssetCallback, IAssetItem, LIST_ACTION} from '../../interfaces';
Expand Down Expand Up @@ -33,7 +34,6 @@ import {getPreviewComponent} from './preview';
import {showImagePreviewModal} from './assetImagePreviewFullScreen';

// Utils
import {getHumanReadableFileSize} from '../../utils/ui';
import {getDropdownItemsForActions, getMimetypeHumanReadable} from '../../utils/assets';

interface IProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as React from 'react';
import {connect} from 'react-redux';
import {Dispatch} from 'redux';

import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {IAttachment} from 'superdesk-api';
import {superdeskApi} from '../../apis';
Expand All @@ -23,7 +25,7 @@ import {
} from '../../ui/list';

// Utils
import {getIconTypeFromMimetype, getHumanReadableFileSize} from '../../utils/ui';
import {getIconTypeFromMimetype} from '../../utils/ui';

interface IProps {
files: Array<IAttachment>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as React from 'react';
import {connect} from 'react-redux';
import {Dispatch} from 'redux';

import {getHumanReadableFileSize} from '@sourcefabric/common';

// Types
import {IDesk} from 'superdesk-api';
import {ISetItem, IStorageDestinationItem, SET_STATE} from '../../interfaces';
Expand All @@ -26,7 +28,6 @@ import {
Text,
} from '../../ui';
import {IPanelTools} from '../../ui/PanelTools';
import {getHumanReadableFileSize} from '../../utils/ui';
import {VersionUserDateLines} from '../common/versionUserDateLines';

interface IProps {
Expand Down
10 changes: 0 additions & 10 deletions scripts/extensions/sams/src/utils/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ export function showModalConnectedToStore<T = any>(
);
}

export function getHumanReadableFileSize(fileSize: number): string {
if (fileSize < 1024) {
return fileSize + 'bytes';
} else if (fileSize < 1048576) {
return (fileSize / 1024).toFixed(1) + 'KB';
} else {
return (fileSize / 1048576).toFixed(1) + 'MB';
}
}

export function getIconTypeFromMimetype(mimetype: string) {
if (mimetype.startsWith('image/')) {
return 'photo';
Expand Down

0 comments on commit 89997bd

Please sign in to comment.