Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[old-slugs] Serialize old slugs #286

Merged
merged 4 commits into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.yml
Expand Up @@ -23,7 +23,7 @@ settings:
- node_modules
react:
version: 'detect'
flowVersion: '0.96.0'
flowVersion: '0.97.0'
plugins:
- react
- prettier
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/@salesforce/design-system-react_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: ab5dcf325d82a5f5112b4788616b9471
// flow-typed version: <<STUB>>/@salesforce/design-system-react_v^0.9.0/flow_v0.96.0
// flow-typed version: <<STUB>>/@salesforce/design-system-react_v^0.9.0/flow_v0.97.0

declare module '@salesforce/design-system-react/components/icon-settings' {
import typeof { Component } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/i18next-browser-languagedetector_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: d5bebb24c198b8b74231bb5fa0817882
// flow-typed version: <<STUB>>/i18next-browser-languagedetector_v2.2.4/flow_v0.96.0
// flow-typed version: <<STUB>>/i18next-browser-languagedetector_v2.2.4/flow_v0.97.0

declare module 'i18next-browser-languagedetector' {
declare module.exports: any;
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/i18next-xhr-backend_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 2b448bf4c55f3c5371a34f2c887400b1
// flow-typed version: <<STUB>>/i18next-xhr-backend_v1.5.1/flow_v0.96.0
// flow-typed version: <<STUB>>/i18next-xhr-backend_v1.5.1/flow_v0.97.0

declare module 'i18next-xhr-backend' {
declare module.exports: any;
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/i18next_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: af080d8184ce79af580d5dd181600806
// flow-typed version: <<STUB>>/i18next_v14.0.1/flow_v0.96.0
// flow-typed version: <<STUB>>/i18next_v14.0.1/flow_v0.97.0

declare module 'i18next' {
declare module.exports: any;
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/react-document-title_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 67975ffb909e1dbe0300551c059ca396
// flow-typed version: <<STUB>>/react-document-title_v^2.0.3/flow_v0.96.0
// flow-typed version: <<STUB>>/react-document-title_v^2.0.3/flow_v0.97.0

declare module 'react-document-title' {
import typeof { Component } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/react-i18next_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 77362cb1828c1356cf43e9cd69ab9a3d
// flow-typed version: <<STUB>>/react-i18next_v9.0.8/flow_v0.96.0
// flow-typed version: <<STUB>>/react-i18next_v9.0.8/flow_v0.97.0

declare module 'react-i18next' {
declare module.exports: any;
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/redux-logger_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 330cc1c31072d248a0357b501c4d516a
// flow-typed version: <<STUB>>/redux-logger_v^3.0.6/flow_v0.96.0
// flow-typed version: <<STUB>>/redux-logger_v^3.0.6/flow_v0.97.0

declare module 'redux-logger' {
declare export default function logger(): any;
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/redux-thunk_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: c23c95a12acfb8035253190639fc973f
// flow-typed version: <<STUB>>/redux-thunk_v^2.3.0/flow_v0.96.0
// flow-typed version: <<STUB>>/redux-thunk_v^2.3.0/flow_v0.97.0

declare module 'redux-thunk' {
import type { DispatchAPI } from 'redux';
Expand Down
2 changes: 1 addition & 1 deletion flow-typed/npm/sockette_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 960bce3f9537642de3e3ec11f2cf81b2
// flow-typed version: <<STUB>>/sockette_v^2.0.0/flow_v0.96.0
// flow-typed version: <<STUB>>/sockette_v^2.0.0/flow_v0.97.0

declare module 'sockette' {
declare export default class Sockette {
Expand Down
31 changes: 31 additions & 0 deletions metadeploy/api/migrations/0067_allowedlist_org_type_help_text.py
@@ -0,0 +1,31 @@
# Generated by Django 2.2 on 2019-04-15 13:44

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [("api", "0066_remove_blank_choice_from_allowedlist")]

operations = [
migrations.AlterField(
model_name="allowedlist",
name="org_type",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
blank=True,
choices=[
("Production", "Production"),
("Scratch", "Scratch"),
("Sandbox", "Sandbox"),
("Developer", "Developer"),
],
max_length=64,
),
default=list,
help_text="All orgs of these types will be automatically allowed.",
size=4,
),
)
]
5 changes: 5 additions & 0 deletions metadeploy/api/models.py
Expand Up @@ -226,6 +226,11 @@ def slug(self):
return slug.slug
return None

@property
def old_slugs(self):
slugs = self.slug_queryset.filter(is_active=True)[1:]
return [slug.slug for slug in slugs]

@property
def slug_parent(self):
return self
Expand Down
2 changes: 2 additions & 0 deletions metadeploy/api/serializers.py
Expand Up @@ -142,6 +142,7 @@ class Meta:
"preflight_message",
"tier",
"slug",
"old_slugs",
"steps",
"is_allowed",
"is_listed",
Expand Down Expand Up @@ -219,6 +220,7 @@ class Meta:
"image",
"most_recent_version",
"slug",
"old_slugs",
"is_allowed",
"is_listed",
"order_key",
Expand Down
5 changes: 5 additions & 0 deletions metadeploy/api/tests/views.py
Expand Up @@ -193,6 +193,7 @@ def test_product(self, client, product_factory, version_factory):
"is_listed": True,
},
"slug": product.slug,
"old_slugs": [],
"is_allowed": True,
"is_listed": True,
"order_key": 0,
Expand Down Expand Up @@ -228,6 +229,7 @@ def test_plan(self, client, plan_factory):
"preflight_message": "",
"tier": "primary",
"slug": "sample-plan",
"old_slugs": [],
"steps": [],
"is_allowed": True,
"is_listed": True,
Expand All @@ -247,6 +249,7 @@ def test_plan__not_visible(self, client, allowed_list_factory, plan_factory):
"preflight_message": None,
"tier": "primary",
"slug": "sample-plan",
"old_slugs": [],
"steps": None,
"is_allowed": False,
"is_listed": True,
Expand Down Expand Up @@ -279,6 +282,7 @@ def test_plan__visible(
"preflight_message": "",
"tier": "primary",
"slug": "sample-plan",
"old_slugs": [],
"steps": [],
"is_allowed": True,
"is_listed": True,
Expand All @@ -302,6 +306,7 @@ def test_plan__visible_superuser(
"preflight_message": "",
"tier": "primary",
"slug": "sample-plan",
"old_slugs": [],
"steps": [],
"is_allowed": True,
"is_listed": True,
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -56,7 +56,7 @@
"react-document-title": "^2.0.3",
"react-dom": "^16.8.6",
"react-i18next": "^10.7.0",
"react-redux": "^7.0.1",
"react-redux": "^7.0.2",
"react-router-dom": "5.0.0",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.8",
Expand Down Expand Up @@ -84,15 +84,15 @@
"css-loader": "^2.1.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-import-resolver-webpack": "^0.11.0",
"eslint-import-resolver-webpack": "^0.11.1",
"eslint-plugin-flowtype": "^3.6.1",
"eslint-plugin-flowtype-errors": "^4.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-import": "^2.17.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
"fetch-mock": "^7.3.1",
"file-loader": "^3.0.1",
"flow-bin": "^0.96.0",
"flow-bin": "^0.97.0",
"flow-typed": "^2.5.1",
"html-webpack-plugin": "^3.2.0",
"husky": "^1.3.1",
Expand All @@ -108,15 +108,15 @@
"nyc": "^13.3.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-loader": "^3.0.0",
"prettier": "^1.16.4",
"prettier": "^1.17.0",
"react-testing-library": "^6.1.2",
"redux-mock-store": "^1.5.3",
"sass-loader": "^7.1.0",
"stylelint": "^9.10.1",
"stylelint": "^10.0.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-scss": "^3.5.4",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.3.1",
"webpack-merge": "^4.2.1"
Expand Down
12 changes: 11 additions & 1 deletion src/js/components/jobs/detail.js
Expand Up @@ -11,9 +11,10 @@ import { CONSTANTS } from 'store/plans/reducer';
import { fetchJob, requestCancelJob, updateJob } from 'store/jobs/actions';
import { fetchVersion } from 'store/products/actions';
import { selectJob, selectJobId } from 'store/jobs/selectors';
import { selectPlan } from 'store/plans/selectors';
import { selectPlan, selectPlanSlug } from 'store/plans/selectors';
import {
selectProduct,
selectProductSlug,
selectVersion,
selectVersionLabel,
} from 'store/products/selectors';
Expand Down Expand Up @@ -47,9 +48,11 @@ type Props = {
...InitialProps,
user: UserType,
product: ProductType | null,
productSlug: ?string,
version: VersionType | null,
versionLabel: ?string,
plan: PlanType | null,
planSlug: ?string,
job: ?JobType,
jobId: ?string,
doFetchVersion: typeof fetchVersion,
Expand Down Expand Up @@ -170,21 +173,26 @@ class JobDetail extends React.Component<Props, State> {
const {
user,
product,
productSlug,
version,
versionLabel,
plan,
planSlug,
job,
jobId,
doUpdateJob,
} = this.props;
const loadingOrNotFound = getLoadingOrNotFound({
product,
productSlug,
version,
versionLabel,
plan,
planSlug,
job,
jobId,
isLoggedIn: user !== null,
route: 'job_detail',
});
if (loadingOrNotFound !== false) {
return loadingOrNotFound;
Expand Down Expand Up @@ -269,9 +277,11 @@ class JobDetail extends React.Component<Props, State> {
const select = (appState: AppState, props: InitialProps) => ({
user: selectUserState(appState),
product: selectProduct(appState, props),
productSlug: selectProductSlug(appState, props),
version: selectVersion(appState, props),
versionLabel: selectVersionLabel(appState, props),
plan: selectPlan(appState, props),
planSlug: selectPlanSlug(appState, props),
job: selectJob(appState, props),
jobId: selectJobId(appState, props),
});
Expand Down
16 changes: 15 additions & 1 deletion src/js/components/plans/detail.js
Expand Up @@ -12,9 +12,14 @@ import { CONSTANTS } from 'store/plans/reducer';
import { fetchPreflight, startPreflight } from 'store/plans/actions';
import { fetchVersion } from 'store/products/actions';
import { selectOrg } from 'store/org/selectors';
import { selectPlan, selectPreflight } from 'store/plans/selectors';
import {
selectPlan,
selectPlanSlug,
selectPreflight,
} from 'store/plans/selectors';
import {
selectProduct,
selectProductSlug,
selectVersion,
selectVersionLabel,
} from 'store/products/selectors';
Expand Down Expand Up @@ -53,9 +58,11 @@ type Props = {
...InitialProps,
user: UserType,
product: ProductType | null,
productSlug: ?string,
version: VersionType | null,
versionLabel: ?string,
plan: PlanType | null,
planSlug: ?string,
preflight: ?PreflightType,
org: OrgType,
doFetchVersion: typeof fetchVersion,
Expand Down Expand Up @@ -276,16 +283,21 @@ class PlanDetail extends React.Component<Props, State> {
const {
user,
product,
productSlug,
version,
versionLabel,
plan,
planSlug,
preflight,
} = this.props;
const loadingOrNotFound = getLoadingOrNotFound({
product,
productSlug,
version,
versionLabel,
plan,
planSlug,
route: 'plan_detail',
});
if (loadingOrNotFound !== false) {
return loadingOrNotFound;
Expand Down Expand Up @@ -398,9 +410,11 @@ class PlanDetail extends React.Component<Props, State> {
const select = (appState: AppState, props: InitialProps) => ({
user: selectUserState(appState),
product: selectProduct(appState, props),
productSlug: selectProductSlug(appState, props),
version: selectVersion(appState, props),
versionLabel: selectVersionLabel(appState, props),
plan: selectPlan(appState, props),
planSlug: selectPlanSlug(appState, props),
preflight: selectPreflight(appState, props),
org: selectOrg(appState),
});
Expand Down