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

Fikset feil med prosjektutlistings-webdelen hvor gjester kunne se fanen "Alle prosjekter" #1003

Merged
merged 2 commits into from
Feb 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ export const ProjectListViews: IProjectListView[] = [
itemIcon: 'AllApps',
searchBoxPlaceholder: strings.AllProjectsSearchBoxPlaceholderText,
filter: () => true,
getHeaderButtonProps: (state) =>
!state.isUserInPortfolioManagerGroup && {
disabled: true,
style: { opacity: 0.3, cursor: 'default' }
}
isHidden: (state) => !state.isUserInPortfolioManagerGroup
},
{
itemKey: 'parent_projects',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,39 @@ import { ProjectListModel } from 'models'
import { IBaseComponentProps } from '../types'

export interface IProjectListView extends IPivotItemProps {
/**
* Placeholder text for search box.
*/
searchBoxPlaceholder?: string

/**
* Filter function for projects. If not provided, all projects are shown.
*
* @param project Project list model
*/
filter?: (project?: ProjectListModel) => boolean

/**
* Function to get header button props. If not provided, the default button props are used.
*
* @param state State of the component
*/
getHeaderButtonProps?: (
state: IProjectListState
) =>
| IButtonProps
| {
[key: string]: string | number | boolean
}
[key: string]: string | number | boolean
}

/**
* Function to determine if the view should be hidden. If not provided, the view is not hidden.
*
* @param state State of the component
*/
isHidden?: (
state: IProjectListState
) => boolean
}

export type ProjectListRenderMode = 'tiles' | 'list'
Expand All @@ -34,17 +58,17 @@ export interface IProjectListProps extends IBaseComponentProps {
showViewSelector?: boolean

/**
* Show Project Logo
* Show Project Logo on the project card
*/
showProjectLogo?: boolean

/**
* Show Project Owner
* Show Project Owner on the project card
*/
showProjectOwner?: boolean

/**
* Show Project Manager
* Show Project Manager on the project card
*/
showProjectManager?: boolean

Expand All @@ -59,12 +83,12 @@ export interface IProjectListProps extends IBaseComponentProps {
defaultView?: string

/**
* Hide views
* Array of views to hide
*/
hideViews?: string[]

/**
* Views
* Views to show using Pivot component
*/
views?: IProjectListView[]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useProjectListDataFetch } from './useProjectListDataFetch'
import { useProjectListState } from './useProjectListState'

/**
* Component logic hook for `ProjectList`.
* Component logic hook for `ProjectList`. This hook is responsible for
* fetching data, sorting, filtering and other logic.
*
* @param props Props
*/
Expand Down Expand Up @@ -100,7 +101,7 @@ export const useProjectList = (props: IProjectListProps) => {
}

const projects = state.isDataLoaded ? filterProjets(state.projects) : state.projects
const views = props.views.filter((view) => !props.hideViews.includes(view.itemKey))
const views = props.views.filter((view) => !props.hideViews.includes(view.itemKey) && (!view.isHidden || !view?.isHidden(state)))

useProjectListDataFetch(props, views, setState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import _ from 'underscore'
import { IProjectListProps, IProjectListState, IProjectListView } from './types'

/**
* Component data fetch hook for `ProjectList`.
* Component data fetch hook for `ProjectList`. This hook is responsible for
* fetching data and setting state.
*
* @param props Props
* @param views Views
Expand Down