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

Actions menu in Subspace List * #6885

Merged
merged 14 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
20 changes: 0 additions & 20 deletions .github/workflows/build-deploy-k8s-dev-hetzner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@ jobs:
- name: 'Checkout github Action'
uses: actions/checkout@v4.1.7

- name: 'Download and extract translations'
uses: crowdin/github-action@v1.13.1
with:
command: 'download'
command_args: '--all --verbose'
source: ./src/core/i18n/en/translation.en.json
translation: ./src/core/i18n/%two_letters_code%/translation.%two_letters_code%.json

download_translations: false
upload_sources: false
upload_translations: false
push_translations: false
push_sources: false

project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

- name: 'Build and push image'
uses: azure/docker-login@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
files:
- source: /src/core/i18n/en/translation.en.json
- source: /src/core/i18n/en/translation.en.json # This is your local repository structure
translation: /src/core/i18n/%two_letters_code%/translation.%two_letters_code%.json
export_pattern: '/src/core/i18n/%two_letters_code%/translation.%two_letters_code%.json'
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
api_token_env: CROWDIN_PERSONAL_TOKEN
52 changes: 28 additions & 24 deletions src/core/apollo/generated/apollo-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18305,8 +18305,8 @@ export function refetchSpaceAccountQuery(variables: SchemaTypes.SpaceAccountQuer
return { query: SpaceAccountDocument, variables: variables };
}

