description: 'Lets do it',
type: SettingType.BOOLEAN,
}),
+ mockDefinition({
+ category: 'authentication',
+ defaultValue: 'false',
+ key: 'provisioning.github.project.visibility.enabled',
+ subCategory: 'github',
+ name: 'Compilation Constants',
+ description: 'Lets do it',
+ type: SettingType.BOOLEAN,
+ }),
];
export default class SettingsServiceMock {
import AutoProvisioningConsent from './AutoProvisionningConsent';
import ConfigurationForm from './ConfigurationForm';
import GitHubConfigurationValidity from './GitHubConfigurationValidity';
-import useGithubConfiguration, { GITHUB_JIT_FIELDS } from './hook/useGithubConfiguration';
+import useGithubConfiguration, {
+ GITHUB_ADDITIONAL_FIELDS,
+ GITHUB_JIT_FIELDS,
+ GITHUB_PROVISIONING_FIELDS,
+} from './hook/useGithubConfiguration';
interface GithubAuthenticationProps {
definitions: ExtendedSettingDefinition[];
currentTab: AuthenticationTabs;
}
-const GITHUB_EXCLUDED_FIELD = ['sonar.auth.github.enabled', 'sonar.auth.github.allowUsersToSignUp'];
+const GITHUB_EXCLUDED_FIELD = ['sonar.auth.github.enabled', ...GITHUB_ADDITIONAL_FIELDS];
export default function GithubAuthenticationTab(props: GithubAuthenticationProps) {
const { definitions, currentTab } = props;
{githubProvisioningStatus && <GitHubSynchronisationWarning />}
- <div className="sw-flex sw-flex-1">
+ <div className="sw-flex sw-flex-1 spacer-bottom">
<Button
className="spacer-top width-30"
onClick={synchronizeNow}
{translate('settings.authentication.github.synchronize_now')}
</Button>
</div>
+ {(newGithubProvisioningStatus ?? githubProvisioningStatus) && (
+ <>
+ <hr />
+ {Object.values(values).map((val) => {
+ if (!GITHUB_PROVISIONING_FIELDS.includes(val.key)) {
+ return null;
+ }
+ return (
+ <div key={val.key}>
+ <AuthenticationFormField
+ settingValue={
+ values[val.key]?.newValue ?? values[val.key]?.value
+ }
+ definition={val.definition}
+ mandatory={val.mandatory}
+ onFieldChange={setNewValue}
+ isNotSet={val.isNotSet}
+ />
+ </div>
+ );
+ })}
+ </>
+ )}
</>
) : (
<p>
export const GITHUB_API_URL_FIELD = 'sonar.auth.github.apiUrl';
export const GITHUB_CLIENT_ID_FIELD = 'sonar.auth.github.clientId.secured';
export const GITHUB_JIT_FIELDS = ['sonar.auth.github.allowUsersToSignUp'];
+export const GITHUB_PROVISIONING_FIELDS = ['provisioning.github.project.visibility.enabled'];
+
+export const GITHUB_ADDITIONAL_FIELDS = [...GITHUB_JIT_FIELDS, ...GITHUB_PROVISIONING_FIELDS];
export const OPTIONAL_FIELDS = [
GITHUB_ENABLED_FIELD,
- ...GITHUB_JIT_FIELDS,
+ ...GITHUB_ADDITIONAL_FIELDS,
'sonar.auth.github.organizations',
'sonar.auth.github.groupsSync',
- 'provisioning.github.project.visibility.enabled',
];
export interface SamlSettingValue {
newGithubProvisioningStatus !== undefined &&
newGithubProvisioningStatus !== githubProvisioningStatus;
const hasGithubProvisioningConfigChange =
- some(GITHUB_JIT_FIELDS, isValueChange) || hasGithubProvisioningTypeChange;
+ some(GITHUB_ADDITIONAL_FIELDS, isValueChange) || hasGithubProvisioningTypeChange;
const resetJitSetting = () => {
- GITHUB_JIT_FIELDS.forEach((s) => setNewValue(s));
+ GITHUB_ADDITIONAL_FIELDS.forEach((s) => setNewValue(s));
};
const { mutate: saveSetting } = useSaveValueMutation();
};
const saveGroup = () => {
- const newValues = GITHUB_JIT_FIELDS.map((settingKey) => values[settingKey]);
+ const newValues = GITHUB_ADDITIONAL_FIELDS.map((settingKey) => values[settingKey]);
saveSettings(newValues);
};
options: [],
fields: [],
},
+ {
+ name: 'Provision project visibility',
+ key: 'provisioning.github.project.visibility.enabled',
+ description:
+ 'Change project visibility based on GitHub repository visibility. If disabled, every provisioned project will be private and will be seen only for those users that have explicit GitHub permissions for the according repository.',
+ type: SettingType.BOOLEAN,
+ category: 'authentication',
+ subCategory: 'github',
+ defaultValue: 'true',
+ options: [],
+ fields: [],
+ },
];