Skip to content

Commit

Permalink
Merge pull request #313 from uselagoon/orgs-modify-env-vars
Browse files Browse the repository at this point in the history
feat: add org env vars to the organizations section
  • Loading branch information
tobybellwood authored Mar 11, 2025
2 parents a06088f + 92eb807 commit ce85294
Show file tree
Hide file tree
Showing 14 changed files with 987 additions and 29 deletions.
6 changes: 6 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ app
});
});

server.get('/organizations/:organizationSlug/variables', (req, res) => {
app.render(req, res, '/organizations/variables', {
organizationSlug: req.params.organizationSlug,
});
});

server.get('/organizations/:organizationSlug/notifications', (req, res) => {
app.render(req, res, '/organizations/notifications', {
organizationSlug: req.params.organizationSlug,
Expand Down
34 changes: 18 additions & 16 deletions src/components/AddVariable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const scopeOptions = [
];

export const AddVariable = ({
varOrganization,
varProject,
varEnvironment,
varValues,
Expand All @@ -49,8 +50,10 @@ export const AddVariable = ({
setClear,
setEnvironmentErrorAlert,
setProjectErrorAlert,
setOrganizationErrorAlert,
action,
loading,
orgEnvValues,
prjEnvValues,
envValues,
}) => {
Expand All @@ -73,14 +76,20 @@ export const AddVariable = ({
setUpdateScope(varScope);
}, [varName, varValue]);
const handleError = () => {
setProjectErrorAlert ? setProjectErrorAlert(true) : setEnvironmentErrorAlert(true);
if (setOrganizationErrorAlert) {
setOrganizationErrorAlert(true);
} else if (setProjectErrorAlert) {
setProjectErrorAlert(true);
} else {
setEnvironmentErrorAlert(true);
}
};

const handlePermissionCheck = () => {
let waitForGQL = setTimeout(() => {
openModal();
}, [1000]);
if (prjEnvValues || envValues) {
if (orgEnvValues || prjEnvValues || envValues) {
clearTimeout(waitForGQL);
openModal();
}
Expand Down Expand Up @@ -193,6 +202,7 @@ export const AddVariable = ({
name: updateName ? updateName : inputName,
value: updateValue ? updateValue : inputValue,
scope: updateScope ? updateScope.toUpperCase() : inputScope,
organization: varOrganization,
project: varProject,
environment: varEnvironment,
},
Expand Down Expand Up @@ -224,13 +234,9 @@ export const AddVariable = ({
}
onClick={showPopconfirm}
>
{varTarget === 'Environment'
? updateVar || varName
? 'Update environment variable'
: 'Add environment variable'
: updateVar || varName
? 'Update project variable'
: 'Add project variable'}
{updateVar || varName
? `Update ${varTarget.toLowerCase()} variable`
: `Add ${varTarget.toLowerCase()} variable`}
</ButtonBootstrap>
</Popconfirm>
);
Expand All @@ -242,13 +248,9 @@ export const AddVariable = ({
}
onClick={addOrUpdateEnvVariableHandler}
>
{varTarget === 'Environment'
? updateVar || varName
? 'Update environment variable'
: 'Add environment variable'
: updateVar || varName
? 'Update project variable'
: 'Add project variable'}
{updateVar || varName
? `Update ${varTarget.toLowerCase()} variable`
: `Add ${varTarget.toLowerCase()} variable`}
</ButtonBootstrap>
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DeleteVariable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ export const DeleteVariable = ({
setClear,
varEnvironment,
varProject,
varOrganization,
open,
openModal,
closeModal,
envValues,
prjEnvValues,
orgEnvValues,
loading,
valueState,
}) => {
const handlePermissionCheck = () => {
let waitForGQL = setTimeout(() => {
openModal();
}, [1000]);
if (prjEnvValues || envValues) {
if (orgEnvValues || prjEnvValues || envValues) {
clearTimeout(waitForGQL);
openModal();
}
Expand Down Expand Up @@ -81,6 +83,7 @@ export const DeleteVariable = ({
variables: {
input: {
name: deleteName,
organization: varOrganization,
project: varProject,
environment: varEnvironment,
},
Expand Down
29 changes: 23 additions & 6 deletions src/components/NavTabs/NavTabsSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { FC } from 'react';
import Skeleton from 'react-loading-skeleton';

import getConfig from 'next/config';

import {
CheckSquareOutlined,
ReadOutlined,
Expand All @@ -16,6 +18,12 @@ import TasksLink from 'components/link/Tasks';

import { StyledNavigation } from './StylednavTabs';

/* eslint-disable-next-line
@typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-call
*/
const { publicRuntimeConfig } = getConfig();

interface NavSkeletonProps {
activeTab: string;
projectName: string;
Expand Down Expand Up @@ -48,12 +56,21 @@ const NavTabsSkeleton: FC<NavSkeletonProps> = ({ activeTab, projectName, openshi
<span className="destination"> Tasks</span>
</TasksLink>
</li>
<li className={`tasks ${activeTab == 'environmentVariables' ? 'active' : ''} ${'linkContainer'}`}>
<EnvironmentVariablesLink environmentSlug={openshiftProjectName} projectSlug={projectName} className="navLink">
<UnorderedListOutlined className="icon" />
<span className="destination"> Variables</span>
</EnvironmentVariablesLink>
</li>
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
publicRuntimeConfig.LAGOON_UI_VIEW_ENV_VARIABLES == null && (
<li className={`variables ${activeTab == 'variables' ? 'active' : ''} linkContainer`}>
<EnvironmentVariablesLink
environmentSlug={openshiftProjectName}
projectSlug={projectName}
className="navLink"
>
<UnorderedListOutlined className="icon" />
<span className="destination"> Variables</span>
</EnvironmentVariablesLink>
</li>
)
}
<Skeleton style={{ height: '50px', lineHeight: '0.5' }} />
<Skeleton style={{ height: '50px', lineHeight: '0.5' }} />
<Skeleton style={{ height: '50px', lineHeight: '0.5' }} />
Expand Down
20 changes: 20 additions & 0 deletions src/components/Organizations/NavTabs/OrgNavTabsSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import React, { FC } from 'react';

import getConfig from 'next/config';

import {
BellOutlined,
GlobalOutlined,
GroupOutlined,
ReadOutlined,
SettingOutlined,
TeamOutlined,
UnorderedListOutlined,
} from '@ant-design/icons';

import { StyledNavigation } from './StyledNavTabs';

/* eslint-disable-next-line
@typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-call
*/
const { publicRuntimeConfig } = getConfig();

interface NavSkeletonProps {
activeTab: string;
}
Expand Down Expand Up @@ -42,6 +51,17 @@ const OrgNavTabsSkeleton: FC<NavSkeletonProps> = ({ activeTab }) => (
<span className="destination">Projects</span>
</a>
</li>
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
publicRuntimeConfig.LAGOON_UI_VIEW_ENV_VARIABLES == null && (
<li className={`variables ${activeTab == 'variables' ? 'active' : ''} linkContainer`}>
<a className="navLink">
<UnorderedListOutlined className="icon" />
<span className="destination">Variables</span>
</a>
</li>
)
}
<li className={`notifications ${activeTab == 'notifications' ? 'active' : ''} linkContainer`}>
<a className="navLink">
<BellOutlined className="icon" />
Expand Down
14 changes: 14 additions & 0 deletions src/components/Organizations/NavTabs/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import React from 'react';

import getConfig from 'next/config';

import {
BellOutlined,
GlobalOutlined,
GroupOutlined,
ReadOutlined,
SettingOutlined,
TeamOutlined,
UnorderedListOutlined,
} from '@ant-design/icons';
import OrgGroupsLink from 'components/link/Organizations/Groups';
import OrgManageLink from 'components/link/Organizations/Manage';
import OrgNotificationsLink from 'components/link/Organizations/Notifications';
import OrganizationLink from 'components/link/Organizations/Organization';
import OrgProjectsLink from 'components/link/Organizations/Projects';
import OrgUsersLink from 'components/link/Organizations/Users';
import OrgVariablesLink from 'components/link/Organizations/Variables';

import { StyledNavigation } from './StyledNavTabs';

const { publicRuntimeConfig } = getConfig();

const OrgNavTabs = ({ activeTab, organization }) => {
return (
<StyledNavigation>
Expand Down Expand Up @@ -64,6 +70,14 @@ const OrgNavTabs = ({ activeTab, organization }) => {
<span className="destination">Projects</span>
</OrgProjectsLink>
</li>
{publicRuntimeConfig.LAGOON_UI_VIEW_ENV_VARIABLES == null && (
<li className={`variables ${activeTab == 'variables' ? 'active' : ''} linkContainer`} data-cy="envvars-tab">
<OrgVariablesLink organizationSlug={organization.name} className="navLink">
<UnorderedListOutlined className="icon" />
<span className="destination"> Variables</span>
</OrgVariablesLink>
</li>
)}
<li className={`notifications ${activeTab == 'notifications' ? 'active' : ''} linkContainer`}>
<OrgNotificationsLink
orgFriendlyName={organization.friendlyName}
Expand Down
Loading

0 comments on commit ce85294

Please sign in to comment.