export const AdminSpaceChallengesPageDocument = gql`
query AdminSpaceChallengesPage($spaceId: UUID_NAMEID!) {
export const AdminSpaceSubspacesPageDocument = gql`
query AdminSpaceSubspacesPage($spaceId: UUID_NAMEID!) {
space(ID: $spaceId) {
id
subspaces {
Expand All @@ -18315,6 +18315,9 @@ export const AdminSpaceChallengesPageDocument = gql`
id
displayName
url
cardBanner: visual(type: CARD) {
...VisualUri
}
}
}
defaults {
Expand All @@ -18332,59 +18335,60 @@ export const AdminSpaceChallengesPageDocument = gql`
}
}
}
${VisualUriFragmentDoc}
${InnovationFlowProfileFragmentDoc}
`;

/**
* __useAdminSpaceChallengesPageQuery__
* __useAdminSpaceSubspacesPageQuery__
*
* To run a query within a React component, call `useAdminSpaceChallengesPageQuery` and pass it any options that fit your needs.
* When your component renders, `useAdminSpaceChallengesPageQuery` returns an object from Apollo Client that contains loading, error, and data properties
* To run a query within a React component, call `useAdminSpaceSubspacesPageQuery` and pass it any options that fit your needs.
* When your component renders, `useAdminSpaceSubspacesPageQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAdminSpaceChallengesPageQuery({
* const { data, loading, error } = useAdminSpaceSubspacesPageQuery({
* variables: {
* spaceId: // value for 'spaceId'
* },
* });
*/
export function useAdminSpaceChallengesPageQuery(
export function useAdminSpaceSubspacesPageQuery(
baseOptions: Apollo.QueryHookOptions<
SchemaTypes.AdminSpaceChallengesPageQuery,
SchemaTypes.AdminSpaceChallengesPageQueryVariables
SchemaTypes.AdminSpaceSubspacesPageQuery,
SchemaTypes.AdminSpaceSubspacesPageQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<SchemaTypes.AdminSpaceChallengesPageQuery, SchemaTypes.AdminSpaceChallengesPageQueryVariables>(
AdminSpaceChallengesPageDocument,
return Apollo.useQuery<SchemaTypes.AdminSpaceSubspacesPageQuery, SchemaTypes.AdminSpaceSubspacesPageQueryVariables>(
AdminSpaceSubspacesPageDocument,
options
);
}

export function useAdminSpaceChallengesPageLazyQuery(
export function useAdminSpaceSubspacesPageLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
SchemaTypes.AdminSpaceChallengesPageQuery,
SchemaTypes.AdminSpaceChallengesPageQueryVariables
SchemaTypes.AdminSpaceSubspacesPageQuery,
SchemaTypes.AdminSpaceSubspacesPageQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<
SchemaTypes.AdminSpaceChallengesPageQuery,
SchemaTypes.AdminSpaceChallengesPageQueryVariables
>(AdminSpaceChallengesPageDocument, options);
SchemaTypes.AdminSpaceSubspacesPageQuery,
SchemaTypes.AdminSpaceSubspacesPageQueryVariables
>(AdminSpaceSubspacesPageDocument, options);
}

export type AdminSpaceChallengesPageQueryHookResult = ReturnType<typeof useAdminSpaceChallengesPageQuery>;
export type AdminSpaceChallengesPageLazyQueryHookResult = ReturnType<typeof useAdminSpaceChallengesPageLazyQuery>;
export type AdminSpaceChallengesPageQueryResult = Apollo.QueryResult<
SchemaTypes.AdminSpaceChallengesPageQuery,
SchemaTypes.AdminSpaceChallengesPageQueryVariables
export type AdminSpaceSubspacesPageQueryHookResult = ReturnType<typeof useAdminSpaceSubspacesPageQuery>;
export type AdminSpaceSubspacesPageLazyQueryHookResult = ReturnType<typeof useAdminSpaceSubspacesPageLazyQuery>;
export type AdminSpaceSubspacesPageQueryResult = Apollo.QueryResult<
SchemaTypes.AdminSpaceSubspacesPageQuery,
SchemaTypes.AdminSpaceSubspacesPageQueryVariables
>;
export function refetchAdminSpaceChallengesPageQuery(variables: SchemaTypes.AdminSpaceChallengesPageQueryVariables) {
return { query: AdminSpaceChallengesPageDocument, variables: variables };
export function refetchAdminSpaceSubspacesPageQuery(variables: SchemaTypes.AdminSpaceSubspacesPageQueryVariables) {
return { query: AdminSpaceSubspacesPageDocument, variables: variables };
}

export const UpdateSpaceDefaultInnovationFlowTemplateDocument = gql`
Expand Down
12 changes: 9 additions & 3 deletions src/core/apollo/generated/graphql-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23362,19 +23362,25 @@ export type SpaceAccountQuery = {
};
};

export type AdminSpaceChallengesPageQueryVariables = Exact<{
export type AdminSpaceSubspacesPageQueryVariables = Exact<{
spaceId: Scalars['UUID_NAMEID'];
}>;

export type AdminSpaceChallengesPageQuery = {
export type AdminSpaceSubspacesPageQuery = {
__typename?: 'Query';
space: {
__typename?: 'Space';
id: string;
subspaces: Array<{
__typename?: 'Space';
id: string;
profile: { __typename?: 'Profile'; id: string; displayName: string; url: string };
profile: {
__typename?: 'Profile';
id: string;
displayName: string;
url: string;
cardBanner?: { __typename?: 'Visual'; id: string; uri: string; name: string } | undefined;
};
}>;
defaults?:
| {
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AvatarProps, Box } from '@mui/material';
import ErrorHandlingAvatar from './ErrorHandlingAvatar';
import { gutters } from '../grid/utils';

type Size = 'small' | 'medium' | 'regular' | 'large';
export type Size = 'small' | 'medium' | 'regular' | 'large';

const AvatarSize: Record<Size, number> = {
small: 1.5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
NotesOutlined,
PersonOutlined,
} from '@mui/icons-material';
import { ChallengeIcon } from '../../../../journey/subspace/icon/ChallengeIcon';
import { SubspaceIcon } from '../../../../journey/subspace/icon/SubspaceIcon';
import { OpportunityIcon } from '../../../../journey/opportunity/icon/OpportunityIcon';
import calloutIcons from '../../../callout/utils/calloutIcons';
import { WhiteboardIcon } from '../../../whiteboard/icon/WhiteboardIcon';
Expand All @@ -24,7 +24,7 @@ const ActivityIcon: Record<
[ActivityEventType.CalloutPostCreated]: NotesOutlined,
[ActivityEventType.CalloutPostComment]: ChatBubbleOutlineOutlined,
[ActivityEventType.CalloutLinkCreated]: LinkOutlined,
[ActivityEventType.ChallengeCreated]: ChallengeIcon,
[ActivityEventType.ChallengeCreated]: SubspaceIcon,
[ActivityEventType.OpportunityCreated]: OpportunityIcon,
[ActivityEventType.UpdateSent]: MicOutlined,
[ActivityEventType.CalendarEventCreated]: CalendarMonthOutlined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,14 @@ export const ContributorAccountView: FC<ContributorAccountViewProps> = ({ accoun
<BlockTitle>{t('pages.admin.generic.sections.account.hostedSpaces')}</BlockTitle>
<Gutters disablePadding disableGap className={styles.gutters}>
{loading && <JourneyCardHorizontalSkeleton />}
<Gutters>
<Gutters disablePadding>
{!loading &&
account?.spaces.map(space => (
<JourneyCardHorizontal
key={space.id}
journeyTypeName="space"
journey={{ profile: space.profile, community: {} }}
size="medium"
deepness={0}
seamless
sx={{ display: 'inline-block', maxWidth: '100%', padding: 0 }}
Expand Down
10 changes: 5 additions & 5 deletions src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, useState } from 'react';
import { ApolloError } from '@apollo/client';
import { SearchableListItem } from '../../../platform/admin/components/SearchableList';
import { SearchableTableItem } from '../../../platform/admin/components/SearchableTable';
import { useDeleteUserMutation, useUserListQuery } from '../../../../core/apollo/generated/apollo-hooks';
import { useNotification } from '../../../../core/ui/notifications/useNotification';
import usePaginatedQuery from '../../../shared/pagination/usePaginatedQuery';
Expand All @@ -13,8 +13,8 @@ interface Provided {
loading: boolean;
deleting: boolean;
error?: ApolloError;
userList: SearchableListItem[];
onDelete: (item: SearchableListItem) => void;
userList: SearchableTableItem[];
onDelete: (item: SearchableTableItem) => void;
fetchMore: (itemsNumber?: number) => Promise<void>;
hasMore: boolean | undefined;
pageSize: number;
Expand Down Expand Up @@ -63,7 +63,7 @@ const useAdminGlobalUserList = ({

const userList = useMemo(
() =>
(data?.usersPaginated.users ?? []).map<SearchableListItem>(({ id, profile, email }) => ({
(data?.usersPaginated.users ?? []).map<SearchableTableItem>(({ id, profile, email }) => ({
id,
value: `${profile.displayName} (${email})`,
url: buildSettingsUrl(profile.url),
Expand All @@ -76,7 +76,7 @@ const useAdminGlobalUserList = ({
onCompleted: () => notify(t('pages.admin.users.notifications.user-removed'), 'success'),
});

const onDelete = (item: SearchableListItem) => {
const onDelete = (item: SearchableTableItem) => {
deleteUser({
variables: {
input: {
Expand Down
3 changes: 2 additions & 1 deletion src/domain/journey/common/JourneyAvatar/JourneyAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { forwardRef } from 'react';
import { SxProps, Theme } from '@mui/material';
import Avatar, { SizeableAvatarProps } from '../../../../core/ui/avatar/Avatar';
import Avatar, { Size, SizeableAvatarProps } from '../../../../core/ui/avatar/Avatar';
import defaultJourneyAvatar from '../../defaultVisuals/Avatar.jpg';

interface JourneyAvatarProps extends SizeableAvatarProps {
src: string | undefined;
sx?: SxProps<Theme> | undefined;
size?: Size;
}

const JourneyAvatar = forwardRef<HTMLDivElement, JourneyAvatarProps>(({ src, size = 'large', ...props }, ref) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { intersection } from 'lodash';
import FlexSpacer from '../../../../core/ui/utils/FlexSpacer';
import JourneyAvatar from '../JourneyAvatar/JourneyAvatar';
import ActionsMenu from '../../../../core/ui/card/ActionsMenu';
import { Size } from '../../../../core/ui/avatar/Avatar';

export const JourneyCardHorizontalSkeleton = () => (
<ElevatedPaper sx={{ padding: gutters() }}>
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface JourneyCardHorizontalProps {
journeyTypeName: JourneyTypeName;
sx?: PaperProps['sx'];
actions?: ReactNode;
size?: Size;
}

const ElevatedPaper = withElevationOnHover(Paper) as typeof Paper;
Expand All @@ -58,6 +60,7 @@ const JourneyCardHorizontal = ({
seamless,
sx,
actions,
size,
}: JourneyCardHorizontalProps) => {
const Icon = JourneyIcon[journeyTypeName];

Expand All @@ -68,18 +71,14 @@ const JourneyCardHorizontal = ({
const mergedSx: PaperProps['sx'] = {
padding: gutters(),
marginLeft: gutters(deepness * 2),
borderRadius: 'unset',
...sx,
};

return (
<ElevatedPaper sx={mergedSx} elevation={seamless ? 0 : undefined}>
<BadgeCardView
visual={
<JourneyAvatar
src={journey.profile.avatar?.uri || journey.profile.cardBanner?.uri}
sx={{ width: gutters(3), height: gutters(3) }}
/>
}
visual={<JourneyAvatar size={size} src={journey.profile.avatar?.uri || journey.profile.cardBanner?.uri} />}
component={RouterLink}
to={journey.profile.url}
actions={actions && <ActionsMenu>{actions}</ActionsMenu>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const ChildJourneyView = <ChildEntity extends BaseChildEntity>({
const key = item ? item.id : `__loading_${index}`;
return cloneElement(renderChildEntityCard(item), { key });
})}
{permissions.canCreateChallenges && (
{permissions.canCreateSubspaces && (
<Actions sx={{ justifyContent: 'flex-end', width: '100%' }}>
<IconButton aria-label={t('common.add')} size="small" onClick={() => onClickCreate?.(true)}>
<RoundedIcon component={AddIcon} size="medium" iconSize="small" />
Expand Down
16 changes: 8 additions & 8 deletions src/domain/journey/space/SpaceContext/SpaceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export interface SpacePermissions {
canRead: boolean;
viewerCanUpdate: boolean;
canReadPosts: boolean;
canReadChallenges: boolean;
canCreateChallenges: boolean;
canReadSubspaces: boolean;
canCreateSubspaces: boolean;
canCreate: boolean;
communityReadAccess: boolean;
contextPrivileges: AuthorizationPrivilege[];
Expand Down Expand Up @@ -49,9 +49,9 @@ const SpaceContext = React.createContext<SpaceContextProps>({
canRead: false,
viewerCanUpdate: false,
canCreate: false,
canCreateChallenges: false,
canCreateSubspaces: false,
canReadPosts: false,
canReadChallenges: false,
canReadSubspaces: false,
communityReadAccess: false,
contextPrivileges: [],
},
Expand Down Expand Up @@ -98,7 +98,7 @@ const SpaceContextProvider: FC<SpaceProviderProps> = ({ children }) => {
const contextPrivileges = space?.context?.authorization?.myPrivileges ?? NO_PRIVILEGES;
const spacePrivileges = space?.authorization?.myPrivileges ?? NO_PRIVILEGES;

const canReadChallenges = spacePrivileges.includes(AuthorizationPrivilege.Read);
const canReadSubspaces = spacePrivileges.includes(AuthorizationPrivilege.Read);
const canCreateSubspaces = spacePrivileges.includes(AuthorizationPrivilege.CreateSubspace);
const canCreate = spacePrivileges.includes(AuthorizationPrivilege.Create);

Expand All @@ -108,14 +108,14 @@ const SpaceContextProvider: FC<SpaceProviderProps> = ({ children }) => {
return {
canRead: spacePrivileges.includes(AuthorizationPrivilege.Read),
viewerCanUpdate: spacePrivileges.includes(AuthorizationPrivilege.Update),
canReadChallenges,
canCreateChallenges: canCreateSubspaces,
canReadSubspaces,
canCreateSubspaces: canCreateSubspaces,
canCreate,
communityReadAccess: communityPrivileges.includes(AuthorizationPrivilege.Read),
canReadPosts: contextPrivileges.includes(AuthorizationPrivilege.Read),
contextPrivileges,
};
}, [spacePrivileges, contextPrivileges, canReadChallenges, communityPrivileges, canCreate, canCreateSubspaces]);
}, [spacePrivileges, contextPrivileges, canReadSubspaces, communityPrivileges, canCreate, canCreateSubspaces]);

const profile = useMemo(() => {
return {
Expand Down
6 changes: 3 additions & 3 deletions src/domain/journey/space/layout/SpaceTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useSpace } from '../SpaceContext/useSpace';
import { buildSettingsUrl } from '../../../../main/routing/urlBuilders';
import { EntityPageSection } from '../../../shared/layout/EntityPageSection';
import { useTranslation } from 'react-i18next';
import { ChallengeIcon } from '../../subspace/icon/ChallengeIcon';
import { SubspaceIcon } from '../../subspace/icon/SubspaceIcon';

const SpaceTabs = (props: EntityTabsProps) => {
const { t } = useTranslation();
Expand All @@ -24,8 +24,8 @@ const SpaceTabs = (props: EntityTabsProps) => {
subEntityTab={{
label: t('common.subspaces'),
section: EntityPageSection.Subspaces,
icon: <ChallengeIcon />,
disabled: !permissions.canReadChallenges,
icon: <SubspaceIcon />,
disabled: !permissions.canReadSubspaces,
}}
/>
);
Expand Down
Loading