Skip to content

Commit

Permalink
Remove favorites feature flag (#2722)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Dec 21, 2022
1 parent a0619e9 commit be045dc
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 91 deletions.
Expand Up @@ -90,27 +90,23 @@ export const FeatureToggleListTable: VFC = () => {

const columns = useMemo(
() => [
...(uiConfig?.flags?.favorites
? [
{
Header: (
<FavoriteIconHeader
isActive={isFavoritesPinned}
onClick={onChangeIsFavoritePinned}
/>
),
accessor: 'favorite',
Cell: ({ row: { original: feature } }: any) => (
<FavoriteIconCell
value={feature?.favorite}
onClick={() => onFavorite(feature)}
/>
),
maxWidth: 50,
disableSortBy: true,
},
]
: []),
{
Header: (
<FavoriteIconHeader
isActive={isFavoritesPinned}
onClick={onChangeIsFavoritePinned}
/>
),
accessor: 'favorite',
Cell: ({ row: { original: feature } }: any) => (
<FavoriteIconCell
value={feature?.favorite}
onClick={() => onFavorite(feature)}
/>
),
maxWidth: 50,
disableSortBy: true,
},
{
Header: 'Seen',
accessor: 'lastSeenAt',
Expand Down Expand Up @@ -179,7 +175,7 @@ export const FeatureToggleListTable: VFC = () => {
searchable: true,
},
],
[isFavoritesPinned, uiConfig?.flags?.favorites]
[isFavoritesPinned]
);

const {
Expand Down
13 changes: 3 additions & 10 deletions frontend/src/component/feature/FeatureView/FeatureView.tsx
Expand Up @@ -115,16 +115,9 @@ export const FeatureView = () => {
<div className={styles.header}>
<div className={styles.innerContainer}>
<div className={styles.toggleInfoContainer}>
<ConditionallyRender
condition={Boolean(
uiConfig?.flags?.favorites
)}
show={() => (
<FavoriteIconButton
onClick={onFavorite}
isFavorite={feature?.favorite}
/>
)}
<FavoriteIconButton
onClick={onFavorite}
isFavorite={feature?.favorite}
/>
<h1
className={styles.featureViewHeader}
Expand Down
11 changes: 3 additions & 8 deletions frontend/src/component/project/Project/Project.tsx
Expand Up @@ -156,14 +156,9 @@ const Project = () => {
<div className={styles.innerContainer}>
<StyledTopRow>
<StyledDiv>
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.favorites)}
show={() => (
<StyledFavoriteIconButton
onClick={onFavorite}
isFavorite={project?.favorite}
/>
)}
<StyledFavoriteIconButton
onClick={onFavorite}
isFavorite={project?.favorite}
/>
<h2 className={styles.title}>
<StyledName data-loading>
Expand Down
Expand Up @@ -193,28 +193,24 @@ export const ProjectFeatureToggles = ({

const columns = useMemo(
() => [
...(uiConfig?.flags?.favorites
? [
{
id: 'favorite',
Header: (
<FavoriteIconHeader
isActive={isFavoritesPinned}
onClick={onChangeIsFavoritePinned}
/>
),
accessor: 'favorite',
Cell: ({ row: { original: feature } }: any) => (
<FavoriteIconCell
value={feature?.favorite}
onClick={() => onFavorite(feature)}
/>
),
maxWidth: 50,
disableSortBy: true,
},
]
: []),
{
id: 'favorite',
Header: (
<FavoriteIconHeader
isActive={isFavoritesPinned}
onClick={onChangeIsFavoritePinned}
/>
),
accessor: 'favorite',
Cell: ({ row: { original: feature } }: any) => (
<FavoriteIconCell
value={feature?.favorite}
onClick={() => onFavorite(feature)}
/>
),
maxWidth: 50,
disableSortBy: true,
},
{
Header: 'Seen',
accessor: 'lastSeenAt',
Expand Down Expand Up @@ -303,7 +299,7 @@ export const ProjectFeatureToggles = ({
disableSortBy: true,
},
],
[projectId, environments, loading, onToggle, uiConfig?.flags?.favorites]
[projectId, environments, loading, onToggle]
);

const [searchValue, setSearchValue] = useState(
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/component/project/ProjectCard/ProjectCard.tsx
Expand Up @@ -69,16 +69,11 @@ export const ProjectCard = ({
return (
<Card className={classes.projectCard} onMouseEnter={onHover}>
<div className={classes.header} data-loading>
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.favorites)}
show={() => (
<FavoriteIconButton
onClick={onFavorite}
isFavorite={isFavorite}
size="medium"
sx={{ ml: -1 }}
/>
)}
<FavoriteIconButton
onClick={onFavorite}
isFavorite={isFavorite}
size="medium"
sx={{ ml: -1 }}
/>
<h2 className={classes.title}>{name}</h2>

Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Expand Up @@ -44,7 +44,6 @@ export interface IFlags {
embedProxyFrontend?: boolean;
changeRequests?: boolean;
variantsPerEnvironment?: boolean;
favorites?: boolean;
networkView?: boolean;
maintenance?: boolean;
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -74,7 +74,6 @@ exports[`should create default config 1`] = `
"changeRequests": false,
"embedProxy": true,
"embedProxyFrontend": true,
"favorites": false,
"maintenance": false,
"maintenanceMode": false,
"networkView": false,
Expand All @@ -92,7 +91,6 @@ exports[`should create default config 1`] = `
"changeRequests": false,
"embedProxy": true,
"embedProxyFrontend": true,
"favorites": false,
"maintenance": false,
"maintenanceMode": false,
"networkView": false,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/db/feature-strategy-store.ts
Expand Up @@ -259,7 +259,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
.modify(FeatureToggleStore.filterByArchived, archived);

let selectColumns = ['features_view.*'] as (string | Raw<any>)[];
if (userId && this.flagResolver.isEnabled('favorites')) {
if (userId) {
query = query.leftJoin(`favorite_features`, function () {
this.on(
'favorite_features.feature',
Expand Down Expand Up @@ -460,7 +460,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
'ft.tag_type as tag_type',
] as (string | Raw<any>)[];

if (userId && this.flagResolver.isEnabled('favorites')) {
if (userId) {
query = query.leftJoin(`favorite_features`, function () {
this.on('favorite_features.feature', 'features.name').andOnVal(
'favorite_features.user_id',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db/feature-toggle-client-store.ts
Expand Up @@ -146,7 +146,7 @@ export default class FeatureToggleClientStore
'ft.tag_type as tag_type',
];

if (userId && this.flagResolver.isEnabled('favorites')) {
if (userId) {
query = query.leftJoin(`favorite_features`, function () {
this.on(
'favorite_features.feature',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db/project-store.ts
Expand Up @@ -100,7 +100,7 @@ class ProjectStore implements IProjectStore {

let groupByColumns = ['projects.id'];

if (userId && this.flagResolver.isEnabled('favorites')) {
if (userId) {
projects = projects.leftJoin(`favorite_projects`, function () {
this.on('favorite_projects.project', 'projects.id').andOnVal(
'favorite_projects.user_id',
Expand Down
6 changes: 1 addition & 5 deletions src/lib/routes/admin-api/index.ts
Expand Up @@ -27,7 +27,6 @@ import PatController from './user/pat';
import { PublicSignupController } from './public-signup';
import InstanceAdminController from './instance-admin';
import FavoritesController from './favorites';
import { conditionalMiddleware } from '../../middleware';
import MaintenanceController from './maintenance';

class AdminApi extends Controller {
Expand Down Expand Up @@ -120,10 +119,7 @@ class AdminApi extends Controller {
);
this.app.use(
`/projects`,
conditionalMiddleware(
() => config.flagResolver.isEnabled('favorites'),
new FavoritesController(config, services).router,
),
new FavoritesController(config, services).router,
);

this.app.use(
Expand Down
4 changes: 0 additions & 4 deletions src/lib/types/experimental.ts
Expand Up @@ -35,10 +35,6 @@ const flags = {
process.env.UNLEASH_EXPERIMENTAL_VARIANTS_PER_ENVIRONMENT,
false,
),
favorites: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_FAVORITES,
false,
),
networkView: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_NETWORK_VIEW,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -40,7 +40,6 @@ process.nextTick(async () => {
anonymiseEventLog: false,
responseTimeWithAppName: true,
changeRequests: true,
favorites: true,
variantsPerEnvironment: true,
},
},
Expand Down
1 change: 0 additions & 1 deletion src/test/config/test-config.ts
Expand Up @@ -29,7 +29,6 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
batchMetrics: true,
changeRequests: true,
variantsPerEnvironment: true,
favorites: true,
},
},
};
Expand Down
104 changes: 104 additions & 0 deletions src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap
Expand Up @@ -5333,6 +5333,50 @@ If the provided project does not exist, the list of events will be empty.",
],
},
},
"/api/admin/projects/{projectId}/favorites": {
"delete": {
"operationId": "removeFavoriteProject",
"parameters": [
{
"in": "path",
"name": "projectId",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "This response has no body.",
},
},
"tags": [
"Features",
],
},
"post": {
"operationId": "addFavoriteProject",
"parameters": [
{
"in": "path",
"name": "projectId",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "This response has no body.",
},
},
"tags": [
"Features",
],
},
},
"/api/admin/projects/{projectId}/features": {
"get": {
"operationId": "getFeatures",
Expand Down Expand Up @@ -6304,6 +6348,66 @@ If the provided project does not exist, the list of events will be empty.",
],
},
},
"/api/admin/projects/{projectId}/features/{featureName}/favorites": {
"delete": {
"operationId": "removeFavoriteFeature",
"parameters": [
{
"in": "path",
"name": "projectId",
"required": true,
"schema": {
"type": "string",
},
},
{
"in": "path",
"name": "featureName",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "This response has no body.",
},
},
"tags": [
"Features",
],
},
"post": {
"operationId": "addFavoriteFeature",
"parameters": [
{
"in": "path",
"name": "projectId",
"required": true,
"schema": {
"type": "string",
},
},
{
"in": "path",
"name": "featureName",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "This response has no body.",
},
},
"tags": [
"Features",
],
},
},
"/api/admin/projects/{projectId}/features/{featureName}/variants": {
"get": {
"operationId": "getFeatureVariants",
Expand Down

0 comments on commit be045dc

Please sign in to comment.