Skip to content

Commit

Permalink
Limit github onboarding to team users (#2729)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspergrom authored Dec 19, 2024
1 parent 062368c commit 1785df2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions frontend/scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare -a ENV_VARIABLES=(
"VUE_APP_IS_TWITTER_ENABLED"
"VUE_APP_DATADOG_RUM_APPLICATION_ID"
"VUE_APP_DATADOG_RUM_CLIENT_TOKEN"
"VUE_APP_TEAM_USER_IDS"
)

for ENV_VAR in "${ENV_VARIABLES[@]}"
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const defaultConfig = {
clientToken: import.meta.env.VUE_APP_DATADOG_RUM_CLIENT_TOKEN,
},
},
permissions: {
teamUserIds: import.meta.env.VUE_APP_TEAM_USER_IDS,
},
};

const composedConfig = {
Expand Down Expand Up @@ -140,6 +143,9 @@ const composedConfig = {
clientToken: 'CROWD_VUE_APP_DATADOG_RUM_CLIENT_TOKEN',
},
},
permissions: {
teamUserIds: 'CROWD_VUE_APP_TEAM_USER_IDS',
},
};

const config = defaultConfig.backendUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,35 @@
<!-- Details-->
<!-- </lf-button>-->
<el-tooltip
content="Onboarding new data for GitHub is currently disabled due to some issues we are experiencing.
Please contact support if you need to onboard new data or update settings."
content="Onboarding new data for GitHub is currently being
managed by the CM dev team. Please reach out in Slack (#lfx-cm) to get your project onboarded."
placement="top"
:disabled="isTeam"
>
<span>
<lf-button type="secondary" disabled @click="isSettingsDrawerOpen = true">
<lf-icon name="link-simple" />
Connect
</lf-button>
</span>
<lf-button type="secondary" :disabled="!isTeam" @click="isSettingsDrawerOpen = true">
<lf-icon name="link-simple" />
Connect
</lf-button>
</el-tooltip>
</div>
<lf-github-settings-drawer v-if="isSettingsDrawerOpen" v-model="isSettingsDrawerOpen" :integration="null" />
</div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { ref, computed } from 'vue';
import LfButton from '@/ui-kit/button/Button.vue';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import LfGithubSettingsDrawer from '@/config/integrations/github/components/settings/github-settings-drawer.vue';
import { isTeamUser } from '@/config/permissions';
import { useAuthStore } from '@/modules/auth/store/auth.store';
import { storeToRefs } from 'pinia';
const isSettingsDrawerOpen = ref(false);
const { user } = storeToRefs(useAuthStore());
const isTeam = computed(() => isTeamUser(user.value));
</script>

<script lang="ts">
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/config/permissions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LfRole } from '@/shared/modules/permissions/types/Roles';
import { LfPermission } from '@/shared/modules/permissions/types/Permissions';
import { User } from '@/modules/auth/types/User.type';
import config from '@/config';
import readonly from './readonly';
import admin from './admin';
import projectAdmin from './projectAdmin';
Expand All @@ -9,3 +11,7 @@ export const lfPermissions: Record<LfRole, Record<LfPermission, boolean>> = {
admin,
projectAdmin,
};

const teamUsers: string[] = (config.permissions.teamUserIds || '').split(',');

export const isTeamUser = (user: User | null) => user && teamUsers.includes(user.id);

0 comments on commit 1785df2

Please sign in to comment.