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

IBX-6398: Adjust admin-ui for Image Picker component #956

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
IBX-6398: Adjust admin-ui for Image Picker component
  • Loading branch information
tischsoic committed Nov 17, 2023
commit c1b479aef157d73b8e3996a103f9805d4f0f606f
2 changes: 1 addition & 1 deletion src/bundle/Resources/public/scss/_inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
position: relative;
display: inline-block;
cursor: pointer;
background-color: $ibexa-color-white;

&:disabled {
&.form-check-input {
Expand All @@ -128,7 +129,6 @@
height: calculateRem(16px);
border-radius: calculateRem(2px);
margin-bottom: calculateRem(3px);
background-color: transparent;

&.form-check-input.form-check-input {
float: none;
Expand Down
59 changes: 49 additions & 10 deletions src/bundle/Resources/public/scss/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,70 @@
font-size: $ibexa-text-font-size;
line-height: calculateRem(24px);
border-spacing: 0;
border-collapse: separate;
background-color: $ibexa-color-white;
margin-bottom: 0;

&.table > :not(caption) > * > * {
box-shadow: none;
}

&__row:nth-child(odd) {
.ibexa-table__cell {
background-color: $ibexa-color-light-300;
&__row {
&:nth-child(odd) {
.ibexa-table__cell {
background-color: $ibexa-color-light-300;
}
}
}

&__row:nth-child(even) {
.ibexa-table__cell {
background-color: $ibexa-color-white;
:nth-child(even) {
.ibexa-table__cell {
background-color: $ibexa-color-white;
}
}

&--selected {
.ibexa-table__cell {
font-weight: 600;
}
}

&--selectable {
cursor: pointer;

&:hover {
.ibexa-table__cell {
border-color: $ibexa-color-primary;
}

.ibexa-input--checkbox,
.ibexa-input--radio {
border-color: $ibexa-color-primary;
}
}
}
}

&__cell:first-child {
border-top-left-radius: $ibexa-border-radius;
border-bottom-left-radius: $ibexa-border-radius;
border-left-width: calculateRem(1px);
}

&__cell:last-child {
border-top-right-radius: $ibexa-border-radius;
border-bottom-right-radius: $ibexa-border-radius;
border-right-width: calculateRem(1px);
}

&__cell.ibexa-table__cell {
vertical-align: middle;
padding: calculateRem(12px) calculateRem(16px);
height: calculateRem(68px);
border-style: solid;
border-color: transparent;
border-top-width: calculateRem(1px);
border-bottom-width: calculateRem(1px);
transition: all $ibexa-admin-transition-duration $ibexa-admin-transition;

.form-check {
margin-bottom: 0;
Expand Down Expand Up @@ -128,7 +159,7 @@
display: none;
}

&--asc:after {
&--asc::after {
display: block;
}

Expand Down Expand Up @@ -197,6 +228,16 @@
text-decoration: none;
}

&__thumbnail {
min-width: calculateRem(90px);
max-width: calculateRem(90px);
min-height: calculateRem(64px);
max-height: calculateRem(64px);
border-radius: calculateRem(8px);
overflow: hidden;
object-fit: cover;
}

&--not-striped {
.ibexa-table__row {
.ibexa-table__cell {
Expand All @@ -206,8 +247,6 @@
}

&--last-column-sticky {
border-collapse: separate;

.ibexa-table__row,
.ibexa-table__head-row {
.ibexa-table__cell:last-of-type,
Expand Down
15 changes: 15 additions & 0 deletions src/bundle/ui-dev/src/modules/common/helpers/text.helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const fileSizeToString = (filesize) => {
const units = ['bytes', 'KB', 'MB', 'GB'];
const kilobyte = 1024;
let size = parseInt(filesize, 10) || 0;
let unitIndex = 0;

while (size >= kilobyte) {
size = size / kilobyte;
unitIndex++;
}

const decimalUnits = unitIndex < 1 ? 0 : 1;

return `${size.toFixed(size >= 10 || decimalUnits)} ${units[unitIndex]}`;
};
28 changes: 28 additions & 0 deletions src/bundle/ui-dev/src/modules/common/pagination/pagination.info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';

const { Translator } = window;

const PaginationInfo = ({ totalCount, viewingCount }) => {
if (totalCount === 0) {
return null;
}

const message = Translator.trans(
/*@Desc("Viewing %viewingCount% out of %totalCount% items")*/ 'viewing_message',
{
viewingCount,
totalCount,
},
'ibexa_sub_items',
);

return <div className="m-sub-items__pagination-info ibexa-pagination__info" dangerouslySetInnerHTML={{ __html: message }} />;
};

PaginationInfo.propTypes = {
totalCount: PropTypes.number.isRequired,
viewingCount: PropTypes.number.isRequired,
};

export default PaginationInfo;
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/**
* Returns a filesize as a formatted string
*
* @function fileSizeToString
* @param {Number} filesize
* @returns {String}
*/
export const fileSizeToString = (filesize) => {
const units = ['bytes', 'KB', 'MB', 'GB'];
const kilobyte = 1024;
let size = parseInt(filesize, 10) || 0;
let unitIndex = 0;
import { fileSizeToString as fileSizeToStringFromCommon } from '../../common/helpers/text.helper';

while (size >= kilobyte) {
size = size / kilobyte;
unitIndex++;
}

const decimalUnits = unitIndex < 1 ? 0 : 1;

return `${size.toFixed(size >= 10 || decimalUnits)} ${units[unitIndex]}`;
};
// @deprecated, will be removed in 5.0
export const fileSizeToString = fileSizeToStringFromCommon;
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@ ibexa.addConfig(
true,
);

ibexa.addConfig(
'adminUiConfig.universalDiscoveryWidget.tabs',
[
{
id: 'image_picker',
Copy link
Contributor

Choose a reason for hiding this comment

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

adding the same tab with a different id? could you explain why?
additionally: admin-ui should not have any knowledge about image-picker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it. The backend part for overwriting config will be done in a separate PR.

priority: 10,
component: BrowseTabModule,
label: Translator.trans(/*@Desc("Browse")*/ 'browse.label', {}, 'ibexa_universal_discovery_widget'),
icon: window.ibexa.helpers.icon.getIconPath('browse'),
},
],
true,
);

export default BrowseTabModule;
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,23 @@ export const SearchTextContext = createContext();
export const DropdownPortalRefContext = createContext();

const UniversalDiscoveryModule = (props) => {
const { tabs } = ibexa.adminUiConfig.universalDiscoveryWidget;
const { tabs: tabsWithPriority } = ibexa.adminUiConfig.universalDiscoveryWidget;
const tabs = tabsWithPriority.reduce((tabsPrioritized, tabToAdd) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe put it in memo? Not sure if it's easy as you have to pass array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this approach.

const tabWithSameIdIndex = tabsPrioritized.findIndex((tab) => tab.id === tabToAdd.id);

if (tabWithSameIdIndex === -1) {
tabsPrioritized.push(tabToAdd);
} else {
const currentTabPriority = tabsPrioritized[tabWithSameIdIndex].priority ?? -1;
const tabToAddPriority = tabToAdd.priority ?? -1;

if (currentTabPriority < tabToAddPriority) {
tabsPrioritized[tabWithSameIdIndex] = tabToAdd;
}
}

return tabsPrioritized;
}, []);
const defaultMarkedLocationId = props.startingLocationId || props.rootLocationId;
const abortControllerRef = useRef();
const dropdownPortalRef = useRef();
Expand Down