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

Add support for itless base layout dashboard type #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@patternfly/react-core": "^5.3.3",
"@redhat-cloud-services/frontend-components": "^4.2.11",
"@redhat-cloud-services/frontend-components-notifications": "^4.1.0",
"@unleash/proxy-client-react": "^3.6.0",
"awesome-debounce-promise": "^2.1.0",
"classnames": "^2.5.1",
"jotai": "^2.8.4",
Expand Down
9 changes: 8 additions & 1 deletion src/Components/DnDLayout/GridLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { drawerExpandedAtom } from '../../state/drawerExpandedAtom';
import { columns, dropping_elem_id } from '../../consts';
import { useAddNotification } from '../../state/notificationsAtom';
import { currentlyUsedWidgetsAtom } from '../../state/currentlyUsedWidgetsAtom';
import { useFlag } from '@unleash/proxy-client-react';

export const breakpoints: {
[key in Variants]: number;
Expand Down Expand Up @@ -100,6 +101,12 @@ const GridLayout = ({ isLayoutLocked = false, layoutType = 'landingPage' }: { is
const addNotification = useAddNotification();
const setCurrentlyUsedWidgets = useSetAtom(currentlyUsedWidgetsAtom);
const { analytics } = useChrome();
const isITLess = useFlag('platform.widget-layout.itless');
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm
I wonder if we could pass this string as a prop from the fed-modules config as we are doing for learning resources.

Its much cleaner and we do not need a feature flag on frontend all.

Choose a reason for hiding this comment

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

That sounds great to me. I'd rather avoid having to use featureFlags if I can avoid it. It makes sense to load this from the frontend deploy file

let targetLayout = layoutType;

if (layoutType === 'landingPage' && isITLess) {
targetLayout = 'landingPageItless';
}

const [currentDropInItem, setCurrentDropInItem] = useAtom(currentDropInItemAtom);
const droppingItemTemplate: ReactGridLayoutProps['droppingItem'] = useMemo(() => {
Expand Down Expand Up @@ -207,7 +214,7 @@ const GridLayout = ({ isLayoutLocked = false, layoutType = 'landingPage' }: { is
return;
}
// TODO template type should be pulled from app config for reusability
getDashboardTemplates(layoutType)
getDashboardTemplates(targetLayout)
.then((templates) => {
const customDefaultTemplate = getDefaultTemplate(templates);
if (!customDefaultTemplate) {
Expand Down
2 changes: 1 addition & 1 deletion src/api/dashboard-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getRequestHeaders = () => ({

export const widgetIdSeparator = '#';

export type LayoutTypes = 'landingPage';
export type LayoutTypes = 'landingPage' | 'landingPageItless';

export type Variants = 'sm' | 'md' | 'lg' | 'xl';

Expand Down