Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sams use helper from sourcefabric common #4700

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomaskikutis Where is the code for v0.0.33, I don't see it in https://github.com/superdesk/sourcefabric-common

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad forgot to push it - it's there now

"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
Loading