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

Make platform template available for certain pricing plans #9798

Merged
merged 7 commits into from
Dec 17, 2024
Merged
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
1 change: 1 addition & 0 deletions back/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AllCops:
- "**/bin/**/*"
- "engines/ee/**/*"
- "vendor/**/*"
- "**/create_tenant.rake"

Layout/HashAlignment:
EnforcedColonStyle: [key, table]
Expand Down
12 changes: 12 additions & 0 deletions back/config/schemas/settings.schema.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,18 @@
"default": true
}
}
},

"platform_templates": {
"type": "object",
"title": "Platform templates",
"description": "Allow non-superadmins to create reports using platform templates.",
"additionalProperties": false,
"required": ["allowed", "enabled"],
"properties": {
"allowed": { "type": "boolean", "default": false },
"enabled": { "type": "boolean", "default": false }
}
}
},
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions back/engines/commercial/multi_tenancy/db/seeds/tenants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ def create_localhost_tenant
project_review: {
enabled: true,
allowed: true
},
platform_templates: {
enabled: false,
allowed: false
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ namespace :cl2_back do
project_review: {
enabled: true,
allowed: true
},
platform_templates: {
enabled: false,
allowed: false
}
}
)
Expand Down
1 change: 1 addition & 0 deletions front/app/api/app_configuration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export interface IAppConfigurationSettings {
similar_inputs?: AppConfigurationFeature & {
admins_only: boolean;
};
platform_templates?: AppConfigurationFeature;
}

export type TAppConfigurationSettingCore = keyof IAppConfigurationSettingsCore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Radio, Text } from '@citizenlab/cl2-component-library';

import useAuthUser from 'api/me/useAuthUser';

import useFeatureFlag from 'hooks/useFeatureFlag';

import { MessageDescriptor, FormattedMessage } from 'utils/cl-intl';
import { isSuperAdmin } from 'utils/permissions/roles';
import { isSuperAdmin, isAdmin } from 'utils/permissions/roles';

import messages from '../messages';

Expand All @@ -26,10 +28,14 @@ interface Props {

const RadioButtons = ({ value, onChange }: Props) => {
const { data: user } = useAuthUser();
const platformTemplatesEnabled = useFeatureFlag({
name: 'platform_templates',
});

const templateTypes = isSuperAdmin(user)
? TEMPLATE_TYPES
: TEMPLATE_TYPES.filter((type) => type !== 'platform');
const templateTypes =
isSuperAdmin(user) || (platformTemplatesEnabled && isAdmin(user))
? TEMPLATE_TYPES
: TEMPLATE_TYPES.filter((type) => type !== 'platform');

return (
<>
Expand Down