Skip to content

Commit

Permalink
Merge branch 'master' into tag-edditor
Browse files Browse the repository at this point in the history
  • Loading branch information
ttakenaga committed Jul 9, 2024
2 parents 5b800ad + 85f7b0e commit 6ed7533
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('plugin-job privilege checker', () => {
const resource = 'plugin-jobs/01dxgwv3k0medrvhdag4mpw9wa';
userEmail = '[email protected]';
const res = await ax.get(resource);
console.log(res.data);
// console.log(res.data);
expect(res.data).toBe('Protected Area');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const pluginId =

test('registers a CAD plug-in', async () => {
pluginDefFileContent = {
type: 'CAD',
pluginName: 'my awesome cad',
version: '1.5.0',
description: 'detects everything'
Expand Down
26 changes: 17 additions & 9 deletions packages/circus-ui-kit/src/cs/displays/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ import { useErrorMessage } from './utils/useErrorMessage';
import classnames from 'classnames';
import styled from 'styled-components';

export type GalleryLabelPosition = 'left' | 'right' | 'top' | 'bottom';

export interface GalleryOptions {
/**
* Image file infomation list to display.
*/
imageInfo: {
fileName: string;
maxWidth?: number;
maxHeight?: number;
labelData?: {
customLabel?: string;
dataPath?: string;
}[];
labelPosition?: 'left' | 'right' | 'top' | 'bottom';
labelPosition?: GalleryLabelPosition;
}[];
/**
* Number of images per column. Sum of imageCountsPerColumn must be the length of imageInfo.
Expand Down Expand Up @@ -82,7 +86,7 @@ const getTargetLabels = (
};

export const Gallery: Display<GalleryOptions, void> = props => {
let {
const {
options: { imageInfo = [], imageCountsPerColumn = [] }
} = props;
const { job, loadAttachment } = useCsResults();
Expand Down Expand Up @@ -113,16 +117,16 @@ export const Gallery: Display<GalleryOptions, void> = props => {
}, [job, loadAttachment]);

if (error) return error;
if (imageCountsPerColumn.reduce((a, b) => a + b, 0) !== imageInfo.length) {
imageCountsPerColumn = Array(imageInfo.length).fill(1);
}

const imagesForEachRow =
imageCountsPerColumn.reduce((a, b) => a + b, 0) === imageInfo.length
? imageCountsPerColumn
: Array(imageInfo.length).fill(1);

return (
<>
{imageCountsPerColumn.map((count, i) => {
const startId = imageCountsPerColumn
.slice(0, i)
.reduce((a, b) => a + b, 0);
{imagesForEachRow.map((count, i) => {
const startId = imagesForEachRow.slice(0, i).reduce((a, b) => a + b, 0);
const targetImageInfo = imageInfo.slice(startId, startId + count);

return (
Expand All @@ -136,6 +140,10 @@ export const Gallery: Display<GalleryOptions, void> = props => {
className="image"
ref={imgRefs.current[i + startId]}
alt={`Image ${info.fileName}`}
style={{
maxWidth: info.maxWidth ?? 'initial',
maxHeight: info.maxHeight ?? 'initial'
}}
/>
<div className="labels">
{labels[i + startId]?.map((label, labelInd) => (
Expand Down

0 comments on commit 6ed7533

Please sign in to comment.