Skip to content

Commit

Permalink
🛠 Fix api and sub link (#2201)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomaricMourgues authored and Labels Bot committed May 26, 2022
1 parent 34e8cff commit 12999b5
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function getAppFromRequest($request, $capabilities = [], $privileges = []

$group_app = $this->doctrine->getRepository("Twake\Workspaces:GroupApp")->findOneBy(Array("app_id" => $application->getId(), "group" => $group_id));

if($group_app->getPrivileges() === null){
return $application;
}

if ((!$group_id || !$group_app) && (count($capabilities) > 0 || count($privileges) > 0)) {
return Array("error" => "you_need_to_provide_a_valid_group_id_field_in_any_api_request", "group_id" => $group_id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import FeatureTogglesService, {
FeatureNames,
} from 'app/features/global/services/feature-toggles-service';
import MessageHistoryService from 'app/features/messages/services/message-history-service';
import consoleService from 'app/features/console/services/console-service';

const { Text, Title, Link } = Typography;
const CompanyMessagesCounter = () => {
Expand All @@ -18,8 +19,7 @@ const CompanyMessagesCounter = () => {

const { company } = useCurrentCompany();

const companySubscriptionUrl =
InitService.server_infos?.configuration.accounts.console?.company_subscription_url || '';
const companySubscriptionUrl = consoleService.getCompanySubscriptionUrl(company.id);

const onClickLink = () => window.open(companySubscriptionUrl, 'blank');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import ObjectModal from 'app/components/object-modal/object-modal';
import { Button, Row, Typography } from 'antd';
import ModalManager from 'app/components/modal/modal-manager';
import Languages from 'app/features/global/services/languages-service';
import InitService from 'app/features/global/services/init-service';
import consoleService from 'app/features/console/services/console-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';

const { Title, Text } = Typography;
export default () => (
export default () => {
const companyId = useRouterCompany();
return (
<ObjectModal
titleCenter
titleLevel={2}
Expand All @@ -24,8 +27,7 @@ export default () => (
style={{ marginTop: 8 }}
onClick={() =>
window.open(
InitService.server_infos?.configuration?.accounts?.console
?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(companyId),
'blank',
)
}
Expand Down Expand Up @@ -69,4 +71,4 @@ export default () => (
/>
</Row>
</ObjectModal>
);
)};
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import Emojione from 'app/components/emojione/emojione';
import Languages from 'app/features/global/services/languages-service';
import './locked-history-banner.scss';
import InitService from 'app/features/global/services/init-service';
import consoleService from 'app/features/console/services/console-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';

const { Title, Text } = Typography;
const LockedHistoryBanner = (): JSX.Element => {

const companyId = useRouterCompany();

const onClickBtn = () =>
window.open(
InitService.server_infos?.configuration?.accounts?.console?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(companyId),
'blank',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import InitService from 'app/features/global/services/init-service';
import { AlertTriangle } from 'react-feather';
import { useCurrentCompany } from 'app/features/companies/hooks/use-companies';
import { CompanyLimitsEnum, CompanyType } from 'app/features/companies/types/company';
import consoleService from 'app/features/console/services/console-service';

type PropsType = { company: Partial<CompanyType>; magicLink?: boolean };

Expand All @@ -13,7 +14,7 @@ const LockedInviteAlert = (props: PropsType): JSX.Element => {
const limit = props?.company?.plan?.limits?.[CompanyLimitsEnum.COMPANY_MEMBERS_LIMIT] || 0;
const onClickBtn = () =>
window.open(
InitService.server_infos?.configuration?.accounts?.console?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(props.company.id || ""),
'blank',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { Button, Row, Typography } from 'antd';
import ModalManager from 'app/components/modal/modal-manager';
import Languages from 'app/features/global/services/languages-service';
import InitService from 'app/features/global/services/init-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import consoleService from 'app/features/console/services/console-service';

type PropsType = {
pricingPlanUrl: string;
};

const { Title, Text } = Typography;
export default () => (
export default () => {
const companyId = useRouterCompany();
return (
<ObjectModal
titleCenter
titleLevel={2}
Expand All @@ -28,8 +32,7 @@ export default () => (
style={{ marginTop: 8 }}
onClick={() =>
window.open(
InitService.server_infos?.configuration?.accounts?.console
?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(companyId),
'blank',
)
}
Expand Down Expand Up @@ -74,4 +77,4 @@ export default () => (
/>
</Row>
</ObjectModal>
);
)};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { Button, Row, Typography } from 'antd';
import ModalManager from 'app/components/modal/modal-manager';
import Languages from 'app/features/global/services/languages-service';
import InitService from 'app/features/global/services/init-service';
import consoleService from 'app/features/console/services/console-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';

const { Title, Text } = Typography;
export default () => (
export default () => {
const companyId = useRouterCompany();
return (
<ObjectModal
titleCenter
titleLevel={2}
Expand All @@ -24,8 +28,7 @@ export default () => (
style={{ marginTop: 8 }}
onClick={() =>
window.open(
InitService.server_infos?.configuration?.accounts?.console
?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(companyId),
'blank',
)
}
Expand Down Expand Up @@ -69,4 +72,4 @@ export default () => (
/>
</Row>
</ObjectModal>
);
)};
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import Groups from 'app/deprecated/workspaces/groups.js';
import InitService from 'app/features/global/services/init-service';
import Languages from 'app/features/global/services/languages-service';
import { AlertTriangle } from 'react-feather';
import consoleService from 'app/features/console/services/console-service';

type PropsType = {
companyId: string;
};

const { Link } = Typography;
export default ({ companyId }: PropsType): JSX.Element => {
const companySubscriptionUrl =
InitService.server_infos?.configuration.accounts.console?.company_subscription_url || '';
const companySubscriptionUrl = consoleService.getCompanySubscriptionUrl(companyId);
const userGroups: { [key: string]: CompanyType } = Groups.user_groups;
const currentUserGroup = userGroups[companyId];
const isCurrentUserAdminOrOwner =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UserService from 'app/features/users/services/current-user-service';
import Groups from 'app/deprecated/workspaces/groups.js';
import { AlertTriangle } from 'react-feather';
import InitService from 'app/features/global/services/init-service';
import consoleService from 'app/features/console/services/console-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';

type SwitchCompanyPropsType = {
placeholder?: string;
Expand Down Expand Up @@ -57,9 +59,10 @@ const SwitchCompany = ({ placeholder, companiesIds }: SwitchCompanyPropsType): J
};

export default (): JSX.Element => {
const companyId = useRouterCompany();
const onClickButton = () =>
window.open(
InitService.server_infos?.configuration?.accounts?.console?.company_subscription_url || '',
consoleService.getCompanySubscriptionUrl(companyId),
'blank',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ class ConsoleService {
public getCompanyManagementUrl(companyId: string) {
const identity_provider_id =
getCompany(companyId)?.identity_provider_id || getCompany(companyId)?.id;
console.log(identity_provider_id);
return (
InitService.server_infos?.configuration?.accounts?.console?.company_management_url || ''
).replace('{company_id}', identity_provider_id);
}

public getCompanySubscriptionUrl(companyId: string) {
const identity_provider_id =
getCompany(companyId)?.identity_provider_id || getCompany(companyId)?.id;
return (
InitService.server_infos?.configuration?.accounts?.console?.company_subscription_url || ''
).replace('{company_id}', identity_provider_id);
}

public getCompanyUsersManagementUrl(companyId: string) {
const identity_provider_id =
getCompany(companyId)?.identity_provider_id || getCompany(companyId)?.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import UserService from 'app/features/users/services/current-user-service';
import ModalManager from 'app/components/modal/modal-manager';
import ChannelWorkspaceEditor from 'app/views/client/channels-bar/Modals/ChannelWorkspaceEditor';
import AccessRightsService from 'app/features/workspace-members/services/workspace-members-access-rights-service';
import { NotificationResource } from 'app/features/users/types/notification-types';
import RouterServices from 'app/features/router/services/router-service';
import GuestManagement from 'app/views/client/channels-bar/Modals/GuestManagement';
import { useFeatureToggles } from 'app/components/locked-features-components/feature-toggles-hooks';
Expand All @@ -28,6 +27,7 @@ import FeatureTogglesService from 'app/features/global/services/feature-toggles-
import ChannelAPIClient from 'app/features/channels/api/channel-api-client';
import { useRefreshDirectChannels } from 'app/features/channels/hooks/use-direct-channels';
import { useChannelNotifications } from 'app/features/users/hooks/use-notifications';
import consoleService from 'app/features/console/services/console-service';

type PropsType = {
channel: ChannelType;
Expand Down Expand Up @@ -117,8 +117,7 @@ const FullMenu = (props: PropsType): JSX.Element => {
) : (
<LockedGuestsPopup
companySubscriptionUrl={
InitService.server_infos?.configuration?.accounts?.console?.company_subscription_url ||
''
consoleService.getCompanySubscriptionUrl(props.channel.company_id || "")
}
/>
),
Expand Down

0 comments on commit 12999b5

Please sign in to comment.