[MM-51844 & MM-51843] Work template permissions check (#22825)
Этот коммит содержится в:
@@ -42,7 +42,7 @@ content:
|
|||||||
template: "Product Release"
|
template: "Product Release"
|
||||||
name: "Feature release"
|
name: "Feature release"
|
||||||
id: product-release-playbook
|
id: product-release-playbook
|
||||||
illustration: "/static/worktemplates/product_teams/feature_release/playbook.png"
|
illustration: "/static/worktemplates/playbooks/product_release.png"
|
||||||
- integration:
|
- integration:
|
||||||
id: jira
|
id: jira
|
||||||
- integration:
|
- integration:
|
||||||
@@ -61,7 +61,7 @@ description:
|
|||||||
board:
|
board:
|
||||||
id: worktemplate.product_teams.goals_and_okrs.board
|
id: worktemplate.product_teams.goals_and_okrs.board
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
||||||
integration:
|
integration:
|
||||||
id: worktemplate.product_teams.goals_and_okrs.integration
|
id: worktemplate.product_teams.goals_and_okrs.integration
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
@@ -134,7 +134,7 @@ description:
|
|||||||
board:
|
board:
|
||||||
id: worktemplate.product_teams.sprint_planning.board
|
id: worktemplate.product_teams.sprint_planning.board
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
Track your team's progress toward weekly goals with sprint breakdowns, prioritization, owner assignment, and comments.
|
Track your team's progress toward weekly goals with sprint breakdowns, prioritization, owner assignment, and comments.
|
||||||
integration:
|
integration:
|
||||||
id: worktemplate.product_teams.sprint_planning.integration
|
id: worktemplate.product_teams.sprint_planning.integration
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
@@ -263,7 +263,7 @@ description:
|
|||||||
board:
|
board:
|
||||||
id: worktemplate.companywide.goals_and_okrs.board
|
id: worktemplate.companywide.goals_and_okrs.board
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
||||||
integration:
|
integration:
|
||||||
id: worktemplate.companywide.goals_and_okrs.integration
|
id: worktemplate.companywide.goals_and_okrs.integration
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
@@ -337,7 +337,7 @@ description:
|
|||||||
board:
|
board:
|
||||||
id: worktemplate.leadership.goals_and_okrs.board
|
id: worktemplate.leadership.goals_and_okrs.board
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.
|
||||||
integration:
|
integration:
|
||||||
id: worktemplate.leadership.goals_and_okrs.integration
|
id: worktemplate.leadership.goals_and_okrs.integration
|
||||||
defaultMessage: >-
|
defaultMessage: >-
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ var wt00a1b44a5831c0a3acb14787b3fdd352 = &WorkTemplate{
|
|||||||
Template: "Product Release",
|
Template: "Product Release",
|
||||||
Name: "Feature release",
|
Name: "Feature release",
|
||||||
ID: "product-release-playbook",
|
ID: "product-release-playbook",
|
||||||
Illustration: "/static/worktemplates/product_teams/feature_release/playbook.png",
|
Illustration: "/static/worktemplates/playbooks/product_release.png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -174,7 +174,7 @@ var wt5baa68055bf9ea423273662e01ccc575 = &WorkTemplate{
|
|||||||
},
|
},
|
||||||
Board: &TranslatableString{
|
Board: &TranslatableString{
|
||||||
ID: "worktemplate.product_teams.goals_and_okrs.board",
|
ID: "worktemplate.product_teams.goals_and_okrs.board",
|
||||||
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board. ",
|
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.",
|
||||||
Illustration: "",
|
Illustration: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ var wt8d2ef53deac5517eb349dc5de6150196 = &WorkTemplate{
|
|||||||
},
|
},
|
||||||
Board: &TranslatableString{
|
Board: &TranslatableString{
|
||||||
ID: "worktemplate.product_teams.sprint_planning.board",
|
ID: "worktemplate.product_teams.sprint_planning.board",
|
||||||
DefaultMessage: "Track your team's progress toward weekly goals with sprint breakdowns, prioritization, owner assignment, and comments. ",
|
DefaultMessage: "Track your team's progress toward weekly goals with sprint breakdowns, prioritization, owner assignment, and comments.",
|
||||||
Illustration: "",
|
Illustration: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ var wtf7b846d35810f8272eeb9a1a562025b5 = &WorkTemplate{
|
|||||||
},
|
},
|
||||||
Board: &TranslatableString{
|
Board: &TranslatableString{
|
||||||
ID: "worktemplate.companywide.goals_and_okrs.board",
|
ID: "worktemplate.companywide.goals_and_okrs.board",
|
||||||
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board. ",
|
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.",
|
||||||
Illustration: "",
|
Illustration: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ var wt32ab773bfe021e3d4913931041552559 = &WorkTemplate{
|
|||||||
},
|
},
|
||||||
Board: &TranslatableString{
|
Board: &TranslatableString{
|
||||||
ID: "worktemplate.leadership.goals_and_okrs.board",
|
ID: "worktemplate.leadership.goals_and_okrs.board",
|
||||||
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board. ",
|
DefaultMessage: "Track your team's progress toward organizational goals with the Goals and OKR board. Keep meetings on track with the Meeting Agenda board.",
|
||||||
Illustration: "",
|
Illustration: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ import {trackEvent} from 'actions/telemetry_actions';
|
|||||||
import Constants, {TELEMETRY_CATEGORIES} from 'utils/constants';
|
import Constants, {TELEMETRY_CATEGORIES} from 'utils/constants';
|
||||||
import {isEnterpriseOrE20License} from 'utils/license_utils';
|
import {isEnterpriseOrE20License} from 'utils/license_utils';
|
||||||
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||||
|
import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||||
|
import {Permissions} from 'mattermost-redux/constants';
|
||||||
|
import {GlobalState} from 'types/store';
|
||||||
import {Visibility, WorkTemplate} from '@mattermost/types/work_templates';
|
import {Visibility, WorkTemplate} from '@mattermost/types/work_templates';
|
||||||
import {ChannelType} from '@mattermost/types/channels';
|
import {ChannelType} from '@mattermost/types/channels';
|
||||||
|
|
||||||
export interface CustomizeProps {
|
export interface CustomizeProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -38,6 +41,10 @@ const Customize = ({
|
|||||||
const templateHasChannels = template.content.findIndex((item) => item.channel) !== -1;
|
const templateHasChannels = template.content.findIndex((item) => item.channel) !== -1;
|
||||||
const templateHasBoards = template.content.findIndex((item) => item.board) !== -1;
|
const templateHasBoards = template.content.findIndex((item) => item.board) !== -1;
|
||||||
const templateHasPlaybooks = template.content.findIndex((item) => item.playbook) !== -1;
|
const templateHasPlaybooks = template.content.findIndex((item) => item.playbook) !== -1;
|
||||||
|
const canCreatePublicChannel = useSelector((state: GlobalState) => haveICurrentTeamPermission(state, Permissions.CREATE_PUBLIC_CHANNEL));
|
||||||
|
const canCreatePrivateChannel = useSelector((state: GlobalState) => haveICurrentTeamPermission(state, Permissions.CREATE_PRIVATE_CHANNEL));
|
||||||
|
const canCreatePublicPlaybook = useSelector((state: GlobalState) => haveICurrentTeamPermission(state, Permissions.PLAYBOOK_PUBLIC_CREATE));
|
||||||
|
const canCreatePrivatePlaybook = useSelector((state: GlobalState) => haveICurrentTeamPermission(state, Permissions.PLAYBOOK_PRIVATE_CREATE));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
trackEvent(TELEMETRY_CATEGORIES.WORK_TEMPLATES, 'pageview_customize');
|
trackEvent(TELEMETRY_CATEGORIES.WORK_TEMPLATES, 'pageview_customize');
|
||||||
@@ -49,10 +56,39 @@ const Customize = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
let privateButtonProps = {};
|
let privateButtonProps = {};
|
||||||
if (templateHasPlaybooks && !licenseIsEnterprise) {
|
let publicButtonProps = {};
|
||||||
if (visibility === Visibility.Private) {
|
if (templateHasPlaybooks) {
|
||||||
onVisibilityChanged(Visibility.Public);
|
if (!canCreatePublicPlaybook) {
|
||||||
|
publicButtonProps = {
|
||||||
|
tooltip: formatMessage({id: 'work_templates.customize.public_playbook_permission_issue', defaultMessage: 'You do not have permission to create public playbooks.'}),
|
||||||
|
disabled: true,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
if (!canCreatePrivatePlaybook) {
|
||||||
|
privateButtonProps = {
|
||||||
|
tooltip: formatMessage({id: 'work_templates.customize.private_playbook_permission_issue', defaultMessage: 'You do not have permission to create private playbooks.'}),
|
||||||
|
disabled: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (templateHasChannels) {
|
||||||
|
if (!canCreatePublicChannel) {
|
||||||
|
publicButtonProps = {
|
||||||
|
tooltip: formatMessage({id: 'work_templates.customize.public_channel_permission_issue', defaultMessage: 'You do not have permission to create public channels.'}),
|
||||||
|
disabled: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!canCreatePrivateChannel) {
|
||||||
|
privateButtonProps = {
|
||||||
|
tooltip: formatMessage({id: 'work_templates.customize.private_channel_permission_issue', defaultMessage: 'You do not have permission to create private channels.'}),
|
||||||
|
disabled: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// leave this rule last as it has priority
|
||||||
|
if (templateHasPlaybooks && !licenseIsEnterprise) {
|
||||||
privateButtonProps = {
|
privateButtonProps = {
|
||||||
tooltip: formatMessage({id: 'work_templates.customize.private_playbook_license_issue', defaultMessage: 'Private playbooks requires an Enterprise license.'}),
|
tooltip: formatMessage({id: 'work_templates.customize.private_playbook_license_issue', defaultMessage: 'Private playbooks requires an Enterprise license.'}),
|
||||||
locked: true,
|
locked: true,
|
||||||
@@ -98,6 +134,7 @@ const Customize = ({
|
|||||||
selected={privacySelectorValue}
|
selected={privacySelectorValue}
|
||||||
onChange={onPrivacySelectorChanged}
|
onChange={onPrivacySelectorChanged}
|
||||||
privateButtonProps={privateButtonProps}
|
privateButtonProps={privateButtonProps}
|
||||||
|
publicButtonProps={publicButtonProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,4 +183,3 @@ const StyledCustomized = styled(Customize)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default StyledCustomized;
|
export default StyledCustomized;
|
||||||
|
|
||||||
|
|||||||
@@ -5699,7 +5699,11 @@
|
|||||||
"work_templates.customize.name_label_all": "Name your channel, board, and playbook",
|
"work_templates.customize.name_label_all": "Name your channel, board, and playbook",
|
||||||
"work_templates.customize.name_label_channels_boards": "Name your channel and board",
|
"work_templates.customize.name_label_channels_boards": "Name your channel and board",
|
||||||
"work_templates.customize.name_label_channels_playbooks": "Name your channel and playbook",
|
"work_templates.customize.name_label_channels_playbooks": "Name your channel and playbook",
|
||||||
|
"work_templates.customize.private_channel_permission_issue": "You do not have permission to create private channels.",
|
||||||
"work_templates.customize.private_playbook_license_issue": "Private playbooks requires an Enterprise license.",
|
"work_templates.customize.private_playbook_license_issue": "Private playbooks requires an Enterprise license.",
|
||||||
|
"work_templates.customize.private_playbook_permission_issue": "You do not have permission to create private playbooks.",
|
||||||
|
"work_templates.customize.public_channel_permission_issue": "You do not have permission to create public channels.",
|
||||||
|
"work_templates.customize.public_playbook_permission_issue": "You do not have permission to create public playbooks.",
|
||||||
"work_templates.customize.visibility_title": "Who should have access to this?",
|
"work_templates.customize.visibility_title": "Who should have access to this?",
|
||||||
"work_templates.menu.modal_title": "Create from a template",
|
"work_templates.menu.modal_title": "Create from a template",
|
||||||
"work_templates.menu.quick_use": "Quick use",
|
"work_templates.menu.quick_use": "Quick use",
|
||||||
|
|||||||
Двоичный файл не отображается.
|
До Ширина: | Высота: | Размер: 516 KiB После Ширина: | Высота: | Размер: 516 KiB |
Двоичный файл не отображается.
|
До Ширина: | Высота: | Размер: 516 KiB |
@@ -3,14 +3,23 @@
|
|||||||
|
|
||||||
import {createSelector} from 'reselect';
|
import {createSelector} from 'reselect';
|
||||||
|
|
||||||
import {getFeatureFlagValue} from 'mattermost-redux/selectors/entities/general';
|
import {getFeatureFlagValue, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {GlobalState} from 'types/store';
|
import {GlobalState} from 'types/store';
|
||||||
|
import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||||
|
import {Permissions} from 'mattermost-redux/constants';
|
||||||
|
import {isEnterpriseOrE20License} from 'utils/license_utils';
|
||||||
|
|
||||||
export const areWorkTemplatesEnabled = createSelector(
|
export const areWorkTemplatesEnabled = createSelector(
|
||||||
'areWorktemplatesEnabled',
|
'areWorktemplatesEnabled',
|
||||||
(state: GlobalState) => getFeatureFlagValue(state, 'WorkTemplate') === 'true',
|
(state: GlobalState) => getFeatureFlagValue(state, 'WorkTemplate') === 'true',
|
||||||
(workTemplateFF) => {
|
(state: GlobalState) => getLicense(state),
|
||||||
return workTemplateFF;
|
(state: GlobalState) => haveICurrentTeamPermission(state, Permissions.CREATE_PUBLIC_CHANNEL) || haveICurrentTeamPermission(state, Permissions.CREATE_PRIVATE_CHANNEL),
|
||||||
|
(state: GlobalState) => haveICurrentTeamPermission(state, Permissions.PLAYBOOK_PUBLIC_CREATE),
|
||||||
|
(state: GlobalState) => haveICurrentTeamPermission(state, Permissions.PLAYBOOK_PRIVATE_CREATE),
|
||||||
|
(workTemplateFF, license, canCreateChannel, canCreatePublicPlaybook, canCreatePrivatePlaybook) => {
|
||||||
|
const licenseIsEnterprise = isEnterpriseOrE20License(license);
|
||||||
|
const canCreatePlaybook = canCreatePublicPlaybook || (canCreatePrivatePlaybook && licenseIsEnterprise);
|
||||||
|
return workTemplateFF && canCreateChannel && canCreatePlaybook;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user