Skip to content

Commit

Permalink
Update empty pages and add permission checks for the create button
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed Aug 26, 2024
1 parent ad35330 commit 42f792d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function useMapContentTypeToDisplayName() {
decisionenvironment: options?.isTitleCase
? t('Decision Environment')
: t('decision environment'),
eventstream: options?.isTitleCase ? t('Event Stream') : t('event stream'),
auditrule: options?.isTitleCase ? t('Rule Audit') : t('rule audit'),
team: options?.isTitleCase ? t('Team') : t('team'),
organization: options?.isTitleCase ? t('Organization') : t('organization'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function EventStreamUserAccess() {
<UserAccess
service="eda"
id={params.id || ''}
type={'project'}
type={'eventstream'}
addRolesRoute={EdaRoute.EventStreamAddUsers}
/>
);
Expand Down
27 changes: 22 additions & 5 deletions frontend/eda/event-streams/EventStreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { useEventStreamActions } from './hooks/useEventStreamActions';
import { useEventStreamColumns } from './hooks/useEventStreamColumns';
import { useEventStreamFilters } from './hooks/useEventStreamFilters';
import { useEventStreamsActions } from './hooks/useEventStreamsActions';
import { PlusCircleIcon } from '@patternfly/react-icons';
import { CubesIcon, PlusCircleIcon } from '@patternfly/react-icons';
import { useOptions } from '../../common/crud/useOptions';
import { ActionsResponse, OptionsResponse } from '../interfaces/OptionsResponse';

export function EventStreams() {
const { t } = useTranslation();
Expand All @@ -21,6 +23,8 @@ export function EventStreams() {
tableColumns,
});
const toolbarActions = useEventStreamsActions(view);
const { data } = useOptions<OptionsResponse<ActionsResponse>>(edaAPI`/event-streams/`);
const canCreateEventStream = Boolean(data && data.actions && data.actions['POST']);
const rowActions = useEventStreamActions(view);
return (
<PageLayout>
Expand All @@ -38,11 +42,24 @@ export function EventStreams() {
toolbarFilters={toolbarFilters}
rowActions={rowActions}
errorStateTitle={t('Error loading event streams')}
emptyStateTitle={t('There are currently no event streams created for your organization.')}
emptyStateDescription={t('Please create an event stream by using the button below.')}
emptyStateTitle={
canCreateEventStream
? t('There are currently no event streams created for your organization.')
: t('You do not have permission to create an event stream.')
}
emptyStateDescription={
canCreateEventStream
? t('Please create an event stream by using the button below.')
: t(
'Please contact your organization administrator if there is an issue with your access.'
)
}
emptyStateIcon={canCreateEventStream ? undefined : CubesIcon}
emptyStateButtonIcon={<PlusCircleIcon />}
emptyStateButtonText={t('Create event stream')}
emptyStateButtonClick={() => pageNavigate(EdaRoute.CreateEventStream)}
emptyStateButtonText={canCreateEventStream ? t('Create event stream') : undefined}
emptyStateButtonClick={
canCreateEventStream ? () => pageNavigate(EdaRoute.CreateEventStream) : undefined
}
{...view}
defaultSubtitle={t('Event stream')}
/>
Expand Down

0 comments on commit 42f792d

Please sign in to comment.